@@ -401,13 +401,15 @@ def get_switch_name(config_db):
401401 sys .exit (STATUS_FAIL )
402402
403403
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 ):
405405
406406 res_dict = {}
407407 status_value = get_value_for_key_in_dict (muxcable_info_dict [asic_index ], port , "state" , "MUX_CABLE_TABLE" )
408408 port_name = platform_sfputil_helper .get_interface_alias (port , db )
409409 port_status_dict ["MUX_CABLE" ][port_name ] = {}
410410 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
411413 health_value = get_value_for_key_in_dict (muxcable_health_dict [asic_index ], port , "state" , "MUX_LINKMGR_TABLE" )
412414 port_status_dict ["MUX_CABLE" ][port_name ]["HEALTH" ] = health_value
413415 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
428430 last_switch_end_time = muxcable_metrics_dict [asic_index ].get ("linkmgrd_switch_active_end" )
429431 port_status_dict ["MUX_CABLE" ][port_name ]["LAST_SWITCHOVER_TIME" ] = last_switch_end_time
430432
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 ):
432434
433435 print_port_data = []
434436 res_dict = {}
435437
436438 res_dict = get_hwmode_mux_direction_port (db , port )
437439 status_value = get_value_for_key_in_dict (muxcable_info_dict [asic_index ], port , "state" , "MUX_CABLE_TABLE" )
438440 #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" )
439442 health_value = get_value_for_key_in_dict (muxcable_health_dict [asic_index ], port , "state" , "MUX_LINKMGR_TABLE" )
440443
441444 last_switch_end_time = ""
@@ -447,6 +450,7 @@ def create_table_dump_per_port_status(db, print_data, muxcable_info_dict, muxcab
447450 port_name = platform_sfputil_helper .get_interface_alias (port , db )
448451 print_port_data .append (port_name )
449452 print_port_data .append (status_value )
453+ print_port_data .append (gRPC_value )
450454 print_port_data .append (health_value )
451455 if res_dict [2 ] == "False" :
452456 hwstatus = "absent"
@@ -510,10 +514,13 @@ def status(db, port, json_output):
510514 port = platform_sfputil_helper .get_interface_name (port , db )
511515
512516 port_table_keys = {}
517+ appl_db_muxcable_tbl_keys = {}
513518 port_health_table_keys = {}
514519 port_metrics_table_keys = {}
515520 per_npu_statedb = {}
521+ per_npu_appl_db = {}
516522 muxcable_info_dict = {}
523+ muxcable_grpc_dict = {}
517524 muxcable_health_dict = {}
518525 muxcable_metrics_dict = {}
519526
@@ -525,6 +532,11 @@ def status(db, port, json_output):
525532 per_npu_statedb [asic_id ] = SonicV2Connector (use_unix_socket_path = False , namespace = namespace )
526533 per_npu_statedb [asic_id ].connect (per_npu_statedb [asic_id ].STATE_DB )
527534
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:*' )
528540 port_table_keys [asic_id ] = per_npu_statedb [asic_id ].keys (
529541 per_npu_statedb [asic_id ].STATE_DB , 'MUX_CABLE_TABLE|*' )
530542 port_health_table_keys [asic_id ] = per_npu_statedb [asic_id ].keys (
@@ -546,17 +558,20 @@ def status(db, port, json_output):
546558 click .echo ("Got invalid asic index for port {}, cant retreive mux status" .format (port_name ))
547559 sys .exit (STATUS_FAIL )
548560
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 (
550564 per_npu_statedb [asic_index ].STATE_DB , 'MUX_CABLE_TABLE|{}' .format (port ))
551565 muxcable_health_dict [asic_index ] = per_npu_statedb [asic_index ].get_all (
552566 per_npu_statedb [asic_index ].STATE_DB , 'MUX_LINKMGR_TABLE|{}' .format (port ))
553567 muxcable_metrics_dict [asic_index ] = per_npu_statedb [asic_index ].get_all (
554568 per_npu_statedb [asic_index ].STATE_DB , 'MUX_METRICS_TABLE|{}' .format (port ))
569+
555570 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 )
557572 logical_health_key = "MUX_LINKMGR_TABLE|{}" .format (port )
558573 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 ]:
560575
561576 if logical_metrics_key not in port_metrics_table_keys [asic_index ]:
562577 muxcable_metrics_dict [asic_index ] = {}
@@ -565,18 +580,18 @@ def status(db, port, json_output):
565580 port_status_dict = {}
566581 port_status_dict ["MUX_CABLE" ] = {}
567582
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 ,
569584 muxcable_health_dict , muxcable_metrics_dict , asic_index , port )
570585
571586 click .echo ("{}" .format (json .dumps (port_status_dict , indent = 4 )))
572587 sys .exit (STATUS_SUCCESSFUL )
573588 else :
574589 print_data = []
575590
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 ,
577592 muxcable_health_dict , muxcable_metrics_dict , asic_index , port )
578593
579- headers = ['PORT' , 'STATUS' , 'HEALTH' , 'HWSTATUS' , 'LAST_SWITCHOVER_TIME' ]
594+ headers = ['PORT' , 'STATUS' , 'SERVER_STATUS' , ' HEALTH' , 'HWSTATUS' , 'LAST_SWITCHOVER_TIME' ]
580595
581596 click .echo (tabulate (print_data , headers = headers ))
582597 sys .exit (STATUS_SUCCESSFUL )
@@ -595,38 +610,42 @@ def status(db, port, json_output):
595610 port_status_dict ["MUX_CABLE" ] = {}
596611 for namespace in namespaces :
597612 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 (
601618 per_npu_statedb [asic_id ].STATE_DB , 'MUX_CABLE_TABLE|{}' .format (port ))
602619 muxcable_health_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
603620 per_npu_statedb [asic_id ].STATE_DB , 'MUX_LINKMGR_TABLE|{}' .format (port ))
604621 muxcable_metrics_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
605622 per_npu_statedb [asic_id ].STATE_DB , 'MUX_METRICS_TABLE|{}' .format (port ))
606623 if not muxcable_metrics_dict [asic_id ]:
607624 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 ,
609626 muxcable_health_dict , muxcable_metrics_dict , asic_id , port )
610627
611628 click .echo ("{}" .format (json .dumps (port_status_dict , indent = 4 )))
612629 else :
613630 print_data = []
614631 for namespace in namespaces :
615632 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 ))
618637 muxcable_health_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
619638 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 (
621640 per_npu_statedb [asic_id ].STATE_DB , 'MUX_CABLE_TABLE|{}' .format (port ))
622641 muxcable_metrics_dict [asic_id ] = per_npu_statedb [asic_id ].get_all (
623642 per_npu_statedb [asic_id ].STATE_DB , 'MUX_METRICS_TABLE|{}' .format (port ))
624643 if not muxcable_metrics_dict [asic_id ]:
625644 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 ,
627646 muxcable_health_dict , muxcable_metrics_dict , asic_id , port )
628647
629- headers = ['PORT' , 'STATUS' , 'HEALTH' , 'HWSTATUS' ,'LAST_SWITCHOVER_TIME' ]
648+ headers = ['PORT' , 'STATUS' , 'SERVER_STATUS' , ' HEALTH' , 'HWSTATUS' , 'LAST_SWITCHOVER_TIME' ]
630649 click .echo (tabulate (print_data , headers = headers ))
631650
632651 sys .exit (STATUS_SUCCESSFUL )
0 commit comments