I've tried multiple ways of getting the license information for a host. we'd like to automate this so that once a year we can just run the script and write the information to a database for audit purposes. I'm just not sure how as I loop through the hosts am able to get the License Information.
----BEGIN CODE----
def get_obj(si, root, vim_type):
container = si.content.viewManager.CreateContainerView(root, vim_type,True)
view = container.view
#print(container.view)
obj = [ret for ret in container.view]
container.Destroy()
return obj
lm = content.licenseManager.licenseAssignmentManager
DCS = get_obj(c, c.content.rootFolder, [vim.Datacenter])
print(DCS)
print(len(DCS))
for dc in DCS:
print("DATACENTEER --"+dc.name)
HOSTS = get_obj(c,dc,[vim.HostSystem])
for host in HOSTS:
print("HOST -- "+str(host.config.host))
print(host.hardware.systemInfo.uuid)
#entity_id = host.hardware.systemInfo.uuid
print(lm.QueryAssignedLicenses(str(host.config.host)))
#print(host.config)
#print(host.configManager)
#sys.exit()