Creating vm from snapshot via API

Hi. I'm trying to create vm from a snapshot using API. If I just provide the new vm name, source snapshot ID and cluster name the new vm is been created successfully on the same storage domain. But if I additionally provide diskattachments to create it on another storage I get error: "Cannot add VM. One or more provided storage domains are either not in active status or of an illegal type for the requested operation". I can't find the reason why I can't create vm on another storage via API while I can do the same via web-portal. My oVirt Engine version is 4.1.1.8-1.el7.centos. Here is my code: curl.exe -k -u "user@domain.suffix:*************" -H "Content-Type: application/xml" -H "Accept: application/xml" -X POST https://192.168.0.1/ovirt-engine/api/vms -d "<vm><name>vm-Test1</name><snapshots><snapshot id=\"4b73c79b-efed-4362-8843-91f5cc2d9775\"/></snapshots><cluster><name>MyCluster</name></cluster><disk_attachments><disk_attachment><disk><image_id>6525c157-4e73-440b-adc8-596f1d03ef3c</image_id><storage_domains><storage_domain id=\"52a003d7-cec1-473e-b521-1a551f55abd1\"/></storage_domains></disk></disk_attachment></disk_attachments></vm>" The answer is: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <fault> <detail>[Cannot add VM. One or more provided storage domains are either not in active status or of an illegal type for the requested operation.]</detail> <reason>Operation Failed</reason> </fault>

I forgot to mention I'm trying to create vm from snapshot according to the documentation: 5.241.1 add post ... When creating a virtual machine from a template or from a snapshot it is usually useful to explicitly indicate in what storage domain to create the disks for the virtual machine. If the virtual machine is created from a template then this is achieved passing a set of disk_attachment elements that indicate the mapping: <vm> ... <disk_attachments> <disk_attachment> <disk id="8d4bd566-6c86-4592-a4a7-912dbf93c298"> <storage_domains> <storage_domain id="9cb6cb0a-cf1d-41c2-92ca-5a6d665649c9"/> </storage_domains> </disk> <disk_attachment> </disk_attachments> </vm> When the virtual machine is created from a snapshot this set of disks is slightly different, it uses the image_id attribute instead of id. <vm> ... <disk_attachments> <disk_attachment> <disk> <image_id>8d4bd566-6c86-4592-a4a7-912dbf93c298</image_id> <storage_domains> <storage_domain id="9cb6cb0a-cf1d-41c2-92ca-5a6d665649c9"/> </storage_domains> </disk> <disk_attachment> </disk_attachments> </vm>

So, if someone has any ideas or can suggest the directions for further research I will be grateful.
participants (1)
-
Aleksei Ivanovich