-
Notifications
You must be signed in to change notification settings - Fork 0
LAB5 utilities implementation #1
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5871,7 +5871,6 @@ def frequency(ctx, interface_name, frequency): | |
|
|
||
| clicommon.run_command(command) | ||
|
|
||
|
|
||
| # | ||
| # 'tx_power' subcommand ('config interface transceiver tx_power ...') | ||
| # For negative float use:- | ||
|
|
@@ -7157,8 +7156,49 @@ def remove_vrrp_v6(ctx, interface_name, vrrp_id): | |
|
|
||
|
|
||
| # | ||
| # 'vrf' group ('config vrf ...') | ||
| # 'tx_error_status' command ("config tx_tx_error_status") | ||
| # | ||
| @config.group(cls=clicommon.AbbreviationGroup, name='tx_error_status') | ||
| def tx_error_status(): | ||
| pass | ||
|
|
||
|
|
||
| @tx_error_status.command('set') | ||
| @click.option('-t', '--threshold', type=click.IntRange(min=1), | ||
| help='Configure threshold for Tx error state - for all ports') | ||
| @click.option('-p', '--period', type=click.IntRange(min=1), | ||
| help='Configure time period for Tx error state - for all ports') | ||
| @clicommon.pass_db | ||
| @click.pass_context | ||
| def set_tx_error_status(ctx, db ,threshold, period): | ||
| """Configure Tx error status threshold and/or time period""" | ||
| if threshold is None and period is None: | ||
| ctx.fail("Please provide either threshold or time period") | ||
|
|
||
| if threshold is not None: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abelamit FYI. The option validation can be done also using a dedicated validator object: I would recommend to learn the existing solutions available in config/show dirs to master your
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
| db.cfgdb.mod_entry('TX_ERROR_CHECK_TABLE', 'TX_ERROR_CHECK', {'threshold': threshold}) | ||
|
|
||
| if period is not None: | ||
| db.cfgdb.mod_entry('TX_ERROR_CHECK_TABLE', 'TX_ERROR_CHECK', {'time_period': period}) | ||
|
|
||
|
|
||
| @tx_error_status.command('del') | ||
| @click.option('-t', '--threshold', type=bool, | ||
| help='Is delete threshold for Tx error state - for all ports') | ||
| @click.option('-p', '--period', type=bool, | ||
| help='Is delete time period for Tx error state - for all ports') | ||
| @clicommon.pass_db | ||
| @click.pass_context | ||
| def del_tx_error_status(ctx, db, threshold, period): | ||
| """Delete configured Tx error status threshold and/or time period""" | ||
| if threshold is None and period is None: | ||
| ctx.fail("Please provide either threshold or time period") | ||
|
|
||
| if threshold is not None and threshold is True: | ||
| db.cfgdb.mod_entry('TX_ERROR_CHECK_TABLE', 'TX_ERROR_CHECK', {'threshold': None}) | ||
|
|
||
| if period is not None and period is True: | ||
| db.cfgdb.mod_entry('TX_ERROR_CHECK_TABLE', 'TX_ERROR_CHECK', {'time_period': None}) | ||
|
|
||
| @config.group(cls=clicommon.AbbreviationGroup, name='vrf') | ||
| @click.pass_context | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abelamit the best practice in CLI coding is to use the single (first) letter of the entire word, or a capital letter if the duplication is present. If more then two key words are present, the shortcut would be two (first) letters for each of the words:
Example:
The recommended notation is:
Useful stuff:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed; thanks for the reference