From f9d8faab68fff73c86471dacf9a8f78fcda6a05e Mon Sep 17 00:00:00 2001 From: tshalvi Date: Thu, 8 Dec 2022 12:01:44 +0000 Subject: [PATCH] config CLI and show CLI --- config/main.py | 26 ++++++++++++++++++++++++++ show/main.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/config/main.py b/config/main.py index 004b40bdb4..218a6f4f4b 100644 --- a/config/main.py +++ b/config/main.py @@ -6921,5 +6921,31 @@ def del_subinterface(ctx, subinterface_name): except JsonPatchConflict as e: ctx.fail("{} is invalid vlan subinterface. Error: {}".format(subinterface_name, e)) + +# +# 'txargs_threshold' command +# +@config.command('txargs_threshold') +@click.argument('new_threshold', metavar='', required=True) +def txargs_threshold(new_threshold): + + config_db = ConfigDBConnector() + config_db.connect() + config_db.mod_entry("TX_MONITORS_ARGS", 'config_tx_threshold', + {'threshold': new_threshold}) + +# +# 'txargs_duration' command +# +@config.command('txargs_duration') +@click.argument('new_duration', metavar='', required=True) +def txargs_duration(new_duration): + + config_db = ConfigDBConnector() + config_db.connect() + config_db.mod_entry("TX_MONITORS_ARGS", 'config_tx_duration', + {'duration': new_duration}) + + if __name__ == '__main__': config() diff --git a/show/main.py b/show/main.py index b206b48635..488844b380 100755 --- a/show/main.py +++ b/show/main.py @@ -2029,6 +2029,53 @@ def peer(db, peer_ip): click.echo(tabulate(bfd_body, bfd_headers)) +# +# 'tx_monitor_interface' group ("show tx_monitor_interface ...") +# + +@cli.group(name='tx_monitor_interface', cls=clicommon.AliasedGroup) +def tx_monitor_interface(): + """Show management interface parameters""" + pass + +# 'tx_fields' subcommand ("show tx_monitor_interface tx_fields") +@tx_monitor_interface.command() +def data (): + """Show data configured for tx_monitor interface""" + + config_db = ConfigDBConnector() + config_db.connect() + + # Fetching data from config_db for TX_MONITORS_ARGS + tx_monitor_data = config_db.get_table('TX_MONITORS_ARGS') + for key in natsorted(list(tx_monitor_data.keys())): + click.echo("{0}".format(tx_monitor_data[key])) + + +# +# 'txstate' group ("show txstate ...") +# +@cli.group(cls=clicommon.AliasedGroup) +def txstate(): + """Show details of the txstate sessions""" + pass + +# 'summary' subcommand ("show txstate summary") +@txstate.command() +@clicommon.pass_db +def summary(db): + """Show txstate session information""" + txstate_keys = db.db.get_all(db.db.STATE_DB, "TX_TABLE") + txstate_headers = ["Interface Name", "Tx State"] + txstate_body = [] + if txstate_keys is not None: + for key in sorted(txstate_keys.keys()): + txstate_body.append([key, txstate_keys[key]]) + else: + click.echo("EMPTY MAP") + click.echo(tabulate(txstate_body, txstate_headers, tablefmt="grid")) + + # Load plugins and register them helper = util_base.UtilHelper() helper.load_and_register_plugins(plugins, cli)