VMware {code} Community
stanimal1
Contributor
Contributor

How to query vCenter API for host version, host health, EVC state, and weather or not Hyperthreading

I have written a script get a ton of vcenter, cluster, and host information using only 443 access to all our vcenters. I am short 4 pieces of information to complete the reports I need for daily operations. 

Does anyone know the uri's to pull vsphere host version, host health, evc state, and hyperthreading state for each host.

Any help or a point in the right direction would be appreciated.

0 Kudos
2 Replies
doskiran
Enthusiast
Enthusiast

From my understanding, not all vSphere REST APIs for the host get & post operations are available in the current releases. We may expect all REST APIs in the next vSphere major release.

But for your requirement use vSphere management SDK(SOAP-based APIs) to query host info.

Below is the sample code written using VIJAVA API.

public static void getHostInfo(String vcIPaddress, String userName, String password, String hostName) {
		try {
			ServiceInstance si = new ServiceInstance(new URL("https://" + vcIPaddress + "/sdk"), userName, password,true);
			HostSystem hs = (HostSystem) new InventoryNavigator(si.getRootFolder()).searchManagedEntity("HostSystem",hostName);
			// Host Version
			System.out.println("Host Version::" + hs.getSummary().getConfig().getProduct().getVersion());

			// Host Health
			HealthSystemRuntime hostHealth = hs.getHealthStatusSystem().getRuntime();
			System.out.println("HostHardwareStatusInfo::" + hostHealth.getHardwareStatusInfo());
			System.out.println("HostSystemHealthInfo::" + hostHealth.getSystemHealthInfo());

			// Weather or not Hyperthreading available
			System.out.println("Is Host Hyperthreading is available::" + hs.getConfig().getHyperThread().isAvailable());

			// Host EVC info
			System.out.println(
					"EVC info::" + hs.getSummary().getCurrentEVCModeKey() + " , " + hs.getSummary().getMaxEVCModeKey());

		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
	}

 

0 Kudos
Scott695852
Contributor
Contributor

I value and respect your opinion.

0 Kudos