You can also use the SDK wrapper:
https://github.com/rhevm-qe-automation/ovirtlib4

eng = OvirtLib("fqdn.something.com", username="myuser", password="mypassword")

for vm in eng.vms():
     if vm.entity.status.name == "UP":
         print(vm(follow="host").entity.host.name)


Thx

Roni


On Sun, Feb 21, 2021 at 11:47 PM <[email protected]> wrote:

> Thanks heaps.
>
> I've realised that I can use the follow_link method to get a reference to
> the host as well as below:
>
> ...
> vms_service = connection.system_service().vms_service()
> vms = vms_service.list()
> for vm in vms:
>   vm_service = vms_service.vm_service(vm.id)
>   if vm.status == types.VmStatus.UP:
>     vmhost = connection.follow_link(vm.host)
>     print("{0:<30s}{1:<30}{2:<30}".format(vm.name,vmhost.name,host.name))
> connection.close()
> ...
> _______________________________________________
> Users mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> 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/[email protected]/message/OOOUUP5SJBQWSYYNF4HLG6YQSFE3RDLM/
>
_______________________________________________
Users mailing list -- [email protected]
To unsubscribe send an email to [email protected]
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/[email protected]/message/WL5ZYHHLZ24TNHI6WAZQQOJMZERDHHUP/

Reply via email to