How to Import VMs from Export-domain via API call ?

Solution Verified - Updated -

Issue

  • I am using a script to clone/import an existing VM from our attached Export Domain.
#!/bin/bash

exec 3<&0
exec 0<vecs

while read LINE; do
NAME=`echo ${LINE} | awk -F, '{print $1}'`
MAC=`echo ${LINE} | awk -F, '{print $2}'`
IP=`echo ${LINE} | awk -F, '{print $3}'`
curl -X POST -H "Accept: application/xml" -H "Content-Type: application/xml" --cacert /root/rhevm.cer -v -u "user@rhevm_fqdn.com:PASSWORD" -d '<action>
  <storage_domain>
    <name>Export</name>
  </storage_domain>
  <cluster>
    <name>admin_user_name</name>
  </cluster>
  <clone>true</clone>
  <vm>
    <name>'${NAME}'</name>
  </vm>
</action>' "https://rhevm._fqdn.com/api/storagedomains/6490f123-338e-496c-bb3f-8ce40cf48d29/vms/96fadf5c-d9ae-4194-873b-437176a7f0c5/import"
done

exec 0<&3
  • The file 'vecs' (in the script) contains lines such as
VMvec01,00:1a:4a:xx:xx:xx,172.22.107.60
VMvec02,00:1a:4a:xx:xx:xx,172.22.107.61
VMvec03,00:1a:4a:xx:xx:xx,172.22.107.62
  • When I try to run this script I get:
------>8(output truncated)8<-------
<clone>true</clone>
    <status>
        <state>failed</state>
    </status>
    <fault>
        <reason>Operation Failed</reason>
        <detail>[Cannot import VM. Storage Domain type not specified.]</detail>
    </fault>
------>8(output truncated)8<-------

Environment

  • Red Hat Enterprise Virtualization 3.3

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.