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:
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