示例#1
0
def run_config(arg, config):
    """Run config"""
    for device in config:
        config[device].setdefault('device', '')
        config[device].setdefault('user', '')
        config[device].setdefault('password', '')
        config[device].setdefault('keyfile', '')
        config[device].setdefault('device_type', 'linux')
        config[device].setdefault('suite', '')
        config[device].setdefault('output', '')

        suite = SysInfoOutputSuite(config[device]['device'],
                                   config[device]['user'],
                                   config[device]['password'],
                                   config[device]['keyfile'])
        printer = SysInfoPrinter(config[device]['output'])

        if arg.check:
            suite.run_module(config[device]['suite'])
            printer.print_function_check(suite)
        elif arg.listing:
            suite.list_modules()
            printer.print_function_list(suite)
        else:
            suite.run_module(config[device]['suite'])
            printer.print_full_xml_stack(suite)
示例#2
0
                        default='230')
    parser.add_argument('--changes',
                        action='store_true',
                        help='Display only changes')
    parser.add_argument('--output',
                        metavar='FILE',
                        type=argparse.FileType('wt'),
                        help='Redirect the output to a file')
    parser.add_argument('--version', action='version',
                        version='Script version: '+__version__)
    try:
        return parser.parse_args()
    except IOError as msg:
        parser.error(str(msg))


if __name__ == "__main__":
    D_ARG = get_args()
    D_PRINTER = SysInfoPrinter(D_ARG.output)
    D_XML = SysInfoDiffXml(D_ARG.first, D_ARG.second)

    if D_ARG.listing:
        sys.stderr.write('First file:\n')
        D_PRINTER.print_xml_function_list(D_XML.first)
        sys.stderr.write('Second file:\n')
        D_PRINTER.print_xml_function_list(D_XML.second)
    else:
        D_XML.diff_process(D_ARG)
        D_PRINTER.print_diff_output(D_XML.get_diff_output())