Ignore:
Timestamp:
Jul 30, 2008, 9:27:08 PM (16 years ago)
Author:
price
Message:

invirt-config: print non-leaves as YAML

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-base/files/usr/sbin/invirt-getconf

    r788 r789  
    1818
    1919from invirt.config import load
    20 from sys import argv, exit, stderr
     20from sys import argv, exit, stderr, stdout
    2121from optparse import OptionParser
    2222
     
    5151        for i, component in enumerate(components):
    5252            progress = '.'.join(components[:i])
    53             if type(conf) not in [dict, list]:
     53            if type(conf) not in (dict, list):
    5454                raise invirt_exception(
    5555                        '%s: node has no children (atomic datum)' % progress)
     
    6666
    6767        if opts.ls:
    68             if type(conf) not in [dict, list]:
     68            if type(conf) not in (dict, list):
    6969                raise invirt_exception(
    7070                        '%s: node has no children (atomic datum)' % progress)
     
    7676                    print k
    7777        else:
    78             print conf
     78            if type(conf) not in (dict, list):
     79                print conf
     80            else:
     81                import yaml
     82                yaml.safe_dump(conf, stdout, default_flow_style=False)
    7983    except invirt_exception, ex:
    8084        print >> stderr, ex
Note: See TracChangeset for help on using the changeset viewer.