From f925ff81ac49a6842111eee777536d4c8f75e31e Mon Sep 17 00:00:00 2001 From: Quentin Smith Date: Sun, 1 Jun 2008 23:53:12 -0400 Subject: [PATCH 1/1] Support YAML (default), JSON, and Pickle formats, depending on the client's choice svn path=/trunk/packages/sipb-xen-remctl-auto/; revision=553 --- debian/control.in | 2 +- files/usr/sbin/sipb-xen-listvms | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) 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) -- 1.7.9.5