Previous page

Next page

Locate page in Contents

Print this page

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 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 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 the new machine as a virtual machine or as a template.

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

The following sample function demonstrates how to clone an existing virtual machine.

def clone_vm(vm):

    try:

        new_name = "Clone of " + vm.name

        print "Cloning is in progress..."

  

        # 1st parameter - new virtual machine name.

        # 2nd parameter - create the machine in the default directory.

        # 3rd parameter - create as a virtual machine (not as a template).

        # This is an asynchronous method, so wait() should be used.

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

    except prlsdkapi.PrlSDKAsyncError, e:

        print "Error: %s" % e

        return

    

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

Please send us your feedback on this help page