Skip to content

Commit

Permalink
[show] Added alias interface mode support for 'show interfaces counte…
Browse files Browse the repository at this point in the history
…rs ...' command

--- What I did
Fixes sonic-net#2464

--- How I did it
Convert the alias name into interface name for "show interfaces counters -u xxx", "show interfaces counters detailed xxx" and "show interfaces counters rif xxx" subcommands.

--- How to verify it
1. Set interface naming mode to alias.
2. Logout/Login.
3. Verify "show interfaces counters -i Eth1".
4. Verify "show interfaces counters rif Eth1".
5. Verify "show interfaces counters detailed Eth1".
6. Set interface naming mode to default.
7. Repeat step 3~5.

Signed-off-by: Julian Chang - TW <julianc@supermicro.com.tw>
  • Loading branch information
puffc committed Nov 2, 2022
1 parent e8b1dcd commit f6d0c08
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions show/interfaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ def counters(ctx, verbose, period, interface, printall, namespace, display):
if period is not None:
cmd += " -p {}".format(period)
if interface is not None:
interface = try_convert_interfacename_from_alias(ctx, interface)
cmd += " -i {}".format(interface)
else:
cmd += " -s {}".format(display)
Expand Down Expand Up @@ -598,10 +599,13 @@ def rates(verbose, period, namespace, display):
def rif(interface, period, verbose):
"""Show interface counters"""

ctx = click.get_current_context()

cmd = "intfstat"
if period is not None:
cmd += " -p {}".format(period)
if interface is not None:
interface = try_convert_interfacename_from_alias(ctx, interface)
cmd += " -i {}".format(interface)

clicommon.run_command(cmd, display_cmd=verbose)
Expand All @@ -614,10 +618,13 @@ def rif(interface, period, verbose):
def detailed(interface, period, verbose):
"""Show interface counters detailed"""

ctx = click.get_current_context()

cmd = "portstat -l"
if period is not None:
cmd += " -p {}".format(period)
if interface is not None:
interface = try_convert_interfacename_from_alias(ctx, interface)
cmd += " -i {}".format(interface)

clicommon.run_command(cmd, display_cmd=verbose)
Expand Down

0 comments on commit f6d0c08

Please sign in to comment.