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'))
18 name, data = get_dom(int(domid))
20 continue # went down since we started
21 if name.startswith('d_'):
27 name = trans.read('', '/local/domain/%d/name' % domid)
30 # presence of a graphical console
31 data['console'] = trans.read('', '/local/domain/%d/device/vfb/0/state' % domid)
33 data['vm'] = trans.read('', '/local/domain/%d/vm' % domid)
34 data['start_time'] = float(trans.read('', '%s/start_time' % data['vm']))
35 data['uptime'] = time.time()-data['start_time']
39 if __name__ == '__main__':
41 if '--json' in sys.argv[1:]:
43 print cjson.encode(vms)
44 elif '--pickle' in sys.argv[1:]:
46 cPickle.dump(vms, sys.stdout, cPickle.HIGHEST_PROTOCOL)
49 print yaml.dump(vms, Dumper=yaml.CSafeDumper, default_flow_style=False)