Search

4.3.4. Scripting the v2v process

download PDF
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

  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 4.3.2, “Converting a virtual machine”.
  2. 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.
    The Import Virtual Machine(s) wizard.

    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 using name=.
    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.
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.