public VirtualMachine[] getVms() throws InvalidProperty, RuntimeFault, RemoteException { return getVms("vm"); }
public Datastore[] getDatastores() throws InvalidProperty, RuntimeFault, RemoteException { return getDatastores("datastore"); }
ObjectNode toObjectNode(HostSystem host) { ManagedObjectReference mor = host.getMOR(); HostHardwareInfo hh = host.getHardware(); ObjectNode n = mapper.createObjectNode().put("id", getUniqueId(host)) .put("name", host.getName()).put("vmw_morType", mor.getType()) .put("vmw_morVal", mor.getVal()).put("vmw_hardwareModel", hh.getSystemInfo().getModel()) .put("vmw_cpuCoreCount", hh.getCpuInfo().getNumCpuCores()) .put("vmw_memorySize", hh.getMemorySize()); return n; }
/** * @since 4.0 */ public void updateIpmi(HostIpmiInfo ipmiInfo) throws InvalidIpmiLoginInfo, InvalidIpmiMacAddress, RuntimeFault, RemoteException { getVimService().updateIpmi(getMOR(), ipmiInfo); }
public Task disconnectHost() throws RuntimeFault, RemoteException { ManagedObjectReference mor = getVimService().disconnectHost_Task(getMOR()); return new Task(getServerConnection(), mor); }
System.out.println("Host Name : " + host.getName()); System.out.println("Network : " + host.getNetworks()[0].getName()); System.out.println("Datastore : " + host.getDatastores()[0].getName()); Folder vmFolder = (Folder) host.getVms()[0].getParent(); importSpecParams.setHostSystem(host.getMOR()); importSpecParams.setLocale("US"); importSpecParams.setEntityName(newVmName); OvfNetworkMapping networkMapping = new OvfNetworkMapping(); networkMapping.setName("Network 1"); networkMapping.setNetwork(host.getNetworks()[0].getMOR()); // network); importSpecParams.setNetworkMapping(new OvfNetworkMapping[] { networkMapping }); importSpecParams.setPropertyMapping(null); ResourcePool rp = ((ComputeResource)host.getParent()).getResourcePool(); ovfDescriptor, rp, host.getDatastores()[0], importSpecParams);
hostNetworkSystem = hostSystem.getHostNetworkSystem(); } catch (RemoteException e) { logger.warn("Error fetching network information for Host System '{}' (ID: {})", hostSystem.getName(), hostSystem.getMOR().getVal()); logger.warn("Exception thrown while fetching network information: {}", e); return ipAddresses;
System.out.println("Host Name : " + host.getName()); System.out.println("Network : " + host.getNetworks()[0].getName()); System.out.println("Datastore : " + host.getDatastores()[0].getName());
/** * Checks whether the host system should be imported into the requisition. * * @param hostSystem the system to check * @return true for import, false otherwise */ private boolean checkHostPowerState(HostSystem hostSystem) { logger.debug("Checking power state for host system {} (ID {})", hostSystem.getName(), hostSystem.getMOR().getVal()); String powerState = hostSystem.getRuntime().getPowerState().toString(); if ("poweredOn".equals(powerState) && request.isImportHostPoweredOn()) { return true; } if ("poweredOff".equals(powerState) && request.isImportHostPoweredOff()) { return true; } if ("standBy".equals(powerState) && request.isImportHostStandBy()) { return true; } if ("unknown".equals(powerState) && request.isImportHostUnknown()) { return true; } return false; }
HostSystem h = (HostSystem) hs[j]; if (h != null) { HostListSummary hsum = h.getSummary(); HostHardwareSummary hd = hsum.getHardware(); if (hsum != null && hd != null) { JsonObject jObject = new JsonObject(); jObject.addProperty("{#ESXHOST}", h.getName()); jObject.addProperty("{#UUID}", hd.getUuid()); jObject.addProperty("{#CLUSTER}", h.getParent().getName()); jArray.add(jObject);
private PerfMetricId[] getHostPerformanceManager(HostSystem host, int interval) throws RemoteException { PerfMetricId[] queryAvailablePerfMetric = null; String name = host.getName(); queryAvailablePerfMetric = hostPerfCache.getIfPresent(name); if (queryAvailablePerfMetric != null) { LOG.debug("CacheHIT: PerfID name: " + name); return queryAvailablePerfMetric; } queryAvailablePerfMetric = performanceManager.queryAvailablePerfMetric(host, null, null, interval); hostPerfCache.put(name, queryAvailablePerfMetric); LOG.debug("CacheMISS: PerfID name: " + name); return queryAvailablePerfMetric; }
HostRuntimeInfo hostRuntimeInfo = hostSystem.getRuntime(); for (Datastore datastore : hostSystem.getDatastores()) { if (vmwareTopologyInfo.length() > 0) { vmwareTopologyInfo.append(", "); for (Network network : hostSystem.getNetworks()) { if (vmwareTopologyInfo.length() > 0) { vmwareTopologyInfo.append(", ");
protected void scanHost(HostSystem host, boolean scanGuests) { try { logger.info("scanning esxi host={}", host.getName()); ObjectNode n = toObjectNode(host); logger.info("scanning guests on esxi host={}",host.getName()); VirtualMachine[] vms = host.getVms(); if (vms != null) { int count =0; logger.info("scanned {} guests on host={}",count,host.getName()); logger.info("scanned {} guests on host={}",count,host.getName());
public static void removeVirtualSwitch(HostSystem host, String vswitchId) throws RemoteException { try { HostNetworkSystem hns = host.getHostNetworkSystem(); hns.removeVirtualSwitch(vswitchId); System.out.println("Successful removed: " + vswitchId); } catch (NotFound e) { System.out.println("Failed : virtual switch cannot be found. "); } catch (HostConfigFault e) { System.out.println("Failed : Configuration falilures. "); } catch (ResourceInUse e) { System.out.println("Failed removing switch "+ vswitchId); System.out.println("There are virtual network adapters " + "associated with the virtual switch."); } catch (Exception e) { System.out.println("Failed removing switch: "+ vswitchId +"\n" + e); } }
public HostCapability queryTargetCapabilities(HostSystem host) throws RuntimeFault, RemoteException { return getVimService().queryTargetCapabilities(getMOR(), host==null?null:host.getMOR()); } }
ScsiLun[] scsiLuns = (ScsiLun[])host.getConfig().getStorageDevice().getScsiLun(); printScsiLunInfo(scsiLuns[i]); Datastore[] datastores = host.getDatastores(); System.out.println("\nVMFS Affected "); printVMFS(datastores, scsiLuns[i].getCanonicalName());
/** * Returns the running host of a virtual machine */ private void getVmHost(String vmName, PrintWriter out) throws IOException { try { VirtualMachine vm = (VirtualMachine) getManagedEntity(vmName, "VirtualMachine"); String vmHost = ""; if (vm == null) { LOG.warn("No vm named '" + vmName + "' found"); } else { VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime(); ManagedObjectReference hmor = vmRuntimeInfo.getHost(); HostSystem host = new HostSystem(vm.getServerConnection(), hmor); vmHost = host.getName(); } out.print(vmHost); out.flush(); } catch (Exception ex) { LOG.error("An error occurred : " + ex.toString()); } }
private static VirtualDevice[] getDefaultDevices(VirtualMachine vm) throws Exception { VirtualMachineRuntimeInfo vmRuntimeInfo = vm.getRuntime(); EnvironmentBrowser envBrowser = vm.getEnvironmentBrowser(); ManagedObjectReference hmor = vmRuntimeInfo.getHost(); VirtualMachineConfigOption cfgOpt = envBrowser.queryConfigOption(null, new HostSystem(vm.getServerConnection(), hmor)); VirtualDevice[] defaultDevs = null; if (cfgOpt == null) { throw new Exception("No VirtualHardwareInfo found in ComputeResource"); } else { defaultDevs = cfgOpt.getDefaultDevice(); if (defaultDevs == null) { throw new Exception("No Datastore found in ComputeResource"); } } return defaultDevs; }
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; }
ComputeResource res = host.getComputeResource(hostPath); HostSystem hostSys = res.getHosts()[0]; HostNetworkSystem networkSystem = hostSys.getHostNetworkSystem(); for (Network n : hostSys.getNetworks()) { if (n.getName().equals(newPortGroupName)) { network = n;