本文整理汇总了Java中com.vmware.vim25.VirtualMachinePowerState类的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachinePowerState类的具体用法?Java VirtualMachinePowerState怎么用?Java VirtualMachinePowerState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VirtualMachinePowerState类属于com.vmware.vim25包,在下文中一共展示了VirtualMachinePowerState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convertPowerState
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
public static PowerState convertPowerState(VirtualMachinePowerState state) {
if (state == null) {
return null;
}
switch (state) {
case POWERED_OFF:
return PowerState.OFF;
case POWERED_ON:
return PowerState.ON;
case SUSPENDED:
return PowerState.SUSPEND;
default:
return PowerState.UNKNOWN;
}
}
开发者ID:vmware,项目名称:photon-model,代码行数:17,代码来源:VSphereToPhotonMapping.java
示例2: resumeNode
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
@Override
public void resumeNode(String vmName) {
VirtualMachine virtualMachine = getNode(vmName);
if (virtualMachine.getRuntime().getPowerState().equals(VirtualMachinePowerState.poweredOff)) {
try {
Task task = virtualMachine.powerOnVM_Task(null);
if (task.waitForTask().equals(Task.SUCCESS))
logger.debug(virtualMachine.getName() + " resumed");
} catch (Exception e) {
logger.error("Can't resume vm " + vmName, e);
propagate(e);
}
} else
logger.debug(vmName + " can't be resumed");
}
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:18,代码来源:VSphereComputeServiceAdapter.java
示例3: waitForStopped
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
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;
}
}
}
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:18,代码来源:VmwareProcessClient.java
示例4: getVMPowerState
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
@GET
@Path("/powerstate/{vmname}")
public String getVMPowerState(@PathParam("vmname") String vmName) throws VMWareException {
Configuration conf = Configuration.getInstance();
VMWareHelper helper = VMWareHelper.getInstance(conf.getUserName(), conf.getPassword(), conf.getUrl());
VirtualMachinePowerState state = helper.getPowerState(vmName);
if (state == null) {
return null;
// throw new VMWareException("Name of VM " + vmName + " not found!");
}
return state.name();
}
开发者ID:awin,项目名称:viAutomator,代码行数:17,代码来源:VMWareService.java
示例5: isStopped
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
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;
}
开发者ID:servicecatalog,项目名称:oscm,代码行数:14,代码来源:VM.java
示例6: migrateVM
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
private static boolean migrateVM(ServiceInstance si, Folder rootFolder,
HostSystem newHost, String targetVMName, String newHostName)
throws Exception {
log("Selected host [vm] for vMotion: " + newHostName + " [" + targetVMName
+ "]");
VirtualMachine vm = (VirtualMachine)new InventoryNavigator(rootFolder)
.searchManagedEntity("VirtualMachine", targetVMName);
if (vm == null) {
log(WARNING, "Could not resolve VM " + targetVMName + ", vMotion of this VM cannot be performed.");
return false;
}
ComputeResource cr = (ComputeResource)newHost.getParent();
String[] checks = new String[] { "cpu", "software" };
HostVMotionCompatibility[] vmcs = si.queryVMotionCompatibility(vm,
new HostSystem[] { newHost }, checks);
String[] comps = vmcs[0].getCompatibility();
if (checks.length != comps.length) {
log(WARNING, "CPU/software NOT compatible, vMotion failed.");
return false;
}
long start = System.currentTimeMillis();
Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost,
VirtualMachineMovePriority.highPriority,
VirtualMachinePowerState.poweredOn);
if (task.waitForMe() == Task.SUCCESS) {
long end = System.currentTimeMillis();
log("vMotion of " + targetVMName + " to " + newHostName
+ " completed in " + (end - start) + "ms. Task result: "
+ task.getTaskInfo().getResult());
return true;
} else {
TaskInfo info = task.getTaskInfo();
log(WARNING, "vMotion of " + targetVMName + " to " + newHostName
+ " failed. Error details: " + info.getError().getFault());
return false;
}
}
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:43,代码来源:VMotionTrigger.java
示例7: softPowerOff
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
private void softPowerOff(ManagedObjectReference vm, long politenessDeadlineMicros)
throws Exception {
try {
getVimPort().shutdownGuest(vm);
} catch (ToolsUnavailableFaultMsg e) {
// no vmtoools present, try harder
hardPowerOff(vm);
return;
}
// wait for guest to shutdown
WaitForValues wait = new WaitForValues(this.connection);
int timeout = (int) TimeUnit.MICROSECONDS
.toSeconds(politenessDeadlineMicros - Utils.getNowMicrosUtc());
if (timeout <= 0) {
// maybe try anyway?
return;
}
Object[] currentPowerState = wait.wait(vm,
new String[] { VimPath.vm_runtime_powerState },
new String[] { VimPath.vm_runtime_powerState },
new Object[][] {
new Object[] {
VirtualMachinePowerState.POWERED_OFF
}
}, timeout);
if (currentPowerState == null
|| currentPowerState[0] != VirtualMachinePowerState.POWERED_OFF) {
// vm not shutdown on time
hardPowerOff(vm);
}
}
开发者ID:vmware,项目名称:photon-model,代码行数:37,代码来源:PowerStateClient.java
示例8: apply
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
@Override
public SshClient apply(final VirtualMachine vm) {
SshClient client = null;
String clientIpAddress = vm.getGuest().getIpAddress();
String sshPort = "22";
while (!vm.getGuest().getToolsStatus().equals(VirtualMachineToolsStatus.toolsOk) || clientIpAddress.isEmpty()) {
int timeoutValue = 1000;
int timeoutUnits = 500;
Predicate<String> tester = Predicates2.retry(
ipAddressTester, timeoutValue, timeoutUnits,
TimeUnit.MILLISECONDS);
boolean passed = false;
while (vm.getRuntime().getPowerState()
.equals(VirtualMachinePowerState.poweredOn)
&& !passed) {
clientIpAddress = Strings.nullToEmpty(vm.getGuest()
.getIpAddress());
passed = tester.apply(clientIpAddress);
}
}
LoginCredentials loginCredentials = LoginCredentials.builder()
.user("root").password(password)
.build();
checkNotNull(clientIpAddress, "clientIpAddress");
client = sshClientFactory.create(
HostAndPort.fromParts(clientIpAddress, Integer.parseInt(sshPort)),
loginCredentials);
checkNotNull(client);
return client;
}
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:31,代码来源:VirtualMachineToSshClient.java
示例9: VirtualMachineToNodeMetadata
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
@Inject
public VirtualMachineToNodeMetadata(Map<VirtualMachinePowerState, NodeMetadata.Status> toPortableNodeStatus,
Supplier<Map<String, CustomFieldDef>> customFields,
Supplier<VSphereServiceInstance> serviceInstanceSupplier,
Function<String, DistributedVirtualPortgroup> distributedVirtualPortgroupFunction,
@Named(VSphereConstants.JCLOUDS_VSPHERE_VM_PASSWORD) String vmInitPassword) {
this.toPortableNodeStatus = checkNotNull(toPortableNodeStatus, "PortableNodeStatus");
this.customFields = checkNotNull(customFields, "customFields");
this.serviceInstanceSupplier = checkNotNull(serviceInstanceSupplier, "serviceInstanceSupplier");
this.distributedVirtualPortgroupFunction = checkNotNull(distributedVirtualPortgroupFunction, "distributedVirtualPortgroupFunction");
this.vmInitPassword = vmInitPassword;
}
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:13,代码来源:VirtualMachineToNodeMetadata.java
示例10: shutdownGuest
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
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));
}
}
开发者ID:primecloud-controller-org,项目名称:primecloud-controller,代码行数:29,代码来源:VmwareProcessClient.java
示例11: VirtualMachineInfo
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
public VirtualMachineInfo(String uuid, String name, String hostName, String vrouterIpAddress,
VirtualMachinePowerState powerState)
{
this.uuid = uuid;
this.name = name;
this.displayName = name;
this.hostName = hostName;
this.vrouterIpAddress = vrouterIpAddress;
this.powerState = powerState;
}
开发者ID:Juniper,项目名称:contrail-vcenter-plugin,代码行数:11,代码来源:VirtualMachineInfo.java
示例12: setContrailVmActiveState
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
private void setContrailVmActiveState() {
if (name.toLowerCase().contains(contrailVRouterVmNamePrefix.toLowerCase())) {
// this is a Contrail VM
if (!powerState.equals(VirtualMachinePowerState.poweredOn)) {
VRouterNotifier.setVrouterActive(vrouterIpAddress, false);
} else if (host != null) {
if (host.getRuntime().isInMaintenanceMode()) {
VRouterNotifier.setVrouterActive(vrouterIpAddress, false);
} else {
VRouterNotifier.setVrouterActive(vrouterIpAddress, true);
}
}
}
}
开发者ID:Juniper,项目名称:contrail-vcenter-plugin,代码行数:15,代码来源:VirtualMachineInfo.java
示例13: createNetworkAdapter
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的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);
}
开发者ID:Juniper,项目名称:vijava,代码行数:32,代码来源:VirtualMachineDeviceManager.java
示例14: checkMigrate_Task
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
public Task checkMigrate_Task(VirtualMachine vm, HostSystem host, ResourcePool pool, VirtualMachinePowerState state, String[] testType) throws NoActiveHostInCluster, InvalidState, RuntimeFault, RemoteException
{
ManagedObjectReference taskMor = getVimService().checkMigrate_Task(getMOR(),
vm.getMOR(),
host==null?null : host.getMOR(),
pool==null?null : pool.getMOR(), state, testType);
return new Task(getServerConnection(), taskMor);
}
开发者ID:Juniper,项目名称:vijava,代码行数:9,代码来源:VirtualMachineProvisioningChecker.java
示例15: powerOffNoCheck
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
private boolean powerOffNoCheck() throws Exception {
ManagedObjectReference morTask = _context.getService().powerOffVMTask(_mor);
boolean result = _context.getVimClient().waitForTask(morTask);
if (result) {
_context.waitForTaskProgressDone(morTask);
// It seems that even if a power-off task is returned done, VM state may still not be marked,
// wait up to 5 seconds to make sure to avoid race conditioning for immediate following on operations
// that relies on a powered-off VM
long startTick = System.currentTimeMillis();
while (getResetSafePowerState() != VirtualMachinePowerState.POWERED_OFF && System.currentTimeMillis() - startTick < 5000) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
s_logger.debug("[ignored] interupted while powering of vm unconditionaly.");
}
}
return true;
} else {
if (getResetSafePowerState() == VirtualMachinePowerState.POWERED_OFF) {
// to help deal with possible race-condition
s_logger.info("Current power-off task failed. However, VM has been switched to the state we are expecting for");
return true;
}
s_logger.error("VMware powerOffVM_Task failed due to " + TaskMO.getTaskFailureInfo(_context, morTask));
}
return false;
}
开发者ID:apache,项目名称:cloudstack,代码行数:32,代码来源:VirtualMachineMO.java
示例16: getPowerState
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
public PowerState getPowerState() {
return VSphereToPhotonMapping.convertPowerState(
(VirtualMachinePowerState) getOrFail(VimPath.vm_runtime_powerState));
}
开发者ID:vmware,项目名称:photon-model,代码行数:5,代码来源:VmOverlay.java
示例17: getPowerState
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
public PowerState getPowerState(ManagedObjectReference vm) throws InvalidPropertyFaultMsg,
RuntimeFaultFaultMsg {
VirtualMachinePowerState vmps = this.get.entityProp(vm, VimPath.vm_runtime_powerState);
return VSphereToPhotonMapping.convertPowerState(vmps);
}
开发者ID:vmware,项目名称:photon-model,代码行数:6,代码来源:PowerStateClient.java
示例18: toPortableNodeStatus
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
@Singleton
@Provides
protected Map<VirtualMachinePowerState, NodeMetadata.Status> toPortableNodeStatus() {
return toPortableNodeStatus;
}
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:6,代码来源:VSphereComputeServiceContextModule.java
示例19: toPortableImageStatus
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
@Singleton
@Provides
protected Map<VirtualMachinePowerState, Image.Status> toPortableImageStatus() {
return toPortableImageStatus;
}
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:6,代码来源:VSphereComputeServiceContextModule.java
示例20: VirtualMachineToImage
import com.vmware.vim25.VirtualMachinePowerState; //导入依赖的package包/类
@Inject
public VirtualMachineToImage(Map<VirtualMachinePowerState, Status> toPortableImageStatus, Map<OsFamily, Map<String, String>> osVersionMap) {
this.toPortableImageStatus = checkNotNull(toPortableImageStatus, "toPortableImageStatus");
this.osVersionMap = checkNotNull(osVersionMap, "osVersionMap");
}
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:6,代码来源:VirtualMachineToImage.java
注:本文中的com.vmware.vim25.VirtualMachinePowerState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论