I am having some issues figuring out how to get a list of VMs and the host that they are running on.
I seem to be able to get a reference to the host object, but can't see how to print the name of the host.
See the below code snippet:
#! /usr/bin/python
import ovirtsdk4 as sdk
import ovirtsdk4.types as types
connection = sdk.Connection(
url='https:/<redacted>:443/ovirt-engine/api',
username='admin@internal',
password='<redacted>',
ca_file='ovirt-engine_ca.crt',
)
vms_service = connection.system_service().vms_service()
vms = vms_service.list()
for vm in vms:
print("VM.name = " + vm.name)
vm_service = vms_service.vm_service(vm.id)
#vm = vm_service.get()
print(vm.status)
if vm.name == 'vmexample':
print("HERE")
print(vm.host)
print(vm.host.name)
connection.close()
OUTPUT:
VM.name = vmexample
up
HERE
<ovirtsdk4.types.Host object at 0x7f5ca250e810>
None
What am I missing?
Thanks,
Jason
_______________________________________________
Users mailing list -- users@ovirt.org
To unsubscribe send an email to users-leave@ovirt.org
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/LU7GPDJPEOOBPHRL2TQ6ZQOMJCBEX62Y/