Skip to content

Commit 71c6d65

Browse files
authored
[show][cli[show interface portchannel support for Multi ASIC (sonic-net#1005)
Add the multi ASIC specific options for the command show interface portchannel Change the teamshow script to get the port channel information from all the Namespaces - Add support for -n and -d options - This new options are ignored for single ASIC platforms Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
1 parent 2c0ff92 commit 71c6d65

1 file changed

Lines changed: 29 additions & 16 deletions

File tree

show/interfaces/portchannel.py

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import click
21

3-
from tabulate import tabulate
4-
from natsort import natsorted
2+
import os
3+
import sys
54

5+
import click
66
import utilities_common.cli as clicommon
7+
from natsort import natsorted
8+
from tabulate import tabulate
9+
import utilities_common.multi_asic as multi_asic_util
10+
from utilities_common.constants import PORT_CHANNEL_OBJ
711

812
"""
913
Script to show LAG and LAG member status in a summary view
@@ -24,7 +28,6 @@
2428
2529
"""
2630

27-
2831
PORT_CHANNEL_APPL_TABLE_PREFIX = "LAG_TABLE:"
2932
PORT_CHANNEL_CFG_TABLE_PREFIX = "PORTCHANNEL|"
3033
PORT_CHANNEL_STATE_TABLE_PREFIX = "LAG_TABLE|"
@@ -35,21 +38,33 @@
3538
PORT_CHANNEL_MEMBER_STATUS_FIELD = "status"
3639

3740
class Teamshow(object):
38-
def __init__(self, db):
41+
def __init__(self, namespace_option, display_option):
3942
self.teams = []
4043
self.teamsraw = {}
4144
self.summary = {}
42-
self.db = db.db
43-
self.db2 = db
45+
self.err = None
46+
self.db = None
47+
self.multi_asic = multi_asic_util.MultiAsic(display_option, namespace_option)
48+
49+
@multi_asic_util.run_on_multi_asic
50+
def get_teams_info(self):
51+
self.get_portchannel_names()
52+
self.get_teamdctl()
53+
self.get_teamshow_result()
4454

4555
def get_portchannel_names(self):
4656
"""
4757
Get the portchannel names from database.
4858
"""
59+
self.teams = []
4960
team_keys = self.db.keys(self.db.CONFIG_DB, PORT_CHANNEL_CFG_TABLE_PREFIX+"*")
5061
if team_keys is None:
5162
return
52-
self.teams = [key[len(PORT_CHANNEL_CFG_TABLE_PREFIX):] for key in team_keys]
63+
for key in team_keys:
64+
team_name = key[len(PORT_CHANNEL_CFG_TABLE_PREFIX):]
65+
if self.multi_asic.skip_display(PORT_CHANNEL_OBJ, team_name) is True:
66+
continue
67+
self.teams.append(team_name)
5368

5469
def get_portchannel_status(self, port_channel_name):
5570
"""
@@ -120,7 +135,7 @@ def get_teamshow_result(self):
120135
pstate = self.db.get_all(self.db.STATE_DB, PORT_CHANNEL_MEMBER_STATE_TABLE_PREFIX+team+'|'+port)
121136
selected = True if pstate['runner.aggregator.selected'] == "true" else False
122137
if clicommon.get_interface_naming_mode() == "alias":
123-
alias = clicommon.InterfaceAliasConverter(self.db2).name_to_alias(port)
138+
alias = clicommon.InterfaceAliasConverter().name_to_alias(port)
124139
info["ports"] += alias + "("
125140
else:
126141
info["ports"] += port + "("
@@ -146,12 +161,10 @@ def display_summary(self):
146161

147162
# 'portchannel' subcommand ("show interfaces portchannel")
148163
@click.command()
164+
@multi_asic_util.multi_asic_click_options
149165
@click.option('--verbose', is_flag=True, help="Enable verbose output")
150-
@clicommon.pass_db
151-
def portchannel(db, verbose):
166+
def portchannel(namespace, display, verbose):
152167
"""Show PortChannel information"""
153-
team = Teamshow(db)
154-
team.get_portchannel_names()
155-
team.get_teamdctl()
156-
team.get_teamshow_result()
157-
team.display_summary()
168+
team = Teamshow(namespace, display)
169+
team.get_teams_info()
170+
team.display_summary()

0 commit comments

Comments
 (0)