/** Create a new virtual network adapter on the VM * Your MAC address should start with 00:50:56 */ public void createNetworkAdapter(VirtualNetworkAdapterType type, String networkName, String macAddress, boolean wakeOnLan, boolean startConnected) throws InvalidProperty, RuntimeFault, RemoteException, InterruptedException { VirtualMachinePowerState powerState = vm.getRuntime().getPowerState(); String vmVerStr = vm.getConfig().getVersion(); int vmVer = Integer.parseInt(vmVerStr.substring(vmVerStr.length()-2)); if((powerState == VirtualMachinePowerState.suspended) || (powerState == VirtualMachinePowerState.suspended && vmVer < 7)) { throw new InvalidPowerState(); } HostSystem host = new HostSystem(vm.getServerConnection(), vm.getRuntime().getHost()); ComputeResource cr = (ComputeResource) host.getParent(); EnvironmentBrowser envBrowser = cr.getEnvironmentBrowser(); ConfigTarget configTarget = envBrowser.queryConfigTarget(host); VirtualMachineConfigOption vmCfgOpt = envBrowser.queryConfigOption(null, host); type = validateNicType(vmCfgOpt.getGuestOSDescriptor(), vm.getConfig().getGuestId(), type); VirtualDeviceConfigSpec nicSpec = createNicSpec(type, networkName, macAddress, wakeOnLan, startConnected, configTarget); VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec(); vmConfigSpec.setDeviceChange(new VirtualDeviceConfigSpec []{nicSpec}); Task task = vm.reconfigVM_Task(vmConfigSpec); task.waitForTask(200, 100); }
/** * Create an instance of {@link JAXBElement }{@code <}{@link InvalidPowerState }{@code >}} * */ @XmlElementDecl(namespace = "urn:pbm", name = "InvalidPowerStateFault") public JAXBElement<InvalidPowerState> createInvalidPowerStateFault(InvalidPowerState value) { return new JAXBElement<InvalidPowerState>(_InvalidPowerStateFault_QNAME, InvalidPowerState.class, null, value); }
public HttpNfcLease exportVApp() throws InvalidPowerState, TaskInProgress, InvalidState, FileFault, RuntimeFault, RemoteException { ManagedObjectReference mor = getVimService().exportVApp(getMOR()); return new HttpNfcLease(getServerConnection(), mor); }