Product SiteDocumentation Site

3.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.
  1. 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 3.3.2, “Converting a Virtual Machine”.
  2. Once the conversion is complete, use the Red Hat Enterprise Virtualization Powershell API to import the virtual machines from the export storage domain. This step must be run on the Red Hat Enterprise Virtualization Manager server. The Import-Vm command performs the import process, and must be run once per virtual machine.
    Example 3.4. Importing all VMs from the export storage domain to the DataStore storage domain on the Default Data Center
    $exportdomain = Get-StorageDomain | ? {$_.Name -eq "export"}
    $datadomain = Get-StorageDomain | ? {$_.Name -eq "DataStore"}
    $dc = Select-DataCenter Name=Default
    $cluster = Select-Cluster Name=Default
    $candidates = Get-VmImportCandidates -StorageDomainId $exportdomain.StorageDomainId -DataCenterId $dc.DataCenterId
    foreach ($candidate in $candidates)
    {
    	Import-Vm -DataCenterId $dc.DataCenterId -SourceDomainId $exportdomain.StorageDomainId -DestDomainId $datadomain.StorageDomainId -ClusterId $cluster.ClusterId -VmId $candidate.VmId
    }
    

    Detailed documentation for the PowerShell API is available in the Red Hat Enterprise Virtualization PowerShell API Guide.