vmware / pyvmomi

VMware vSphere API Python Bindings
Apache License 2.0
2.19k stars 766 forks source link

Getting error with vim.LicenseManager #1037

Closed devnarenku closed 1 year ago

devnarenku commented 1 year ago

Describe the bug

Hi,

Getting the following error with vim.LicenseManager. Kindly help to fix the issue.

I am using "pyvmomi==8.0.1.0.1".

content.viewManager.CreateContainerView(content.rootFolder, [vim.LicenseManager], True)

vmodl.fault.InvalidArgument: (vmodl.fault.InvalidArgument) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = 'A specified parameter was not correct: type',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) [],
   invalidProperty = 'type'
}

Reproduction steps

  1. content.viewManager.CreateContainerView(content.rootFolder, [vim.LicenseManager], True)
  2. ...

Expected behavior

Need to get the ESXi hosts License details whether it's using a trial license or paid one.

Additional context

No response

DanielDraganov commented 1 year ago

Hello, The code snippet does not work because CreateContainerView works with a particular set of types. The first argument must be "A reference to an instance of a Folder, Datacenter, ComputeResource, ResourcePool, or HostSystem object. " Ref: Search for "CreateContainerView" in https://developer.vmware.com/apis/1639/vsphere

About the license info. This should do the job. Please refer to the API doc if you need more license related API calls. licenseManager = si.content.licenseManager licenses = licenseManager.licenses

devnarenku commented 1 year ago

Thanks DanielDraganov for your quick help.