Fix vm_by_host bug

When get the vm from the host,It shoud skip the vms of which the
state is not 'active'.Because the error one can't be migrated.

Change-Id: I56c3d9d00f521a909f17f8c63cf9d5a9f5d77144
This commit is contained in:
wangxiyuan 2015-04-29 14:45:33 +08:00
parent f1a8fb44b9
commit 618fdc6133

View File

@ -704,7 +704,7 @@ def vms_by_host(nova, host):
:rtype: list(str)
"""
return [str(vm.id) for vm in nova.servers.list()
if vm_hostname(vm) == host]
if (vm_hostname(vm) == host and str(getattr(vm, 'OS-EXT-STS:vm_state')) == 'active')]
@contract