3.5.13.1 Java

The WsDevClient class contains an example of the creation of a virtual machine:

Vm testVm = new Vm();
testVm.setVmDomainType(VmDomainType.XEN_HVM);
testVm.setName(testVmName);
testVm.setRepositoryId(testRepoId);

final Job vmCreateJob = api.vmCreate(testVm, testPoolId);
System.out.println("create vm job id: " + vmCreateJob.getId());
testVmId = waitForJobComplete(api, vmCreateJob, Vm.class); 

In this 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 hardware virtualization with its configuration located on the repository defined in the WsDevClient.properties file.

The vmCreate method also requires the server pool ID to be provided so that the virtual machine is created within the correct server pool.

The WsDevClient class goes on to demonstrate many other actions that can be performed on a virtual machine via the SOAP API including removing and restoring server pool association, basic modifications of attributes, assigning VNICs and killing a virtual machine. It is recommended that the reader explore these examples and how they relate to methods within the OvmWsSoapClient class to understand how to expand any interactions with virtual machines through the SOAP API.