def handle_cli_command(arg1, arg2): if arg1 == 'describe': TableEntryManager.describe(arg2) elif arg1 == 'show_tables': TableEntryManager.show_tables(arg2) else: Log.echo("Command not found.")
def describe(manager): data = PrettyTable() manager = TableEntryManager.get(manager=manager) data.field_names = ["Table name", "# table entries"] for table in manager.tables.keys(): t = manager.get_table_entries(table_name=table) data.add_row([table, len(t)]) Log.echo(data)
def describe(): data = PrettyTable() data.field_names = ["MC Address", "Subscribed BFRs", "Domains"] for mc_addr in GroupManager.get_mc_addresses(): data.add_row([ mc_addr, GroupManager.get_bfr_by_mc_addr(mc_addr), GroupManager.get_domains_for_mc_addr(mc_addr) ]) Log.echo(data)
def list_commands(): """ List all commands with info text for help output :return: """ data = PrettyTable() data.field_names = ["Command", "Info"] for k, v in sorted(CLI.prompt_to_info.iteritems()): data.add_row([k, v]) Log.echo(data)
def show_tables(manager): manager = TableEntryManager.get(manager=manager) prettyTables = [] for table in manager.tables.keys(): t = manager.get_table_entries(table_name=table) data = PrettyTable() data.field_names = ["Switch", "Table Name", "Match fields", "Action name", "Action params", "Priority"] for entry in t: data.add_row([entry.switch, table, entry.match_fields, entry.action_name, entry.action_params, entry.priority]) prettyTables.append(data) for table in prettyTables: Log.echo(table)