public HostSystem[] getHosts() { return getHosts("host"); }
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) { } }
/** * 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; }
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 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."); } }
log.debug("Host: " + host); ComputeResource res = host.getComputeResource(hostPath); HostSystem hostSys = res.getHosts()[0]; HostNetworkSystem networkSystem = hostSys.getHostNetworkSystem();