vSphere Build Version via API

726 views Asked by At

Is there a way do get the vsphere build versing using any API/SDK/REST?

I know it's possible using powershell on vcenter for that, but it'd be great if there was another option.

Like described here: https://www.virtuallyghetto.com/2017/08/powercli-script-to-help-correlate-vcenter-esxi-vsan-buildversions-wo-manual-vmware-kb-lookup.html

2

There are 2 answers

0
Rekovni On

It looks like you should be able to using the VMware vSphere API Python Bindings, as you can just simulate going through the Managed Object Browser.

Parent Managed Object ID: ServiceInstance
Property Path: content.about

And then there is a build string which is what you are looking for.

0
Quirinux On

I figure out how to do this, my need is having as much information about vsphere as possible, so get datacenter, cluster and host details is mantaroy.

For that I used the official ruby api, rbvmomi, but I believe it's exactly the same thing for python one and golang.

It's needed to interact through host folder under root/children object, which is not that clear on wmware api docs, to get it easier follow a piece of code:

vim = RbVmomi::VIM.connect host: host, user: 'user', password: 'pass', insecure: true, debug: false
vim.root.children.each do |root_child|
    root_child.hostFolder.children.each do |child|
        child.host.each do |host|
            prod = host.config.product
            puts host.name,                             
               prod.apiType,                     
               prod.apiVersion,                 
               prod.build,                           
               prod.fullName,                  
               prod.instanceUuid,             
               prod.licenseProductName, 
               prod.localeBuild,              
               prod.localeVersion,         
               prod.name,                           
               prod.osType,                      
               prod.productLineId,         
               prod.vendor,                       
               prod.version
        end
    end
end