本文整理汇总了Java中com.vmware.vim25.VirtualMachineSummary类的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachineSummary类的具体用法?Java VirtualMachineSummary怎么用?Java VirtualMachineSummary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VirtualMachineSummary类属于com.vmware.vim25包,在下文中一共展示了VirtualMachineSummary类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDataToVmDetailsMap
import com.vmware.vim25.VirtualMachineSummary; //导入依赖的package包/类
public static void addDataToVmDetailsMap(Map<String, String> inputMap,
VirtualMachineSummary virtualMachineSummary,
VirtualMachineConfigSummary virtualMachineConfigSummary) {
inputMap.put(ManagedObjectType.VM_ID.getValue(), virtualMachineSummary.getVm().getValue());
inputMap.put(ManagedObjectType.VM_FULL_NAME.getValue(), virtualMachineConfigSummary.getGuestFullName());
inputMap.put(ManagedObjectType.VM_UUID.getValue(), virtualMachineConfigSummary.getUuid());
inputMap.put(Inputs.VM_CPU_COUNT, virtualMachineConfigSummary.getNumCpu().toString());
inputMap.put(Inputs.VM_MEMORY_SIZE, virtualMachineConfigSummary.getMemorySizeMB().toString());
inputMap.put(ManagedObjectType.VM_ETH_COUNT.getValue(), virtualMachineConfigSummary.getNumEthernetCards().toString());
inputMap.put(ManagedObjectType.VM_DISK_COUNT.getValue(), virtualMachineConfigSummary.getNumVirtualDisks().toString());
inputMap.put(Inputs.DATA_STORE, virtualMachineConfigSummary.getVmPathName()
.substring(1, virtualMachineConfigSummary.getVmPathName().indexOf(Constants.RIGHT_SQUARE_BRACKET)));
inputMap.put(ManagedObjectType.VM_PATH_NAME.getValue(), virtualMachineConfigSummary.getVmPathName());
inputMap.put(ManagedObjectType.VM_IS_TEMPLATE.getValue(), Boolean.toString(virtualMachineConfigSummary.isTemplate()));
if (virtualMachineSummary.getGuest() != null) {
if (virtualMachineSummary.getGuest().getIpAddress() != null) {
inputMap.put(ManagedObjectType.VM_IP_ADDRESS.getValue(), virtualMachineSummary.getGuest().getIpAddress());
} else {
inputMap.put(ManagedObjectType.VM_IP_ADDRESS.getValue(), Constants.EMPTY);
}
}
}
示例2: getMorHost
import com.vmware.vim25.VirtualMachineSummary; //导入依赖的package包/类
public ManagedObjectReference getMorHost(String hostname, ConnectionResources connectionResources,
ManagedObjectReference vmMor) throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
ManagedObjectReference host = null;
if (isNotBlank(hostname)) {
host = getManagedObjectReference(hostname, connectionResources,
ManagedObjectType.HOST_SYSTEM.getValue(), ErrorMessages.HOST_NOT_FOUND);
} else if (StringUtils.isBlank(hostname) && vmMor != null) {
ObjectContent[] objectContents = GetObjectProperties.getObjectProperties(connectionResources, vmMor,
new String[]{ManagedObjectType.SUMMARY.getValue()});
for (ObjectContent objectItem : objectContents) {
List<DynamicProperty> vmProperties = objectItem.getPropSet();
for (DynamicProperty propertyItem : vmProperties) {
VirtualMachineSummary virtualMachineSummary = (VirtualMachineSummary) propertyItem.getVal();
host = virtualMachineSummary.getRuntime().getHost();
break;
}
break;
}
} else {
host = connectionResources.getHostMor();
}
return host;
}
示例3: getMorDataStore
import com.vmware.vim25.VirtualMachineSummary; //导入依赖的package包/类
public ManagedObjectReference getMorDataStore(String dataStoreName, ConnectionResources connectionResources,
ManagedObjectReference vmMor, VmInputs vmInputs)
throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg {
ManagedObjectReference dataStore = null;
if (isNotBlank(dataStoreName)) {
ManagedObjectReference cloneHostMor = getMorHost(vmInputs.getCloneHost(), connectionResources, vmMor);
ConfigTarget configTarget = getHostConfigTarget(connectionResources, cloneHostMor);
List<VirtualMachineDatastoreInfo> dataStoreInfoList = configTarget.getDatastore();
for (VirtualMachineDatastoreInfo dataStoreInfo : dataStoreInfoList) {
if (vmInputs.getCloneDataStore().equals(dataStoreInfo.getDatastore().getName())) {
dataStore = getDataStoreRef(vmInputs.getCloneDataStore(), dataStoreInfoList);
break;
}
}
if (dataStore == null) {
throw new RuntimeException(ErrorMessages.DATA_STORE_NOT_FOUND);
}
} else {
ObjectContent[] objectContents = GetObjectProperties.getObjectProperties(connectionResources, vmMor,
new String[]{ManagedObjectType.SUMMARY.getValue()});
for (ObjectContent objectItem : objectContents) {
List<DynamicProperty> vmProperties = objectItem.getPropSet();
for (DynamicProperty propertyItem : vmProperties) {
VirtualMachineSummary virtualMachineSummary = (VirtualMachineSummary) propertyItem.getVal();
String vmPathName = virtualMachineSummary.getConfig().getVmPathName();
dataStoreName = vmPathName.substring(1, vmPathName.indexOf(Constants.RIGHT_SQUARE_BRACKET));
dataStore = getDataStore(dataStoreName, connectionResources, vmMor);
break;
}
break;
}
}
return dataStore;
}
示例4: getVMDetails
import com.vmware.vim25.VirtualMachineSummary; //导入依赖的package包/类
/**
* Method used to connect to data center to retrieve details of a virtual machine identified by the inputs provided.
*
* @param httpInputs Object that has all the inputs necessary to made a connection to data center
* @param vmInputs Object that has all the specific inputs necessary to identify the targeted virtual machine
* @return Map with String as key and value that contains returnCode of the operation, a JSON formatted string that
* contains details of the virtual machine or failure message and the exception if there is one
* @throws Exception
*/
public Map<String, String> getVMDetails(HttpInputs httpInputs, VmInputs vmInputs) throws Exception {
ConnectionResources connectionResources = new ConnectionResources(httpInputs, vmInputs);
try {
ManagedObjectReference vmMor = new MorObjectHandler().getMor(connectionResources,
ManagedObjectType.VIRTUAL_MACHINE.getValue(), vmInputs.getVirtualMachineName());
ObjectContent[] objectContents = GetObjectProperties.getObjectProperties(connectionResources, vmMor,
new String[]{ManagedObjectType.SUMMARY.getValue()});
if (objectContents != null) {
Map<String, String> vmDetails = new HashMap<>();
for (ObjectContent objectItem : objectContents) {
List<DynamicProperty> vmProperties = objectItem.getPropSet();
for (DynamicProperty propertyItem : vmProperties) {
VirtualMachineSummary virtualMachineSummary = (VirtualMachineSummary) propertyItem.getVal();
VirtualMachineConfigSummary virtualMachineConfigSummary = virtualMachineSummary.getConfig();
ResponseUtils.addDataToVmDetailsMap(vmDetails, virtualMachineSummary, virtualMachineConfigSummary);
}
}
String responseJson = ResponseUtils.getJsonString(vmDetails);
return ResponseUtils.getResultsMap(responseJson, Outputs.RETURN_CODE_SUCCESS);
} else {
return ResponseUtils.getResultsMap("Could not retrieve the details for: [" +
vmInputs.getVirtualMachineName() + "] VM.", Outputs.RETURN_CODE_FAILURE);
}
} catch (Exception ex) {
return ResponseUtils.getResultsMap(ex.toString(), Outputs.RETURN_CODE_FAILURE);
} finally {
if (httpInputs.isCloseSession()) {
connectionResources.getConnection().disconnect();
clearConnectionFromContext(httpInputs.getGlobalSessionObject());
}
}
}