Name, Description, Boot Options, RAM sizeThe virtual machine name, description, and RAM size modifications are simple. They are performed by invoking a corresponding method of a Example """ Modify the vrtual machine name, RAM size, and boot options. """ def vm_edit(vm):
# Begin the virtual machine editing operation. try: vm.begin_edit().wait() except prlsdkapi.PrlSDKError, e: print "Error: %s" % e return
# Obtain the VmConfig object containing the virtual machine # configuration information. vm_config = vm.get_config()
vm.set_name(vm.get_name() + "_modified") vm.set_ram_size(256) vm.set_description("SDK Test Machine")
# Modify boot device priority using the following order:. # CD > HDD > Network > FDD. # Remove all other devices from the boot priority list (if any). count = vm_config.get_boot_dev_count() for i in range(count):
# Obtain an instance of the prlsdkapi.BootDevice class # containing the boot device information. boot_dev = vm_config.get_boot_dev(i)
# Enable the device. boot_dev.set_in_use(True)
# Set the device sequence index. dev_type = boot_dev.get_type()
if dev_type == consts.PDE_OPTICAL_DISK: boot_dev.set_sequence_index(0) elif dev_type == consts.PDE_HARD_DISK: boot_dev.set_sequence_index(1) elif dev_type == consts.PDE_GENERIC_NETWORK_ADAPTER: boot_dev.set_sequence_index(2) elif dev_type == consts.PDE_FLOPPY_DISK: boot_dev.set_sequence_index(3) else: boot_dev.remove()
# Commit the changes. try: vm.commit().wait() except prlsdkapi.PrlSDKError, e: print "Error: %s" % e return |
||||
|