4.3.4. Scripting the v2v process
The entire v2v process can be scripted, enabling the automated batch processing of a large number of virtual machines. The process is broken up into two steps, which must be run on separate hosts.
Procedure 4.8. Scripting the v2v process
- Use
virt-v2v
to convert the virtual machines and copy them to the export storage domain. This step must be run on a Linux host. The process is detailed in Section 4.3.2, “Converting a virtual machine”. - Once the conversion is complete, use the Red Hat Enterprise Virtualization Administration Portal to import the virtual machines from the export storage domain. This step must be run on the Red Hat Enterprise Virtualization Manager server.For more information on importing a virtual machine with the Red Hat Enterprise Virtualization Administration Portal, see the Red Hat Enterprise Virtualization Administration Guide.
Figure 4.4. Importing a virtual machine with the Red Hat Enterprise Virtualization Administration Portal
Alternatively, the Python SDK or the command line can also be used to import the virtual machines from the export storage domain:To import the virtual machines using the SDK, use the following:Example 4.3. Importing virtual machines from the export storage domain using the SDK
api = API(url="http(s)://...:.../api", username="...", password="...", filter=False, debug=True) sd = api.storagedomains.get(id="from-sd-id") import_candidate = sd.vms.get(id="vm-to-import") import_candidate.import_vm(action=params.Action( cluster=api.clusters.get(id="to-cluster-id"), storage_domain=api.storagedomains.get(id="to-sd-id")))
Note
When using the SDK method, entities can also be fetched and passed usingname=
.To import the virtual machines using the command line, connect to the Red Hat Enterprise Virtualization Manager shell and use the following command:Example 4.4. Importing virtual machines from the export storage domain using the command line
action vm "vm-to-import" import_vm --storagedomain-identifier "from-sd-id" --cluster-id "to-cluster-id" --storage_domain-id "to-sd-id"
Note
When using the command line method, entities can also be fetched and passed using-name
.