@@ -401,13 +401,15 @@ def get_switch_name(config_db):
401
401
sys .exit (STATUS_FAIL )
402
402
403
403
404
- def create_json_dump_per_port_status (db , port_status_dict , muxcable_info_dict , muxcable_health_dict , muxcable_metrics_dict , asic_index , port ):
404
+ def create_json_dump_per_port_status (db , port_status_dict , muxcable_info_dict , muxcable_grpc_dict , muxcable_health_dict , muxcable_metrics_dict , asic_index , port ):
405
405
406
406
res_dict = {}
407
407
status_value = get_value_for_key_in_dict (muxcable_info_dict [asic_index ], port , "state" , "MUX_CABLE_TABLE" )
408
408
port_name = platform_sfputil_helper .get_interface_alias (port , db )
409
409
port_status_dict ["MUX_CABLE" ][port_name ] = {}
410
410
port_status_dict ["MUX_CABLE" ][port_name ]["STATUS" ] = status_value
411
+ gRPC_value = get_value_for_key_in_dict (muxcable_grpc_dict [asic_index ], port , "state" , "MUX_CABLE_TABLE" )
412
+ port_status_dict ["MUX_CABLE" ][port_name ]["SERVER_STATUS" ] = gRPC_value
411
413
health_value = get_value_for_key_in_dict (muxcable_health_dict [asic_index ], port , "state" , "MUX_LINKMGR_TABLE" )
412
414
port_status_dict ["MUX_CABLE" ][port_name ]["HEALTH" ] = health_value
413
415
res_dict = get_hwmode_mux_direction_port (db , port )
@@ -428,14 +430,15 @@ def create_json_dump_per_port_status(db, port_status_dict, muxcable_info_dict, m
428
430
last_switch_end_time = muxcable_metrics_dict [asic_index ].get ("linkmgrd_switch_active_end" )
429
431
port_status_dict ["MUX_CABLE" ][port_name ]["LAST_SWITCHOVER_TIME" ] = last_switch_end_time
430
432
431
- def create_table_dump_per_port_status (db , print_data , muxcable_info_dict , muxcable_health_dict , muxcable_metrics_dict , asic_index , port ):
433
+ def create_table_dump_per_port_status (db , print_data , muxcable_info_dict , muxcable_grpc_dict , muxcable_health_dict , muxcable_metrics_dict , asic_index , port ):
432
434
433
435
print_port_data = []
434
436
res_dict = {}
435
437
436
438
res_dict = get_hwmode_mux_direction_port (db , port )
437
439
status_value = get_value_for_key_in_dict (muxcable_info_dict [asic_index ], port , "state" , "MUX_CABLE_TABLE" )
438
440
#status_value = get_value_for_key_in_tbl(y_cable_asic_table, port, "status")
441
+ gRPC_value = get_value_for_key_in_dict (muxcable_grpc_dict [asic_index ], port , "state" , "MUX_CABLE_TABLE" )
439
442
health_value = get_value_for_key_in_dict (muxcable_health_dict [asic_index ], port , "state" , "MUX_LINKMGR_TABLE" )
440
443
441
444
last_switch_end_time = ""
@@ -447,6 +450,7 @@ def create_table_dump_per_port_status(db, print_data, muxcable_info_dict, muxcab
447
450
port_name = platform_sfputil_helper .get_interface_alias (port , db )
448
451
print_port_data .append (port_name )
449
452
print_port_data .append (status_value )
453
+ print_port_data .append (gRPC_value )
450
454
print_port_data .append (health_value )
451
455
if res_dict [2 ] == "False" :
452
456
hwstatus = "absent"
@@ -510,10 +514,13 @@ def status(db, port, json_output):
510
514
port = platform_sfputil_helper .get_interface_name (port , db )
511
515
512
516
port_table_keys = {}
517
+ appl_db_muxcable_tbl_keys = {}
513
518
port_health_table_keys = {}
514
519
port_metrics_table_keys = {}
515
520
per_npu_statedb = {}
521
+ per_npu_appl_db = {}
516
522
muxcable_info_dict = {}
523
+ muxcable_grpc_dict = {}
517
524
muxcable_health_dict = {}
518
525
muxcable_metrics_dict = {}
519
526
@@ -525,6 +532,11 @@ def status(db, port, json_output):
525
532
per_npu_statedb [asic_id ] = SonicV2Connector (use_unix_socket_path = False , namespace = namespace )
526
533
per_npu_statedb [asic_id ].connect (per_npu_statedb [asic_id ].STATE_DB )
527
534
535
+ per_npu_appl_db [asic_id ] = swsscommon .SonicV2Connector (use_unix_socket_path = False , namespace = namespace )
536
+ per_npu_appl_db [asic_id ].connect (per_npu_appl_db [asic_id ].APPL_DB )
537
+
538
+ appl_db_muxcable_tbl_keys [asic_id ] = per_npu_appl_db [asic_id ].keys (
539
+ per_npu_appl_db [asic_id ].APPL_DB , 'MUX_CABLE_TABLE:*' )
528
540
port_table_keys [asic_id ] = per_npu_statedb [asic_id ].keys (
529
541
per_npu_statedb [asic_id ].STATE_DB , 'MUX_CABLE_TABLE|*' )
530
542
port_health_table_keys [asic_id ] = per_npu_statedb [asic_id ].keys (
@@ -546,17 +558,20 @@ def status(db, port, json_output):
546
558
click .echo ("Got invalid asic index for port {}, cant retreive mux status" .format (port_name ))
547
559
sys .exit (STATUS_FAIL )
548
560
549
- muxcable_info_dict [asic_index ] = per_npu_statedb [asic_index ].get_all (
561
+ muxcable_info_dict [asic_index ] = per_npu_appl_db [asic_id ].get_all (
562
+ per_npu_appl_db [asic_id ].APPL_DB , 'MUX_CABLE_TABLE:{}' .format (port ))
563
+ muxcable_grpc_dict [asic_index ] = per_npu_statedb [asic_index ].get_all (
550
564
per_npu_statedb [asic_index ].STATE_DB , 'MUX_CABLE_TABLE|{}' .format (port ))
551
565
muxcable_health_dict [asic_index ] = per_npu_statedb [asic_index ].get_all (
552
566
per_npu_statedb [asic_index ].STATE_DB , 'MUX_LINKMGR_TABLE|{}' .format (port ))
553
567
muxcable_metrics_dict [asic_index ] = per_npu_statedb [asic_index ].get_all (
554
568
per_npu_statedb [asic_index ].STATE_DB , 'MUX_METRICS_TABLE|{}' .format (port ))
569
+
555
570
if muxcable_info_dict [asic_index ] is not None :
556
- logical_key = "MUX_CABLE_TABLE| {}" .format (port )
571
+ logical_key = "MUX_CABLE_TABLE: {}" .format (port )
557
572
logical_health_key = "MUX_LINKMGR_TABLE|{}" .format (port )
558
573
logical_metrics_key = "MUX_METRICS_TABLE|{}" .format (port )
559
- if logical_key in port_table_keys [asic_index ] and logical_health_key in port_health_table_keys [asic_index ]:
574
+ if logical_key in appl_db_muxcable_tbl_keys [asic_index ] and logical_health_key in port_health_table_keys [asic_index ]:
560
575
561
576
if logical_metrics_key not in port_metrics_table_keys [asic_index ]:
562
577
muxcable_metrics_dict [asic_index ] = {}
@@ -565,18 +580,18 @@ def status(db, port, json_output):
565
580
port_status_dict = {}
566
581
port_status_dict ["MUX_CABLE" ] = {}
567
582
568
- create_json_dump_per_port_status (db , port_status_dict , muxcable_info_dict ,
583
+ create_json_dump_per_port_status (db , port_status_dict , muxcable_info_dict , muxcable_grpc_dict ,
569
584
muxcable_health_dict , muxcable_metrics_dict , asic_index , port )
570
585
571
586
click .echo ("{}" .format (json .dumps (port_status_dict , indent = 4 )))
572
587
sys .exit (STATUS_SUCCESSFUL )
573
588
else :
574
589
print_data = []
575
590
576
- create_table_dump_per_port_status (db , print_data , muxcable_info_dict ,
591
+ create_table_dump_per_port_status (db , print_data , muxcable_info_dict , muxcable_grpc_dict ,
577
592
muxcable_health_dict , muxcable_metrics_dict , asic_index , port )
578
593
579
- headers = ['PORT' , 'STATUS' , 'HEALTH' , 'HWSTATUS' , 'LAST_SWITCHOVER_TIME' ]
594
+ headers = ['PORT' , 'STATUS' , 'SERVER_STATUS' , ' HEALTH' , 'HWSTATUS' , 'LAST_SWITCHOVER_TIME' ]
580
595
581
596
click .echo (tabulate (print_data , headers = headers ))
582
597
sys .exit (STATUS_SUCCESSFUL )
@@ -595,38 +610,42 @@ def status(db, port, json_output):
595
610
port_status_dict ["MUX_CABLE" ] = {}
596
611
for namespace in namespaces :
597
612
asic_id = multi_asic .get_asic_index_from_namespace (namespace )
598
- for key in natsorted (port_table_keys [asic_id ]):
599
- port = key .split ("|" )[1 ]
600
- muxcable_info_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
613
+ for key in natsorted (appl_db_muxcable_tbl_keys [asic_id ]):
614
+ port = key .split (":" )[1 ]
615
+ muxcable_info_dict [asic_id ] = per_npu_appl_db [asic_id ].get_all (
616
+ per_npu_appl_db [asic_id ].APPL_DB , 'MUX_CABLE_TABLE:{}' .format (port ))
617
+ muxcable_grpc_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
601
618
per_npu_statedb [asic_id ].STATE_DB , 'MUX_CABLE_TABLE|{}' .format (port ))
602
619
muxcable_health_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
603
620
per_npu_statedb [asic_id ].STATE_DB , 'MUX_LINKMGR_TABLE|{}' .format (port ))
604
621
muxcable_metrics_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
605
622
per_npu_statedb [asic_id ].STATE_DB , 'MUX_METRICS_TABLE|{}' .format (port ))
606
623
if not muxcable_metrics_dict [asic_id ]:
607
624
muxcable_metrics_dict [asic_id ] = {}
608
- create_json_dump_per_port_status (db , port_status_dict , muxcable_info_dict ,
625
+ create_json_dump_per_port_status (db , port_status_dict , muxcable_info_dict , muxcable_grpc_dict ,
609
626
muxcable_health_dict , muxcable_metrics_dict , asic_id , port )
610
627
611
628
click .echo ("{}" .format (json .dumps (port_status_dict , indent = 4 )))
612
629
else :
613
630
print_data = []
614
631
for namespace in namespaces :
615
632
asic_id = multi_asic .get_asic_index_from_namespace (namespace )
616
- for key in natsorted (port_table_keys [asic_id ]):
617
- port = key .split ("|" )[1 ]
633
+ for key in natsorted (appl_db_muxcable_tbl_keys [asic_id ]):
634
+ port = key .split (":" )[1 ]
635
+ muxcable_info_dict [asic_id ] = per_npu_appl_db [asic_id ].get_all (
636
+ per_npu_appl_db [asic_id ].APPL_DB , 'MUX_CABLE_TABLE:{}' .format (port ))
618
637
muxcable_health_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
619
638
per_npu_statedb [asic_id ].STATE_DB , 'MUX_LINKMGR_TABLE|{}' .format (port ))
620
- muxcable_info_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
639
+ muxcable_grpc_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
621
640
per_npu_statedb [asic_id ].STATE_DB , 'MUX_CABLE_TABLE|{}' .format (port ))
622
641
muxcable_metrics_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
623
642
per_npu_statedb [asic_id ].STATE_DB , 'MUX_METRICS_TABLE|{}' .format (port ))
624
643
if not muxcable_metrics_dict [asic_id ]:
625
644
muxcable_metrics_dict [asic_id ] = {}
626
- create_table_dump_per_port_status (db , print_data , muxcable_info_dict ,
645
+ create_table_dump_per_port_status (db , print_data , muxcable_info_dict , muxcable_grpc_dict ,
627
646
muxcable_health_dict , muxcable_metrics_dict , asic_id , port )
628
647
629
- headers = ['PORT' , 'STATUS' , 'HEALTH' , 'HWSTATUS' ,'LAST_SWITCHOVER_TIME' ]
648
+ headers = ['PORT' , 'STATUS' , 'SERVER_STATUS' , ' HEALTH' , 'HWSTATUS' , 'LAST_SWITCHOVER_TIME' ]
630
649
click .echo (tabulate (print_data , headers = headers ))
631
650
632
651
sys .exit (STATUS_SUCCESSFUL )
0 commit comments