@@ -178,6 +178,33 @@ class FabricQueueStat(FabricStat):
178
178
print (tabulate (table , queuestat_header , tablefmt = 'simple' , stralign = 'right' ))
179
179
print ()
180
180
181
+ class FabricReachability (FabricStat ):
182
+ def reachability_print (self ):
183
+ # Connect to database
184
+ self .db = multi_asic .connect_to_all_dbs_for_ns (self .namespace )
185
+ # Get the set of all fabric port keys
186
+ port_keys = self .db .keys (self .db .STATE_DB , FABRIC_PORT_STATUS_TABLE_PREFIX + '*' )
187
+ # Create a new dictionary. The key values are the local port values
188
+ # in integer format. Only ports that have remote port data are added.
189
+ # Only ports that are "up" will be connected to a remote peer.
190
+ port_dict = {}
191
+ for port_key in port_keys :
192
+ port_data = self .db .get_all (self .db .STATE_DB , port_key )
193
+ if "REMOTE_PORT" in port_data :
194
+ port_number = int (port_key .replace ("FABRIC_PORT_TABLE|PORT" , "" ))
195
+ port_dict .update ({port_number : port_data })
196
+ # Create ordered table of port data
197
+ header = ["Local Link" , "Remote Module" , "Remote Link" , "Status" ]
198
+ body = []
199
+ for port_number in sorted (port_dict .keys ()):
200
+ port_data = port_dict [port_number ]
201
+ body .append ((port_number , port_data ["REMOTE_MOD" ], \
202
+ port_data ["REMOTE_PORT" ], port_data ["STATUS" ]))
203
+ if self .namespace :
204
+ print (f"\n { self .namespace } " )
205
+ print (tabulate (body , header , tablefmt = 'simple' , stralign = 'right' ))
206
+ return
207
+
181
208
def main ():
182
209
parser = argparse .ArgumentParser (description = 'Display the fabric port state and counters' ,
183
210
formatter_class = argparse .RawTextHelpFormatter ,
@@ -191,16 +218,25 @@ Examples:
191
218
""" )
192
219
193
220
parser .add_argument ('-q' ,'--queue' , action = 'store_true' , help = 'Display fabric queue stat, otherwise port stat' )
221
+ parser .add_argument ('-r' ,'--reachability' , action = 'store_true' , help = 'Display reachability, otherwise port stat' )
194
222
parser .add_argument ('-n' ,'--namespace' , default = None , help = 'Display fabric ports counters for specific namespace' )
195
223
parser .add_argument ('-e' , '--errors' , action = 'store_true' , help = 'Display errors' )
196
224
197
225
args = parser .parse_args ()
198
226
queue = args .queue
227
+ reachability = args .reachability
199
228
namespace = args .namespace
200
229
errors_only = args .errors
201
230
202
231
def nsStat (ns , errors_only ):
203
- stat = FabricQueueStat (ns ) if queue else FabricPortStat (ns )
232
+ if queue :
233
+ stat = FabricQueueStat (ns )
234
+ elif reachability :
235
+ stat = FabricReachability (ns )
236
+ stat .reachability_print ()
237
+ return
238
+ else :
239
+ stat = FabricPortStat (ns )
204
240
cnstat_dict = stat .get_cnstat_dict ()
205
241
stat .cnstat_print (cnstat_dict , errors_only )
206
242
0 commit comments