Previous page

Next page

Locate page in Contents

Print this page

Removing an Existing Virtual Machine

If a virtual machine is no longer needed, it can be removed. There are two options for removing a virtual machine:

  1. Un-register the virtual machine without deleting its files. You can re-register the virtual machine later if needed.
  2. Delete the virtual machine from the host completely. The virtual machine cannot be recovered if this option is used.

The following sample function illustrates how to implement both options. The function takes a Vm object identifying the virtual machine and a boolean value indicating whether the virtual machine files should be deleted from the host computer.

def remove_vm(vm, delete):

  

    if delete == False:

        # Unregister the virtual machine but don't delete its files.

        try:

            vm.unreg()

        except prlsdkapi.PrlSDKAsyncError, e:

            print "Error: %s" % e

            return            

    else:

        # Unregister the machine and delete its files from the hard drive.

        try:

            vm.delete()

        except prlsdkapi.PrlSDKAsyncError, e:

            print "Error: %s" % e

            return

  

    print "Virtual machine " + vm.name + " has been removed."

Please send us your feedback on this help page