com.vmware.vim25.VirtualMachineRuntimeInfo Java Examples
The following examples show how to use
com.vmware.vim25.VirtualMachineRuntimeInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VmwareProcessClient.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
public void waitForStopped(String machineName) { VirtualMachine machine = getVirtualMachine(machineName); // 停止判定処理 while (true) { try { Thread.sleep(30 * 1000L); } catch (InterruptedException ignore) { } VirtualMachineRuntimeInfo runtimeInfo = machine.getRuntime(); if (runtimeInfo.getPowerState() == VirtualMachinePowerState.poweredOff) { break; } } }
Example #2
Source File: VMwareGuru.java From cloudstack with Apache License 2.0 | 6 votes |
@Override public VirtualMachine importVirtualMachineFromBackup(long zoneId, long domainId, long accountId, long userId, String vmInternalName, Backup backup) throws Exception { DatacenterMO dcMo = getDatacenterMO(zoneId); VirtualMachineMO vmToImport = dcMo.findVm(vmInternalName); if (vmToImport == null) { throw new CloudRuntimeException("Error finding VM: " + vmInternalName); } VirtualMachineConfigSummary configSummary = vmToImport.getConfigSummary(); VirtualMachineRuntimeInfo runtimeInfo = vmToImport.getRuntimeInfo(); List<VirtualDisk> virtualDisks = vmToImport.getVirtualDisks(); String[] vmNetworkNames = vmToImport.getNetworks(); VirtualDevice[] nicDevices = vmToImport.getNicDevices(); Map<VirtualDisk, VolumeVO> disksMapping = getDisksMapping(backup, virtualDisks); Map<String, NetworkVO> networksMapping = getNetworksMapping(vmNetworkNames, accountId, zoneId, domainId); long guestOsId = getImportingVMGuestOs(configSummary); long serviceOfferingId = getImportingVMServiceOffering(configSummary, runtimeInfo); long templateId = getImportingVMTemplate(virtualDisks, dcMo, vmInternalName, guestOsId, accountId, disksMapping, backup); VMInstanceVO vm = getVM(vmInternalName, templateId, guestOsId, serviceOfferingId, zoneId, accountId, userId, domainId); syncVMVolumes(vm, virtualDisks, disksMapping, vmToImport, backup); syncVMNics(nicDevices, dcMo, networksMapping, vm); return vm; }
Example #3
Source File: NetworkManager.java From development with Apache License 2.0 | 5 votes |
private static ManagedObjectReference getNetworkFromHost(VMwareClient vmw, ManagedObjectReference vmwInstance, String networkName) throws Exception { logger.debug("networkName: " + networkName); VirtualMachineRuntimeInfo vmRuntimeInfo = (VirtualMachineRuntimeInfo) vmw .getServiceUtil().getDynamicProperty(vmwInstance, "runtime"); ManagedObjectReference hostRef = vmRuntimeInfo.getHost(); List<ManagedObjectReference> networkRefList = (List<ManagedObjectReference>) vmw .getServiceUtil().getDynamicProperty(hostRef, "network"); ManagedObjectReference netCard = null; StringBuffer networks = new StringBuffer(); for (ManagedObjectReference networkRef : networkRefList) { String netCardName = (String) vmw.getServiceUtil() .getDynamicProperty(networkRef, "name"); networks.append(netCardName + " "); if (netCardName.equalsIgnoreCase(networkName)) { netCard = networkRef; break; } } if (netCard == null) { String hostName = (String) vmw.getServiceUtil() .getDynamicProperty(hostRef, "name"); logger.error("Network " + networkName + " not found on host " + hostName); logger.debug("available networks are: " + networks.toString()); throw new Exception("Network card " + networkName + " not found on host " + hostName); } return netCard; }
Example #4
Source File: VM.java From development with Apache License 2.0 | 5 votes |
public boolean isStopped() throws Exception { VirtualMachineRuntimeInfo vmRuntimeInfo = (VirtualMachineRuntimeInfo) vmw .getServiceUtil().getDynamicProperty(vmInstance, "runtime"); if (vmRuntimeInfo != null) { return VirtualMachinePowerState.POWERED_OFF .equals(vmRuntimeInfo.getPowerState()); } LOG.warn("Failed to retrieve runtime information from VM " + instanceName); return false; }
Example #5
Source File: VmwareProcessClient.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
public void shutdownGuest(String machineName) { // VirtualMachine VirtualMachine machine = getVirtualMachine(machineName); // パワーオフ状態の場合はスキップ VirtualMachineRuntimeInfo runtimeInfo = machine.getRuntime(); if (runtimeInfo.getPowerState() == VirtualMachinePowerState.poweredOff) { return; } // 仮想マシンのシャットダウン try { machine.shutdownGuest(); } catch (RemoteException e) { throw new AutoException("EPROCESS-000519", e, machineName); } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100415", machineName)); } // シャットダウンが完了するまで待機 waitForStopped(machineName); if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100416", machineName)); } }
Example #6
Source File: VMwareGuru.java From cloudstack with Apache License 2.0 | 5 votes |
/** * Get service offering ID for VM being imported. * If it cannot be found it creates one and returns its ID */ private Long getImportingVMServiceOffering(VirtualMachineConfigSummary configSummary, VirtualMachineRuntimeInfo runtimeInfo) { Integer numCpu = configSummary.getNumCpu(); Integer memorySizeMB = configSummary.getMemorySizeMB(); Integer maxCpuUsage = runtimeInfo.getMaxCpuUsage(); List<ServiceOfferingVO> offerings = serviceOfferingDao.listPublicByCpuAndMemory(numCpu, memorySizeMB); return CollectionUtils.isEmpty(offerings) ? createServiceOfferingForVMImporting(numCpu, memorySizeMB, maxCpuUsage).getId() : offerings.get(0).getId(); }
Example #7
Source File: VirtualMachineMO.java From cloudstack with Apache License 2.0 | 4 votes |
public HostMO getRunningHost() throws Exception { VirtualMachineRuntimeInfo runtimeInfo = getRuntimeInfo(); return new HostMO(_context, runtimeInfo.getHost()); }
Example #8
Source File: VirtualMachineMO.java From cloudstack with Apache License 2.0 | 4 votes |
public VirtualMachineRuntimeInfo getRuntimeInfo() throws Exception { return (VirtualMachineRuntimeInfo)_context.getVimClient().getDynamicProperty(_mor, "runtime"); }