|
4 | 4 | Script to show LAG and LAG member status in a summary view |
5 | 5 | Example of the output: |
6 | 6 | 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 |
8 | 9 | No. Team Dev Protocol Ports |
9 | 10 | ----- ------------- ---------- --------------------------- |
10 | 11 | 0 PortChannel0 LACP(A)(Up) Ethernet0(D) Ethernet4(S) |
@@ -33,6 +34,9 @@ PORT_CHANNEL_APPL_TABLE_PREFIX = "LAG_TABLE:" |
33 | 34 | PORT_CHANNEL_CFG_TABLE_PREFIX = "PORTCHANNEL|" |
34 | 35 | PORT_CHANNEL_STATUS_FIELD = "oper_status" |
35 | 36 |
|
| 37 | +PORT_CHANNEL_MEMBER_APPL_TABLE_PREFIX = "LAG_MEMBER_TABLE:" |
| 38 | +PORT_CHANNEL_MEMBER_STATUS_FIELD = "status" |
| 39 | + |
36 | 40 | class Teamshow(object): |
37 | 41 | def __init__(self): |
38 | 42 | self.teams = [] |
@@ -60,6 +64,10 @@ class Teamshow(object): |
60 | 64 | full_table_id = PORT_CHANNEL_APPL_TABLE_PREFIX + port_channel_name |
61 | 65 | return self.db.get(self.db.APPL_DB, full_table_id, PORT_CHANNEL_STATUS_FIELD) |
62 | 66 |
|
| 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 | + |
63 | 71 | def get_team_id(self, team): |
64 | 72 | """ |
65 | 73 | Skip the 'PortChannel' prefix and extract the team id. |
@@ -111,16 +119,24 @@ class Teamshow(object): |
111 | 119 | info['ports'] = 'N/A' |
112 | 120 | else: |
113 | 121 | 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 | + |
117 | 131 | self.summary[team_id] = info |
118 | 132 |
|
119 | 133 | def display_summary(self): |
120 | 134 | """ |
121 | 135 | Display the portchannel (team) summary. |
122 | 136 | """ |
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 | + |
124 | 140 | header = ['No.', 'Team Dev', 'Protocol', 'Ports'] |
125 | 141 | output = [] |
126 | 142 | for team_id in natsorted(self.summary): |
|
0 commit comments