ebook img

Python API Reference Guide PDF

509 Pages·2016·2.53 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Python API Reference Guide

Python API Reference Guide • • • PDE_ PDE_GENERIC_DEVICE, PDE_HARD_DISK, PDE_GENERIC_NETWORK_ADAPTER • PDE_HARD_DISK PDE HARD DISK # Create a Virtual Machine def create(server): # Get the ServerConfig object. result = server.get_srv_config().wait() srv_config = result.get_param() # Create a Vm object and set the virtual server type # to Virtual Machine (PVT_VM). vm = server.create_vm() vm.set_vm_type(consts.PVT_VM) # Set a default configuration for the VM. vm.set_default_config(srv_config, \ consts.PVS_GUEST_VER_WIN_WINDOWS8, True) # Set the VM name. vm.set_name("Windows8") # Modify the default RAM and HDD size. vm.set_ram_size(256) dev_hdd = vm.get_hard_disk(0) dev_hdd.set_disk_size(3000) # Register the VM with the Parallels Cloud Server. vm.reg("", True).wait() # Change VM name. def setName(vm, name): print 'set_name' vm.begin_edit().wait() vm.set_name(name) vm.commit().wait() # Set boot device priority def vm_boot_priority(vm): # Begin the virtual server editing operation. vm.begin_edit().wait() # 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.get_boot_dev_count() for i in range(count): boot_dev = vm.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. vm.commit().wait() # Execute a program in a VM. def execute(vm): # Log in. g_login = "Administrator" g_password = "12345" # Create a StringList object to hold the # program input parameters and populate it. hArgsList = prlsdkapi.StringList() hArgsList.add_item("cmd.exe") hArgsList.add_item("/C") hArgsList.add_item("C:\\123.bat") # Create an empty StringList object. # The object is passed to the VmGuest.run_program method and # is used to specify the list of environment variables and # their values to add to the program execution environment. # In this sample, we are not adding any variables. # If you wish to add a variable, add it in the var_name=var_value format. hEnvsList = prlsdkapi.StringList() hEnvsList.add_item("") # Establish a user session. vm_guest = vm.login_in_guest(g_login, g_password).wait().get_param() # Run the program. vm_guest.run_program("cmd.exe", hArgsList, hEnvsList).wait() # Log out. vm_guest.logout().wait() Package prlsdkapi 1 Package prlsdkapi 1.1 Modules • prlsdk (Section 2, p. 168) – consts (Section 3, p. 278) – errors (Section 4, p. 342) 1.2 Functions conv error(err) sdk check result(result, err obj=None) call sdk function(func name, *args) set sdk library path(path) get sdk library path() is sdk initialized() init desktop sdk() init desktop mas sdk() init desktop wl sdk() init workstation sdk() init player sdk() init server sdk() conv handle arg(arg) handle to object(handle) 1.3 Variables Name Description prlsdk module Value: os.environ [’PRLSDK’] continued on next page 7 Class PrlSDKError Package prlsdkapi Name Description sdklib Value: os.environ [’SDKLIB’] err Value: ’Cannot import module "prlsdk" !’ deinit sdk Value: DeinitSDK() package Value: ’prlsdkapi’ 1.4 Class PrlSDKError object exceptions.BaseException exceptions.Exception prlsdkapi.PrlSDKError 1.4.1 Methods init (self, result, error code, err obj) x. init (...) initializes x; see help(type(x)) for signature Overrides: object. init extit(inherited documentation) get result(self) get details(self) Inherited from exceptions.Exception new () Inherited from exceptions.BaseException delattr (), getattribute (), getitem (), getslice (), reduce (), repr (), setattr (), setstate (), str (), unicode () Inherited from object format (), hash (), reduce ex (), sizeof (), subclasshook () 1.4.2 Properties Name Description Inherited from exceptions.BaseException args, message continued on next page 8 Class ApiHelper Package prlsdkapi Name Description Inherited from object class 1.5 Class ApiHelper Provides common Parallels Python API system methods. 1.5.1 Methods init(self, version) Initialize the Parallels API library. init ex(self, nVersion, nAppMode, nFlags=0, nReserved=0) Initialize the Parallels API library (extended version). deinit(self) De-initializes the library. get version(self) Return the Parallels API version number. get app mode(self) Return the Parallels API application mode. get result description(self, nErrCode, bIsBriefMessage=True, bFormated=False) Evaluate a return code and return a description of the problem. get message type(self, nErrCode) Evaluate the specified error code and return its classification (warning, question, info, etc.). msg can be ignored(self, nErrCode) Evaluate an error code and determine if the error is critical. 9 Class ApiHelper Package prlsdkapi get crash dumps path(self) Return the name and path of the directory where Parallels crash dumps are stored. init crash handler(self, sCrashDumpFileSuffix) Initiate the standard Parallels crash dump handler. create strings list(self) create handles list(self) create op type list(self, nTypeSize) get supported oses types(self, nHostOsType) Determine the supported OS types for the current API mode. get supported oses versions(self, nHostOsType, nGuestOsType) get default os version(self, nGuestOsType) Return the default guest OS version for the specified guest OS type. send problem report(self, sProblemReport, bUseProxy, sProxyHost, nProxyPort, sProxyUserLogin, sProxyUserPasswd, nProblemSendTimeout, nReserved) Send a problem report to the Parallels support server. send packed problem report(self, hProblemReport, bUseProxy, sProxyHost, nProxyPort, sProxyUserLogin, sProxyUserPasswd, nProblemSendTimeout, nReserved) unregister remote device(self, device type) Unregister a remote device. send remote command(self, hVm, hCommand) get remote command target(self, hCommand) get remote command index(self, hCommand) 10

Description:
register3rd party vm(self, strVmConfigPath, strVmRootDirPath, nFlags) create vm(self ). Create a new instaince of the Vm class. Return Value.
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.