Previous page

Next page

Locate page in Contents

Cloning a Virtual Machine

A new virtual machine can be created by cloning an existing virtual machine. The machine will be created as an exact copy of the source virtual machine and will be automatically registered with the Parallels Service. The cloning operation is performed using the prlsdkapi.Vm.clone method. The following parameters must be specified when cloning a virtual machine:

  1. A unique name for the new virtual machine (the new name is NOT generated automatically).
  2. The name of the directory where the new virtual machine files should be created or an empty string to create the files in the default directory.
  3. A boolean value specifying whether to create a regular virtual machine or a virtual machine template. Virtual machine templates are used to create other virtual machines from them. You cannot run a template.

The source virtual machine must be registered with the Parallels Service before it can be cloned.

Sample

"""

    Clone a virtual machine.

    @param vm: An instance of the prlsdkapi.Vm class identifying

               the source virtual machine.

"""

def clone_vm(vm):

    

    try:

        new_name = "Clone_2 of " + vm.get_config().get_name()

        print "Clonning is in progress..."

        # Second parameter - create a new machine in the

        # default directory.

        # Third parameter - create a virtual machine (not a template).

        vm.clone(new_name, "", False).wait()

    except prlsdkapi.PrlSDKError, e:

        print "Error: %s" % e

        return

    

    print "Cloning was successful. New virtual machine name: " + new_name