+sipb-xen-remctl-auto (1.0.14) unstable; urgency=low
+
+ * Use more efficient python API to get VM information, and return it
+ in a Python dict structure.
+
+ -- Quentin Smith <quentin@mit.edu> Thu, 15 May 2008 20:29:03 -0400
+
sipb-xen-remctl-auto (1.0.13) unstable; urgency=low
* Switch to just using the remote server.
-#!/bin/sh
+#!/usr/bin/python
-xm uptime | sed -n 's/^d_// p'
+import sys
+sys.path.insert(0, '/usr/lib/xen-3.1-1/lib/python')
+from xen.lowlevel.xs import xs
+
+trans = xs()
+
+def live_vms():
+ domids = set(trans.ls('', '/local/domain'))
+ domids.remove('0')
+
+ vms = dict()
+
+ for domid in domids:
+ name, data = get_dom(int(domid))
+ if name.startswith('d_'):
+ name = name[2:]
+ vms[name] = data
+ return vms
+
+def get_dom(domid):
+ name = trans.read('', '/local/domain/%d/name' % domid)
+ data = dict()
+ data['domid'] = domid
+ # presence of a graphical console
+ data['console'] = trans.read('', '/local/domain/%d/device/vfb/0/state' % domid)
+ # uptime
+ data['vm'] = trans.read('', '/local/domain/%d/vm' % domid)
+ data['start_time'] = float(trans.read('', '%s/start_time' % data['vm']))
+
+ return name, data
+
+if __name__ == '__main__':
+ vms = live_vms()
+ if '--pickle' in sys.argv[1:]:
+ import cPickle
+ cPickle.dump(vms, sys.stdout)
+ else:
+ print vms