From 46fc35d3c3ad3e9028920e5257ee80b6d98af35c Mon Sep 17 00:00:00 2001 From: meow Date: Fri, 31 Jan 2020 23:10:16 +0500 Subject: [PATCH] Fix vm-queries.py --- opennebula-vm-etcd/vm-queries.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/opennebula-vm-etcd/vm-queries.py b/opennebula-vm-etcd/vm-queries.py index e92ef14..e1da013 100644 --- a/opennebula-vm-etcd/vm-queries.py +++ b/opennebula-vm-etcd/vm-queries.py @@ -1,6 +1,6 @@ from pprint import pprint -from config import config, etcd_client +from config import etcd_client def get_vm_by_ip(vms, ip, status='active'): @@ -11,7 +11,7 @@ def get_vm_by_ip(vms, ip, status='active'): } for vm_id, vm in vms_by_status.items(): vm_ips = [] - for nic in vm.get('nics', []): + for nic in vm.get('nic', []): global_ipv6 = nic.get('IP6_GLOBAL', None) local_ipv6 = nic.get('IP6_LINK', None) ipv4 = nic.get('IP', None) @@ -23,7 +23,7 @@ def get_vm_by_ip(vms, ip, status='active'): def main(): - vm_prefix = '/opennebula/vm/' + vm_prefix = '/opennebula/parsed_vm/' vms = { int(vm.key.split('/')[-1]): vm.value @@ -39,10 +39,10 @@ def main(): print(vms.get(VM_ID).get('host').get('name')) # Get VNC Port of a VM - print(vms.get(VM_ID).get('graphics')[0].get('PORT')) + print(vms.get(VM_ID).get('graphics').get('PORT')) # Get all disks attached with VM - pprint(vms.get(VM_ID).get('disks')) + pprint(vms.get(VM_ID).get('disk')) # Who is owner of a VM? print(vms.get(VM_ID).get('owner').get('name')) @@ -51,5 +51,6 @@ def main(): search_ungleich_ch = get_vm_by_ip(vms, '2a0a:e5c0:0:5:0:78ff:fe11:d75f') pprint(search_ungleich_ch) + if __name__ == '__main__': main()