使用nova库获取vmware虚拟机硬件信息

>>> from nova.virt.vmwareapi.driver import VMwareAPISession
>>> session = VMwareAPISession( host_ip="xxx.xxx.xxx.xx ",
                 username="xxx ",
                 password="xxxxx ",
                 retry_count="3",
                 scheme="https")
)
>>> client_factory = session._get_vim().client.factory
>>> from nova.virt.vmwareapi.vm_util import _get_vm_ref_from_vm_uuid
>>> from nova.virt.vmwareapi import vim_util
>>> vm_ref = _get_vm_ref_from_vm_uuid(session, "instance-uuid-xxxx-xxx-xxx-xxx-xxx ")
>>> hardware_devices  = session._call_method(vim_util, "get_dynamic_property",vm_ref, "VirtualMachine", "config.hardware.device")
>>> hardware_devices = hardware_devices.VirtualDevice
>>> for device in hardware_devices:
...     print device
...     device.__class__.__name__ ​

你可能感兴趣的:(python,openstack)