本文整理汇总了Java中com.vmware.vim25.mo.EnvironmentBrowser类的典型用法代码示例。如果您正苦于以下问题:Java EnvironmentBrowser类的具体用法?Java EnvironmentBrowser怎么用?Java EnvironmentBrowser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EnvironmentBrowser类属于com.vmware.vim25.mo包,在下文中一共展示了EnvironmentBrowser类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDVPortgroupInfo
import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的package包/类
public DistributedVirtualPortgroupInfo getDVPortgroupInfo(VirtualMachine machine, String networkName) {
HostSystem host = new HostSystem(machine.getServerConnection(), machine.getRuntime().getHost());
ComputeResource computeResource = (ComputeResource) host.getParent();
EnvironmentBrowser envBrowser = computeResource.getEnvironmentBrowser();
DistributedVirtualPortgroupInfo dvPortgroupInfo = null;
try {
ConfigTarget configTarget = envBrowser.queryConfigTarget(host);
// 分散ポートグループの場合
if (configTarget.getDistributedVirtualPortgroup() != null) {
// 分散ポートグループ情報を取得
dvPortgroupInfo = findDVPortgroupInfo(configTarget.getDistributedVirtualPortgroup(), networkName);
}
} catch (RemoteException e) {
throw new RuntimeException(e);
}
return dvPortgroupInfo;
}
示例2: getValidCdromOnHost
import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的package包/类
private List<String> getValidCdromOnHost() throws InvalidProperty, RuntimeFault, RemoteException
{
List<String> result = new ArrayList<String>();
EnvironmentBrowser envBrower = vm.getEnvironmentBrowser();
ConfigTarget configTarget;
try
{
configTarget = envBrower.queryConfigTarget(null);
}
catch (Exception ex)
{
throw new RuntimeException("Error in getting Cdrom devices from host.");
}
if(configTarget != null && configTarget.cdRom != null)
{
for(VirtualMachineCdromInfo cdromInfo : configTarget.cdRom)
{
result.add(cdromInfo.name);
}
}
return result;
}
示例3: doesNetworkNameExist
import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的package包/类
static boolean doesNetworkNameExist(VirtualMachine vm,
String netName) throws Exception
{
VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser();
ManagedObjectReference hmor = vmRuntimeInfo.getHost();
HostSystem host = new HostSystem(
vm.getServerConnection(), hmor);
ConfigTarget cfg = envBrowser.queryConfigTarget(host);
VirtualMachineNetworkInfo[] nets = cfg.getNetwork();
for (int i = 0; nets!=null && i < nets.length; i++)
{
NetworkSummary netSummary = nets[i].getNetwork();
if (netSummary.isAccessible() &&
netSummary.getName().equalsIgnoreCase(netName))
{
return true;
}
}
return false;
}
示例4: findDatastoreSummary
import com.vmware.vim25.mo.EnvironmentBrowser; //导入依赖的package包/类
static DatastoreSummary findDatastoreSummary(VirtualMachine vm, String dsName) throws Exception
{
DatastoreSummary dsSum = null;
VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime();
EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser();
ManagedObjectReference hmor = vmRuntimeInfo.getHost();
if(hmor == null)
{
System.out.println("No Datastore found");
return null;
}
ConfigTarget configTarget = envBrowser.queryConfigTarget(new HostSystem(vm.getServerConnection(), hmor));
VirtualMachineDatastoreInfo[] dis = configTarget.getDatastore();
for (int i=0; dis!=null && i<dis.length; i++)
{
dsSum = dis[i].getDatastore();
if (dsSum.isAccessible() && dsName.equals(dsSum.getName()))
{
break;
}
}
return dsSum;
}
示例5: 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;
}
示例6: 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);
}