Added the VM status and total RAM usage

This commit is contained in:
Anton Beloglazov 2012-10-08 17:07:02 +11:00
parent 8eddc40f0c
commit 5a39380523
2 changed files with 18 additions and 5 deletions

View File

@ -582,14 +582,20 @@ def migrate_vms(nova, placement):
time.sleep(5)
while True:
for vm_uuid in vms:
for vm_uuid in placement.keys():
vm = nova.servers.get(vm_uuid)
if vm_hostname(vm) != placement[vm] or vm.status != u'ACTIVE':
if log.isEnabledFor(logging.DEBUG):
log.info('VM %s: %s, %s',
vm_uuid,
vm_hostname(vm),
vm.status)
if vm_hostname(vm) != placement[vm_uuid] or \
vm.status != u'ACTIVE':
break
else:
if log.isEnabledFor(logging.INFO):
log.info('Completed migration of VM %s to %s',
vm, placement[vm])
vm_uuid, placement[vm_uuid])
else:
return
time.sleep(3)

View File

@ -34,7 +34,14 @@ nova = client.Client(config['os_admin_user'],
placement = dict((str(vm.human_id), vm_hostname(vm)) for vm in nova.servers.list())
placement = dict((str(vm.human_id),
(vm.status,
vm_hostname(vm),
nova.hosts.get(vm_hostname(vm))[2].memory_mb))
for vm in nova.servers.list())
for vm in sorted(placement.keys()):
print '{0:15} ==> {1}'.format(vm, placement[vm])
print '{0:10} {1:10} {2} [{3} MB used]'.format(vm,
placement[vm][0],
placement[vm][1],
placement[vm][2])