// initialize the system, set up web services
ServiceInstance si = new ServiceInstance(url, username, password, true);
// create a new VirtualMachineConfigSpec for VM1
VirtualMachineConfigSpec vmcs1 = new VirtualMachineConfigSpec();
ResourceAllocationInfo rai1 = new ResourceAllocationInfo();
SharesInfo si1 = new SharesInfo();
si1.setLevel(SharesLevel.custom);
si1.setShares(1333);
rai1.setShares(si1);
vmcs1.setCpuAllocation(rai1);
// do the same for VM2
VirtualMachineConfigSpec vmcs2 = new VirtualMachineConfigSpec();
ResourceAllocationInfo rai2 = new ResourceAllocationInfo();
SharesInfo si2 = new SharesInfo();
si2.setLevel(SharesLevel.high);
rai2.setShares(si2);
vmcs2.setCpuAllocation(rai2);
ManagedObjectReference vm1_mor = createMOR("VirtualMachine", vm1_oid);
ManagedObjectReference vm2_mor = createMOR("VirtualMachine", vm2_oid);
VirtualMachine vm1 = (VirtualMachine) MorUtil.createExactManagedEntity(si.getServerConnection(), vm1_mor);