I want to retrieve ESXi information (Model and hardware BIOS identification)
I found we need to browse HostHardwareSummary, but can't find any reference/example in Python. https://github.com/vmware/pyvmomi
I want to retrieve ESXi information (Model and hardware BIOS identification)
I found we need to browse HostHardwareSummary, but can't find any reference/example in Python. https://github.com/vmware/pyvmomi
import ssl
import requests
# this will disable the warnings from requests
requests.packages.urllib3.disable_warnings()
from pyVmomi import vim
from pyVim import connect
# this will only work if you have 2.7.9 or newer
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_NONE
service_instance = connect.SmartConnect(host="your host", user="your user", pwd="password", sslContext=context)
search_index = service_instance.content.searchIndex
root_folder = service_instance.content.rootFolder
# below is one of several ways to find a host.. this is one of the worst ways but it is quick for the purpose of this example
view_ref = service_instance.content.viewManager.CreateContainerView(container=root_folder,type=[vim.HostSystem], recursive=True)
host = view_ref.view[0]
print host.name
print host.summary.hardware.uuid
print host.summary.hardware.model
view_ref.Destroy
I hope this example helps. If you need to get this info for a lot of hosts you should really use a property collector. I wrote a sample that does it for VMs but would not take much to modify it for HostSystems.. You can find it here