我正在尝试获取vSphere实例中许可证的所有信息,由于我已经在使用pyvmomi来获取vm信息,我认为将其用于许可证也是最简单的,但现在它似乎不适用于推荐文档所说的大约一半的对象。这是我产生错误的代码:
# 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()
这是它产生的错误:
line 30, in get_data
host_view = content.viewManager.CreateContainerView(content.rootFolder, [vim.AboutInfo], True)
File "C:ProgramsPythonPython39libsite-packagespyVmomiVmomiSupport.py", line 706, in <lambda>
self.f(*(self.args + (obj,) + args), **kwargs)
File "C:ProgramsPythonPython39libsite-packagespyVmomiVmomiSupport.py", line 512, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "C:ProgramsPythonPython39libsite-packagespyVmomiSoapAdapter.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'
}
唯一有效的类型是:
- vim.HostSystem
- vim.Managed实体
- vim.VirtualMachine
- vim.ClusterComputeResource
- vim.ComputeResource
- vim.Datacenter
- vim.Folder
在将其标记为与Pyvmomi支持的类型重复之前(这是一个类似的难题(,我正在努力了解vSphere或Pyvmomi或代码中链中的何处发生了此故障,以及为什么会发生此故障,而我的问题不涉及vim。虚拟机类型。
最近在pyVmomi项目问题中也提出了同样的问题。答案->https://github.com/vmware/pyvmomi/issues/1037#issuecomment-1627187432
licenseManager = content.licenseManager
licenses = licenseManager.licenses