From: Quentin Smith Date: Mon, 2 Jun 2008 03:53:12 +0000 (-0400) Subject: Support YAML (default), JSON, and Pickle formats, depending on the client's choice X-Git-Tag: sipb-xen-remctl-auto/1.0.16~7 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-remote.git/commitdiff_plain/f925ff81ac49a6842111eee777536d4c8f75e31e?ds=inline Support YAML (default), JSON, and Pickle formats, depending on the client's choice svn path=/trunk/packages/sipb-xen-remctl-auto/; revision=553 --- diff --git a/debian/control.in b/debian/control.in index 2a90fd7..9ffe173 100644 --- a/debian/control.in +++ b/debian/control.in @@ -7,6 +7,6 @@ Standards-Version: 3.7.2 Package: sipb-xen-remctl-auto Architecture: all -Depends: ${misc:Depends}, remctl-server, sipb-xen-console-server +Depends: ${misc:Depends}, remctl-server, sipb-xen-console-server, python-cjson, python-yaml Description: Installs the SIPB Xen automatic remctl management system This is our automatic remctl configuration management system. diff --git a/files/usr/sbin/sipb-xen-listvms b/files/usr/sbin/sipb-xen-listvms index 34cff0e..8b78b22 100755 --- a/files/usr/sbin/sipb-xen-listvms +++ b/files/usr/sbin/sipb-xen-listvms @@ -4,7 +4,6 @@ import sys import time sys.path.insert(0, '/usr/lib/xen-3.1-1/lib/python') from xen.lowlevel.xs import xs -import yaml trans = xs() @@ -36,4 +35,12 @@ def get_dom(domid): if __name__ == '__main__': vms = live_vms() - print yaml.safe_dump(vms, default_flow_style=False) + if '--json' in sys.argv[1:]: + import cjson + print cjson.encode(vms) + elif '--pickle' in sys.argv[1:]: + import cPickle + cPickle.dump(vms, sys.stdout, cPickle.HIGHEST_PROTOCOL) + else: + import yaml + print yaml.safe_dump(vms, default_flow_style=False)