Skip to content

Commit 0e81375

Browse files
author
Shuotian Cheng
authored
[teamshow]: Add * to indicate if the state has been synced into database (sonic-net#395)
Although teamd would indicate a team member is selected or not, due to teamsyncd issue, it is possible that the state is not correclty synchronized into the application database. Add this '*' to indicate if the member port's state is not written into the database. Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
1 parent 8d97400 commit 0e81375

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

scripts/teamshow

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
Script to show LAG and LAG member status in a summary view
55
Example of the output:
66
acsadmin@sonic:~$ teamshow
7-
Flags: A - active, I - inactive, Up - up, Dw - down, N/A - Not Available, S - selected, D - deselected
7+
Flags: A - active, I - inactive, Up - up, Dw - down, N/A - Not Available,
8+
S - selected, D - deselected, * - not synced
89
No. Team Dev Protocol Ports
910
----- ------------- ---------- ---------------------------
1011
0 PortChannel0 LACP(A)(Up) Ethernet0(D) Ethernet4(S)
@@ -33,6 +34,9 @@ PORT_CHANNEL_APPL_TABLE_PREFIX = "LAG_TABLE:"
3334
PORT_CHANNEL_CFG_TABLE_PREFIX = "PORTCHANNEL|"
3435
PORT_CHANNEL_STATUS_FIELD = "oper_status"
3536

37+
PORT_CHANNEL_MEMBER_APPL_TABLE_PREFIX = "LAG_MEMBER_TABLE:"
38+
PORT_CHANNEL_MEMBER_STATUS_FIELD = "status"
39+
3640
class Teamshow(object):
3741
def __init__(self):
3842
self.teams = []
@@ -60,6 +64,10 @@ class Teamshow(object):
6064
full_table_id = PORT_CHANNEL_APPL_TABLE_PREFIX + port_channel_name
6165
return self.db.get(self.db.APPL_DB, full_table_id, PORT_CHANNEL_STATUS_FIELD)
6266

67+
def get_portchannel_member_status(self, port_channel_name, port_name):
68+
full_table_id = PORT_CHANNEL_MEMBER_APPL_TABLE_PREFIX + port_channel_name + ":" + port_name
69+
return self.db.get(self.db.APPL_DB, full_table_id, PORT_CHANNEL_MEMBER_STATUS_FIELD)
70+
6371
def get_team_id(self, team):
6472
"""
6573
Skip the 'PortChannel' prefix and extract the team id.
@@ -111,16 +119,24 @@ class Teamshow(object):
111119
info['ports'] = 'N/A'
112120
else:
113121
for port in json_info['ports']:
114-
info['ports'] += port
115-
info['ports'] += '(S)' if json_info['ports'][port]['runner']['selected'] else '(D)'
116-
info['ports'] += ' '
122+
status = self.get_portchannel_member_status(team, port)
123+
selected = json_info["ports"][port]["runner"]["selected"]
124+
125+
info["ports"] += port + "("
126+
info["ports"] += "S" if selected else "D"
127+
if status is None or (status == "enabled" and not selected) or (status == "disabled" and selected):
128+
info["ports"] += "*"
129+
info["ports"] += ") "
130+
117131
self.summary[team_id] = info
118132

119133
def display_summary(self):
120134
"""
121135
Display the portchannel (team) summary.
122136
"""
123-
print "Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available, S - selected, D - deselected"
137+
print("Flags: A - active, I - inactive, Up - up, Dw - Down, N/A - not available,\n"
138+
" S - selected, D - deselected, * - not synced")
139+
124140
header = ['No.', 'Team Dev', 'Protocol', 'Ports']
125141
output = []
126142
for team_id in natsorted(self.summary):

0 commit comments

Comments
 (0)