summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Likins <alikins@grimlock.devel.redhat.com>2008-01-03 17:23:32 -0500
committerAdrian Likins <alikins@grimlock.devel.redhat.com>2008-01-03 17:23:32 -0500
commit97ec4e4f384d3b41905500774349d8c165f86c42 (patch)
tree5acc0244b0068f961cec40ecbb17914732b59b03
parentf31f2fddc2130591ed192750ef9c31091055439f (diff)
downloadthird_party-func-97ec4e4f384d3b41905500774349d8c165f86c42.tar.gz
third_party-func-97ec4e4f384d3b41905500774349d8c165f86c42.tar.xz
third_party-func-97ec4e4f384d3b41905500774349d8c165f86c42.zip
apply patch from Al Tobey <tobert@gmail.com>
>The attached patch renames the virt module's info() method to state(), >then adds a new info() method that returns all of libvirt's info() >data.
-rwxr-xr-xfunc/minion/modules/virt.py34
1 files changed, 27 insertions, 7 deletions
diff --git a/func/minion/modules/virt.py b/func/minion/modules/virt.py
index b92dd54..747ba04 100755
--- a/func/minion/modules/virt.py
+++ b/func/minion/modules/virt.py
@@ -148,14 +148,34 @@ class Virt(func_module.FuncModule):
self.conn = FuncLibvirtConnection()
return self.conn
+ def state(self):
+ vms = self.list_vms()
+ state = []
+ for vm in vms:
+ state_blurb = self.conn.get_status(vm)
+ state.append("%s %s" % (vm,state_blurb))
+ return state
+
+
def info(self):
- vms = self.list_vms()
- info = []
- for vm in vms:
- print vm
- info_blurb = self.conn.get_status(vm)
- info.append("%s %s" % (vm,info_blurb))
- return info
+ vms = self.list_vms()
+ info = dict()
+ for vm in vms:
+ data = self.conn.find_vm(vm).info()
+ # libvirt returns maxMem, memory, and cpuTime as long()'s, which
+ # xmlrpclib tries to convert to regular int's during serialization.
+ # This throws exceptions, so convert them to strings here and
+ # assume the other end of the xmlrpc connection can figure things
+ # out or doesn't care.
+ info[vm] = {
+ "state" : VIRT_STATE_NAME_MAP.get(data[0],"unknown"),
+ "maxMem" : str(data[1]),
+ "memory" : str(data[2]),
+ "nrVirtCpu" : data[3],
+ "cpuTime" : str(data[4])
+ }
+ return info
+
def list_vms(self):
self.conn = self.get_conn()