本文整理匯總了Java中com.vmware.vim25.mo.EnvironmentBrowser.queryConfigOption方法的典型用法代碼示例。如果您正苦於以下問題:Java EnvironmentBrowser.queryConfigOption方法的具體用法?Java EnvironmentBrowser.queryConfigOption怎麽用?Java EnvironmentBrowser.queryConfigOption使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.vmware.vim25.mo.EnvironmentBrowser
的用法示例。
在下文中一共展示了EnvironmentBrowser.queryConfigOption方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDefaultDevices
import com.vmware.vim25.mo.EnvironmentBrowser; //導入方法依賴的package包/類
static VirtualDevice[] getDefaultDevices(VirtualMachine vm)
throws Exception
{
VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser();
ManagedObjectReference hmor = vmRuntimeInfo.getHost();
VirtualMachineConfigOption cfgOpt = envBrowser.queryConfigOption(null, new HostSystem(vm.getServerConnection(), hmor));
VirtualDevice[] defaultDevs = null;
if (cfgOpt != null)
{
defaultDevs = cfgOpt.getDefaultDevice();
if (defaultDevs == null)
{
throw new Exception("No Datastore found in ComputeResource");
}
}
else
{
throw new Exception("No VirtualHardwareInfo found in ComputeResource");
}
return defaultDevs;
}
示例2: createNetworkAdapter
import com.vmware.vim25.mo.EnvironmentBrowser; //導入方法依賴的package包/類
/** 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);
}