Compared to the Parallels C API, a Python class is an equivalent of a C handle. A class must be instantiated (or a reference to it must be obtained) before it can be used in your program. In the Parallels Python API, a class is instantiated either the standard Python way (calling the class as a function) or by using a method of another class. A reference to an object that already exists in memory is obtained using a method or a property of another class. The examples in this guide provide information on how to obtain the most important and commonly used objects (host, virtual machine, devices, etc.).
The following sample illustrates how to create an object of class
prlsdkapi.Server. Here, we simply instantiate the
Server class as it is normally done in Python.
server = prlsdkapi.Server()
In the following example, we create an object of class
prlsdkapi.Vm (the virtual machine class). Please note that in this case, we have to obtain the object reference from the
server object (an instance of class
prlsdkapi.Server). This is necessary for the server object to become aware of a new virtual machine object.
vm = server.create_vm()
Please send us your feedback on this help page