이 콘텐츠는 선택한 언어로 제공되지 않습니다.

4.3.5. Scripted bulk v2v process


For bulk import scenarios, it is advantageous to be able to perform the scripted v2v process from a single host. Remote procedure calls to the Red Hat Enterprise Virtualization Manager can be made using the REST API. This enables a single script running on a single Linux host to perform both steps of the v2v process. Figure 4.5, “Scripted bulk v2v process” illustrates the steps performed by the script.
Scripted bulk v2v process

Figure 4.5. Scripted bulk v2v process

The scripted bulk v2v process involves the following steps, as shown in Figure 4.5, “Scripted bulk v2v process”:
  1. The virtual machine image is retrieved from the source hypervisor.
  2. The virtual machine image is packaged and copied to the export storage domain.
  3. A remote procedure call is made to the Red Hat Enterprise Virtualization Manager, telling it to import the virtual machine.
  4. The Manager imports the virtual machine from the export storage domain.
To configure and run the scripted bulk v2v process:

Procedure 4.9. Configuring and running the scripted bulk v2v process

  1. Ensure the REST API is enabled on the Red Hat Enterprise Virtualization Manager, and it is accessible from the Linux host running the v2v process. For more information about the REST API, see the Red Hat Enterprise Virtualization REST API Guide Guide.
  2. On the Linux host, create the file v2v.sh with the following contents. Ensure you edit the script to contain appropriate values for your environment.

    Example 4.5. Single host v2v script

    #!/bin/sh
    # Declare all VMs to import
    XENDOMAINS=("rhelxen" "rhel5")
    KVMDOMAINS=("rhelkvm")
    VMWAREVMS=("rhel54vmware")
    
    # Iterate through each Xen domain, performing the conversion
    for domain in ${XENDOMAINS[@]}
    do
            virt-v2v -ic xen:///localhost -o rhev -os storage.example.com:/exportdomain --network rhevm $domain
    done
    
    # Iterate through each KVM domain, performing the conversion
    for domain in ${KVMDOMAINS[@]}
    do
            virt-v2v -o rhev -os storage.example.com:/exportdomain --network rhevm $domain
    done
    
    # Iterate through each VMware VM, performing the conversion
    for vm in ${VMWAREVMS[@]}
    do
            virt-v2v -ic esx://esx.example.com/?no_verify=1 -o rhev -os storage.example.com:/exportdomain --network rhevm $vm
    done
    
    
    # Call the import VM procedure remotely on the RHEV Manager
    
    export BASE_URL='https://[rhevm-host]'
    export HTTP_USER='user@internal'
    export HTTP_PASSWORD='password'
    
    curl -o rhevm.cer http://[rhevm-host]/ca.crt
    
    # Get the export storage domains
    
    curl -X GET -H "Accept: application/xml" -u "${HTTP_USER}:${HTTP_PASSWORD}" --cacert rhevm.cer ${BASE_URL}/api/storagedomains?search=nfs_export -o exportdomain
    EXPORT_DOMAIN=`xpath exportdomain '/storage_domains/storage_domain/@id' | sed -e 's/ id=//' | sed -e 's/"//g'`
    
    # Get the datacenter
    
    curl -X GET -H "Accept: application/xml" -u "${HTTP_USER}:${HTTP_PASSWORD}" --cacert rhevm.cer ${BASE_URL}/api/datacenters?search=NFS -o dc
    DC=`xpath dc '/data_centers/data_center/@id' | sed -e 's/ id=//' | sed -e 's/"//g'`
    
    # Get the cluster
    
    curl -X GET -H "Accept: application/xml" -u "${HTTP_USER}:${HTTP_PASSWORD}" --cacert rhevm.cer ${BASE_URL}/api/clusters?search=NFS -o cluster
    CLUSTER_ELEMENT=`xpath cluster '/clusters/cluster/@id' | sed -e 's/ id=//' | sed -e 's/"//g'`
    
    # List contents of export storage domain
    
    curl -X GET -H "Accept: application/xml" -u "${HTTP_USER}:${HTTP_PASSWORD}" --cacert rhevm.cer ${BASE_URL}/api/storagedomains/${EXPORT_DOMAIN}/vms -o vms
    
    # For each vm, export
    VMS=`xpath vms '/vms/vm/actions/link[@rel="import"]/@href' | sed -e 's/ href="//g' | sed -e 's/"/ /g'`
    
    for vms in $VMS
    do
            curl -v -u "${HTTP_USER}:${HTTP_PASSWORD}" -H "Content-type: application/xml" -d '<action><cluster><name>cluster_name</name></cluster><storage_domain><name>data_domain</name></storage_domain><overwrite>true</overwrite><discard_snapshots>true</discard_snapshots></action>' --cacert rhevm.cer ${BASE_URL}$vms
    done
    
    

    Note

    Use the POST method to export virtual machines with the REST API. For more information about using the REST API, see the Red Hat Enterprise Virtualization REST API Guide.
  3. Run the v2v.sh script. It can take several hours to convert and import a large number of virtual machines.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.