[ovirt-users] API Importing a VM from an export domain fails

Juan Hernández jhernand at redhat.com
Wed Jan 13 10:01:55 UTC 2016


On 01/12/2016 08:44 PM, Tim Bielawa wrote:
> Hello virt folks,
> 
> Background:
> 
> I'm using the REST API to import a VM from an attached export domain.
> The VM was imported using the virt-v2v tool. I've tried this with cURL
> and with the python SDK, both yield the same error message.
> 
> RHEVM Version: 3.5.6.0-1
> Python SDK Version: 3.5.6.0-1
> 
> According to the documentation, importing should follow this syntax:
> 
>> POST
> /ovirt-engine/api/storagedomains/{storagedomain:id}/vms/{vm:id}/import
> 
> With a small <action> body attached. In theory (by the documentation and
> bug tracker [1]) either of these XML documents (both in the same paste)
> should work:
> 
> http://fpaste.org/309944/52627148/
> 
> However, this fails with the following error message (full response in [2])
> 
>> Cannot import VM. Storage Domain type not specified.
> 
> 
> Steps to reproduce:
> 
> 1. Import a VM into an export storage domain
> 2. Create an XML document with an action like this (filling in the
> correct values for the ID variables)
> 
>     <action>
>       <cluster id="<CLUSTER_ID>"/>
>       <storage_domain id="<STORAGE_DOMAIN_ID>">
>         <type>export</type>
>       </storage_domain>
>       <clone>True</clone>
>       <vm>
>         <name>IMPORTED_VM</name>
>       </vm>
>     </action>
> 
> 
> 3. POST to the import location (again, substitute the correct ID
> variables in the location)
> 
>     /ovirt-engine/api/storagedomains/<STORAGE_DOMAIN_ID>/vms/<VM_ID>/import
> 
> 
> 
> Where is this storage domain type supposed to be defined, if not inside
> of the storage_domain element as demonstrated in the documentation?
> 
> I would appreciate any advice you can offer or pointers to useful
> resources/documentation.
> 
> Thanks!
> 
> 
> [1] https://bugzilla.redhat.com/show_bug.cgi?id=1147011#c13
> [2] http://fpaste.org/309949/14526274/
> 
> -- 
> Tim Bielawa
> 1BA0 4FAB 4C13 FBA0 A036  4958 AD05 E75E 0333 AE37
> 

The bug that you are referring to (bug 1147011) isn't fixed in version
3.5, and there are no plans to fix it, as far as I know. It will be
fixed on only in 3.6. This means that you have to apply the workaround
that Sven Kieske mentions in the description of the bug. So the XML
document to send should look like this:

  <action>
    <cluster id="00000001-0001-0001-0001-000000000001"/>
    <storage_domain id="00000001-0001-0001-0001-000000000002"/>
    <clone>true</clone>
    <vm>
      <name>TBIELAWA_IMPORTED_VM</name>

      <!-- Note that this "snapshot" element is needed to avoid
           the bug, even if the VM doesn't have any snapshot. -->
      <snapshots>
        <collapse_snapshots>true</collapse_snapshots>
      </snapshots>

    </vm>
  </action>

With the Python SDK should be something like this:

  # Find the target cluster and storage domain:
  target_cluster_id = api.clusters.get(name="mycluster").get_id()
  target_sd_id = api.storagedomains.get(name="mydata").get_id()

  # Find the export storage domain:
  export_sd = api.storagedomains.get(name="myexport")

  # Find the VM:
  vm = export_sd.vms.get(name="myvm")

  # Import the VM:
  vm.import_vm(
      params.Action(
          cluster=params.Cluster(id=target_cluster_id),
          storage_domain=params.StorageDomain(id=target_sd_id),
          clone=True,
          vm=params.VM(
              name="TBIELAWA_IMPORTED_VM",
              snapshots=params.Snapshots(
                  collapse_snapshots=True
              )
          )
      )
  )

-- 
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta
3ºD, 28016 Madrid, Spain
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.



More information about the Users mailing list