Fix vm-queries.py
This commit is contained in:
parent
78470501dd
commit
46fc35d3c3
1 changed files with 6 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
|
|
||||||
from config import config, etcd_client
|
from config import etcd_client
|
||||||
|
|
||||||
|
|
||||||
def get_vm_by_ip(vms, ip, status='active'):
|
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():
|
for vm_id, vm in vms_by_status.items():
|
||||||
vm_ips = []
|
vm_ips = []
|
||||||
for nic in vm.get('nics', []):
|
for nic in vm.get('nic', []):
|
||||||
global_ipv6 = nic.get('IP6_GLOBAL', None)
|
global_ipv6 = nic.get('IP6_GLOBAL', None)
|
||||||
local_ipv6 = nic.get('IP6_LINK', None)
|
local_ipv6 = nic.get('IP6_LINK', None)
|
||||||
ipv4 = nic.get('IP', None)
|
ipv4 = nic.get('IP', None)
|
||||||
|
@ -23,7 +23,7 @@ def get_vm_by_ip(vms, ip, status='active'):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
vm_prefix = '/opennebula/vm/'
|
vm_prefix = '/opennebula/parsed_vm/'
|
||||||
|
|
||||||
vms = {
|
vms = {
|
||||||
int(vm.key.split('/')[-1]): vm.value
|
int(vm.key.split('/')[-1]): vm.value
|
||||||
|
@ -39,10 +39,10 @@ def main():
|
||||||
print(vms.get(VM_ID).get('host').get('name'))
|
print(vms.get(VM_ID).get('host').get('name'))
|
||||||
|
|
||||||
# Get VNC Port of a VM
|
# 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
|
# 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?
|
# Who is owner of a VM?
|
||||||
print(vms.get(VM_ID).get('owner').get('name'))
|
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')
|
search_ungleich_ch = get_vm_by_ip(vms, '2a0a:e5c0:0:5:0:78ff:fe11:d75f')
|
||||||
pprint(search_ungleich_ch)
|
pprint(search_ungleich_ch)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in a new issue