5 sys.path.insert(0, '/usr/lib/xen-3.1-1/lib/python')
6 from xen.lowlevel.xs import xs
11 domids = set(trans.ls('', '/local/domain'))
17 name, data = get_dom(int(domid))
18 if name.startswith('d_'):
24 name = trans.read('', '/local/domain/%d/name' % domid)
27 # presence of a graphical console
28 data['console'] = trans.read('', '/local/domain/%d/device/vfb/0/state' % domid)
30 data['vm'] = trans.read('', '/local/domain/%d/vm' % domid)
31 data['start_time'] = float(trans.read('', '%s/start_time' % data['vm']))
32 data['uptime'] = time.time()-data['start_time']
36 if __name__ == '__main__':
38 if '--json' in sys.argv[1:]:
40 print cjson.encode(vms)
41 elif '--pickle' in sys.argv[1:]:
43 cPickle.dump(vms, sys.stdout, cPickle.HIGHEST_PROTOCOL)
46 print yaml.safe_dump(vms, default_flow_style=False)