public HostSystem[] getHosts() { return getHosts("host"); }
public ComputeResourceSummary getSummary() { return (ComputeResourceSummary) this.getCurrentProperty("summary"); }
public Datastore[] getDatastores() { return getDatastores("datastore"); }
public Task reconfigureComputeResource_Task(ComputeResourceConfigSpec spec, boolean modify) throws RuntimeFault, RemoteException { ManagedObjectReference taskMOR = getVimService().reconfigureComputeResource_Task(getMOR(), spec, modify); return new Task(getServerConnection(), taskMOR); }
Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost, VirtualMachineMovePriority.highPriority, VirtualMachinePowerState.poweredOn);
private static DistributedVirtualPortgroupInfo getDvPortGroupInfo(VirtualMachine vm, String dvPort) throws Exception{ HostSystem host = new HostSystem(vm.getServerConnection(), vm.getRuntime().getHost()); ComputeResource cr = (ComputeResource) host.getParent(); EnvironmentBrowser envBrowser = cr.getEnvironmentBrowser(); ConfigTarget configTarget = envBrowser.queryConfigTarget(host); DistributedVirtualPortgroupInfo dvPortgroupInfo = null; DistributedVirtualPortgroupInfo[] availableDvPortGroupInfo = configTarget.getDistributedVirtualPortgroup(); int j = 0; while (j < availableDvPortGroupInfo.length && dvPortgroupInfo == null) { dvPortgroupInfo = (availableDvPortGroupInfo[j].portgroupName.equalsIgnoreCase(dvPort)) ? availableDvPortGroupInfo[j] : null; j++; } if (dvPortgroupInfo == null) { throw new Exception("Impossible to find dvPortGroupInfo with name : " + dvPort); } return dvPortgroupInfo; }
Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost, VirtualMachineMovePriority.highPriority, VirtualMachinePowerState.poweredOn);
EnvironmentBrowser envBrowser = cr.getEnvironmentBrowser(); ConfigTarget configTarget = envBrowser.queryConfigTarget(host); VirtualMachineConfigOption vmCfgOpt = envBrowser.queryConfigOption(null, host);
vm2.markAsVirtualMachine(this.vmwareComputeResource.getResourcePool(), null);
public void removePortGroup(Path path) throws RemoteException { ComputeResource res = getComputeResource(path.getParent()); HostSystem host = res.getHosts()[0]; HostNetworkSystem networkSystem = host.getHostNetworkSystem(); try { networkSystem.removePortGroup(path.getName()); } catch (NotFound swallow) { } }
public ComputeResourceConfigInfo getConfigurationEx() { return (ComputeResourceConfigInfo) this.getCurrentProperty("configurationEx"); }
ResourcePool rp = ((ComputeResource)host.getParent()).getResourcePool();
public void removeSwitch(Path path) throws RemoteException { ComputeResource res = getComputeResource(path.getParent()); HostSystem host = res.getHosts()[0]; HostNetworkSystem networkSystem = host.getHostNetworkSystem(); try { networkSystem.removeVirtualSwitch(path.getName()); } catch (NotFound swallow) { } }
Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost, VirtualMachineMovePriority.highPriority, VirtualMachinePowerState.poweredOn);
/** * Restores the SwitchResult object for the network task * @param host * @throws RemoteException */ public void restoreNetwork(VirtualHost host) throws RemoteException { ComputeResource res = host.getComputeResource(hostPath); HostSystem hostSys = res.getHosts()[0]; Network network = null; for (Network n : hostSys.getNetworks()) { if (n.getName().equals(portGroupName)) { network = n; break; } } if (network == null) { throw new RemoteException("Could not restore network from xml."); } Path switchPath = new Path(hostPath, switchName); Path portGroupPath = new Path(hostPath, portGroupName); SwitchResult switchResult = new SwitchResult(network, switchPath, portGroupPath); this.vSwitch = switchResult; }
ResourcePool rp = ((ComputeResource)host.getParent()).getResourcePool();
log.debug("Host: " + host); ComputeResource res = host.getComputeResource(hostPath); HostSystem hostSys = res.getHosts()[0]; HostNetworkSystem networkSystem = hostSys.getHostNetworkSystem();
ResourcePool pool = computeResource.getResourcePool();
public void powerOnVm() throws InvalidProperty, RuntimeFault, RemoteException, InterruptedException { Path hostPath = this.environment.getHostPath(); VirtualHost host = this.environment.fetchVirtualHost(); ComputeResource res = host.getComputeResource(hostPath); HostSystem hostSystem = res.getHosts()[0]; VirtualMachineRuntimeInfo vmri = vm.getRuntime(); if (vmri.getPowerState() == VirtualMachinePowerState.poweredOff || vmri.getPowerState() == VirtualMachinePowerState.suspended) { com.vmware.vim25.mo.Task task = vm.powerOnVM_Task(hostSystem); task.waitForTask(); log.info("vm:" + vm.getName() + " powered on."); } }
stopStartVM(); restoreConnection(); Task task = vm.migrateVM_Task(cr.getResourcePool(), newHost, VirtualMachineMovePriority.highPriority, VirtualMachinePowerState.poweredOn);