3.5.13.2 Python

In the following code, some basic attributes of the virtual machine are set before it is created. In fact, there are a large number of attributes specific to a virtual machine that can be set to control how the virtual machine is configured. Here the most basic attributes have been selected to create a virtual machine using Xen para-virtualization with its configuration located on the repository called 'MyRepository'. The virtual machine is also attached to the server pool called 'MyServerPool'.

In the following example, we assume that many of the ID objects required to create a virtual machine have already been set based on the code used in the previous examples. If you need to populate these objects beforehand, refer to the example provided in Obtaining the Server Pool ID Value.

vm=client.factory.create('vm')
vm.name="MySOAPVm"
vm.repositoryId=repo_id
vm.vmDomainType='XEN_PVM'
job=client.service.vmCreate(vm,svrpool_id)
vm_id=wait_for_job(client,job.id)