VMware {code} Community
sajuptpm
Contributor
Contributor

How to get Storage Resources, Mount Devices and Available Interfacesan of an Esxi host

Hi,

I want to find following things from Esxi host via sdk

1)

number of sockets in an Esxi host

2)

Number of cores

I think "host.summary.hardware.numCpuCores" will give it.

Is it correct ?

3)

Storage Resources

host.datastore will return list of storages (object of class Datastore)

Is it correct ?

I need storage resources available in an Esxi host like : NFS, etc---   (with info like size, used, free, type )

4)

Virtual Networks
host.network will return list of networks (object of class Network)

Is it correct ?

5)

Mount Devices

I don't konw how get devices (eg: /dev/sda) mounted to an Esxi host

6)

Available Interfaces

I don't konw how get interfaces available in an Esxi host

I want to find interfaces like : etho, tap0, br1 (with its config details)

3 Replies
sajuptpm
Contributor
Contributor

Hi,

Please confirm that I am fetching information from proper location.


1)

Mount Devices

===========

http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fvim.host.FileS...

https://192.168.0.116/mob/?moid=ha-host&doPath=config.fileSystemVolume.mountInfo

host.config.fileSystemVolume.mountInfo <=== Return list

----------------------------

https://192.168.0.116/mob/?moid=ha-host&doPath=configManager

https://192.168.0.116/mob/?moid=storageSystem&doPath=fileSystemVolumeInfo.mountInfo

host.configManager.storageSystem.fileSystemVolumeInfo.mountInfo

2)

Available Interfaces

===============

http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vsphere.privileges.doc_50%2FGUID-836...

https://192.168.0.116/mob/?moid=ha-host&doPath=config.network

host.config.network

---------------------------------

https://192.168.0.116/mob/?moid=networkSystem&doPath=networkInfo

3)

Storage Resources

==============

http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vsphere.privileges.doc_50%2FGUID-836...

https://192.168.0.116/mob/?moid=ha-host&doPath=config.storageDevice

host.config.storageDevice

--------------------------------

https://192.168.0.116/mob/?moid=ha-host&doPath=configManager

https://192.168.0.116/mob/?moid=storageSystem&doPath=storageDeviceInfo

host.configManager.storageSystem.storageDeviceInfo

4)

Virtual Networks

=============

http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.vsphere.privileges.doc_50%2FGUID-836...

https://192.168.0.116/mob/?moid=ha-host&doPath=config.virtualNicManagerInfo.netConfig

host.config.virtualNicManagerInfo.netConfig

-------------------------

https://192.168.0.116/mob/?moid=ha-host&doPath=configManager

https://192.168.0.116/mob/?moid=ha-vnic-mgr&doPath=info.netConfig

host.configManager.ha-vnic-mgr.info.netConfig

Thanks

Reply
0 Kudos
comiscience
Contributor
Contributor

Hello

What i want to ask you is about Storage Resources.

I tried to get storage information by code below:

      Object cmobj  = cb.getServiceUtil().GetDynamicProperty(hostmor, "configManager");
      HostConfigManager configMgr = (HostConfigManager)cmobj;
      ManagedObjectReference ssSystem = configMgr.storageSystem;
      HostStorageDeviceInfo storageInfo = (HostStorageDeviceInfo)cb.getServiceUtil().GetDynamicProperty(ssSystem, "storageDeviceInfo");
In the storageInfo, i cannot get directely storage resources information like size, used, free, type. Could you tell me how did you get these informations?
And indeed, i tried to get these information by using code below:

_service = ecb.getServiceConnectionV25().Service;

_sic = ecb.getServiceConnectionV25().ServiceContent; 

ManagedObjectReference[] hmor = _service.FindAllByIp(_sic.searchIndex, dcmor, ecb.get_option("hostname"), true);

I can just get one disk information of total 10 disks.

Do you have any idea?

Thanks

Reply
0 Kudos
comiscience
Contributor
Contributor

Object cobj = cb.getServiceUtil().GetDynamicProperty(hostmor, "datastore");
                    ManagedObjectReference[] datastores = (ManagedObjectReference[])cobj;
                    for (int i = 0; i < datastores.Length; i++)
                    {
                        VimApi.DatastoreSummary storageSummaryInfo = (VimApi.DatastoreSummary)cb.getServiceUtil().GetObjectProperties(cb.getConnection().ServiceContent.propertyCollector, datastores[i], new String[] { "summary" })[0].propSet[0].val;
                        Console.WriteLine("  Id: " + storageSummaryInfo.name +
                                          " ; Peripherique: " + storageSummaryInfo.url +
                                          " ; Capacite: " + storageSummaryInfo.capacity +
                                          " ; Libre: " + storageSummaryInfo.freeSpace +
                                          " ; Type: " + storageSummaryInfo.type);
                    }