コード例 #1
0
    def setup_class(cls):
        logger.info('SETUP')
        os.environ['UTILITIES_UNIT_TESTING'] = '2'

        backup_yang_models()
        move_yang_models(test_path, 'autogen_test', test_yang_models)

        for yang_model in test_yang_models:
            gen.generate_cli_plugin(cli_group='show',
                                    plugin_name=yang_model.split('.')[0],
                                    config_db_path=config_db_path,
                                    templates_path=templates_path)
            gen.generate_cli_plugin(cli_group='config',
                                    plugin_name=yang_model.split('.')[0],
                                    config_db_path=config_db_path,
                                    templates_path=templates_path)

        helper = util_base.UtilHelper()
        helper.load_and_register_plugins(show_plugins, show_main.cli)
        helper.load_and_register_plugins(config_plugins, config_main.config)
コード例 #2
0
ファイル: main.py プロジェクト: sudhin-arrcus/sonic-utilities
    """Show all console lines and their info include available ttyUSB devices unless specified brief mode"""
    cmd = "consutil show" + (" -b" if brief else "")
    run_command(cmd, display_cmd=verbose)
    return


#
# 'ztp status' command ("show ztp status")
#
@cli.command()
@click.argument('status', required=False, type=click.Choice(["status"]))
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def ztp(status, verbose):
    """Show Zero Touch Provisioning status"""
    if os.path.isfile('/usr/bin/ztp') is False:
        exit("ZTP feature unavailable in this image version")

    cmd = "ztp status"
    if verbose:
        cmd = cmd + " --verbose"
    run_command(cmd, display_cmd=verbose)


# Load plugins and register them
helper = util_base.UtilHelper()
for plugin in helper.load_plugins(plugins):
    helper.register_plugin(plugin, cli)

if __name__ == '__main__':
    cli()