|
|
@ -275,12 +275,17 @@ class Virt(object):
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return info
|
|
|
|
return info
|
|
|
|
|
|
|
|
|
|
|
|
def list_vms(self):
|
|
|
|
def list_vms(self, state=None):
|
|
|
|
self.conn = self.__get_conn()
|
|
|
|
self.conn = self.__get_conn()
|
|
|
|
vms = self.conn.find_vm(-1)
|
|
|
|
vms = self.conn.find_vm(-1)
|
|
|
|
results = []
|
|
|
|
results = []
|
|
|
|
for x in vms:
|
|
|
|
for x in vms:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
if state:
|
|
|
|
|
|
|
|
vmstate = self.conn.get_status2(x)
|
|
|
|
|
|
|
|
if vmstate == state:
|
|
|
|
|
|
|
|
results.append(x.name())
|
|
|
|
|
|
|
|
else:
|
|
|
|
results.append(x.name())
|
|
|
|
results.append(x.name())
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
@ -395,6 +400,11 @@ def core(module):
|
|
|
|
v = Virt(uri)
|
|
|
|
v = Virt(uri)
|
|
|
|
res = {}
|
|
|
|
res = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if state and command=='list_vms':
|
|
|
|
|
|
|
|
res = v.list_vms(state=state)
|
|
|
|
|
|
|
|
if type(res) != dict:
|
|
|
|
|
|
|
|
res = { command: res }
|
|
|
|
|
|
|
|
return VIRT_SUCCESS, res
|
|
|
|
|
|
|
|
|
|
|
|
if state:
|
|
|
|
if state:
|
|
|
|
if not guest:
|
|
|
|
if not guest:
|
|
|
|