Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lab5 sonic-utilities temp #1

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='<new_threshold>', 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='<new_duration>', 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()
47 changes: 47 additions & 0 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down