Ignore:
Timestamp:
Jun 1, 2008, 11:53:12 PM (16 years ago)
Author:
quentin
Message:

Support YAML (default), JSON, and Pickle formats, depending on the client's choice

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-listvms

    r551 r553  
    55sys.path.insert(0, '/usr/lib/xen-3.1-1/lib/python')
    66from xen.lowlevel.xs import xs
    7 import yaml
    87
    98trans = xs()
     
    3736if __name__ == '__main__':
    3837    vms = live_vms()
    39     print yaml.safe_dump(vms, default_flow_style=False)
     38    if '--json' in sys.argv[1:]:
     39        import cjson
     40        print cjson.encode(vms)
     41    elif '--pickle' in sys.argv[1:]:
     42        import cPickle
     43        cPickle.dump(vms, sys.stdout, cPickle.HIGHEST_PROTOCOL)
     44    else:
     45        import yaml
     46        print yaml.safe_dump(vms, default_flow_style=False)
Note: See TracChangeset for help on using the changeset viewer.