vim.LicenseManager in pyvmomi returns as an unsupported type?

290 Views Asked by At

I am trying to get all of the information on the licenses within a vSphere instance, and since I am already using pyvmomi for the vm information, I figured it'd be easiest to use it for the licenses as well, but now a it doesn't seem to work for about half of the objects the recommended docs say it should. Here is my code that is generating the error:

# args are login details
si = service_instance.connect(args)
content = si.RetrieveContent()
host_view = content.viewManager.CreateContainerView(content.rootFolder, [vim.LicenseManager], True)
hosts = list(host_view.view)
host_view.Destroy()

This is the error it generates:

  line 30, in get_data
    host_view = content.viewManager.CreateContainerView(content.rootFolder, [vim.AboutInfo], True)
  File "C:\Programs\Python\Python39\lib\site-packages\pyVmomi\VmomiSupport.py", line 706, in <lambda>
    self.f(*(self.args + (obj,) + args), **kwargs)
  File "C:\Programs\Python\Python39\lib\site-packages\pyVmomi\VmomiSupport.py", line 512, in _InvokeMethod
    return self._stub.InvokeMethod(self, info, args)
  File "C:\Programs\Python\Python39\lib\site-packages\pyVmomi\SoapAdapter.py", line 1397, in InvokeMethod
    raise obj # pylint: disable-msg=E0702
pyVmomi.VmomiSupport.InvalidArgument: (vmodl.fault.InvalidArgument) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = 'A specified parameter was not correct: type',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) [],
   invalidProperty = 'type'
}

The only types that have worked are:

  • vim.HostSystem
  • vim.ManagedEntity
  • vim.VirtualMachine
  • vim.ClusterComputeResource
  • vim.ComputeResource
  • vim.Datacenter
  • vim.Folder

And before you mark this as duplicate to Pyvmomi supported types (which is a similar quandary) I am trying to understand where in the chain in my vSphere or pyvmomi or code where this failure is occurring and why it is occurring, and my problem does not involve the vim.VirtualMachine type.

1

There are 1 best solutions below

0
ddraganov On BEST ANSWER

The same question was recently asked in the pyVmomi project issues. Answer -> https://github.com/vmware/pyvmomi/issues/1037#issuecomment-1627187432

licenseManager = content.licenseManager
licenses = licenseManager.licenses