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 (#2468)

Fixes #2464

#### What I did
This change fixed "show interfaces counters xxx" output nothing when naming mode is alias. 

#### 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. Logout/Login
8. Repeat step 3~5.
  • Loading branch information
puffc authored May 5, 2023
1 parent 589375f commit 1097373
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 @@ -578,6 +578,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 @@ -643,10 +644,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 @@ -659,10 +663,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 1097373

Please sign in to comment.