Skip to content

Commit 10bc119

Browse files
vdahiya12yxieca
authored andcommitted
[ycable] add changes for correcting telemetry values for 'active-active' (#341)
* [ycable] add changes for correcting telemetry values for 'active-active' This change creates unknown, N/A values for active-standby cable types for active-active type cable. Since streaming telemetry today looks for both active-active and active-standby for posting values to State DB, this change introduces a one time posting of fields with 'pseudo-cable' type when channels are attempted to be created by ycabled. Description Motivation and Context How Has This Been Tested? UT and posting the changes on test device. Signed-off-by: vaibhav-dahiya <[email protected]>
1 parent 7ee7805 commit 10bc119

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

sonic-ycabled/tests/test_y_cable_helper.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -6271,8 +6271,10 @@ def test_check_identifier_presence_and_setup_channel(self):
62716271
test_db[asic_index], "HW_TABLE1")
62726272
hw_mux_cable_tbl_peer[asic_index] = swsscommon.Table(
62736273
test_db[asic_index], "HW_TABLE2")
6274+
mux_tbl[asic_index] = swsscommon.Table(
6275+
test_db[asic_index], "MUX_INFO_TABLE")
62746276

6275-
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
6277+
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
62766278
assert(rc == None)
62776279

62786280
@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
@@ -6302,8 +6304,10 @@ def test_check_identifier_presence_and_setup_channel_with_mock(self):
63026304
test_db[asic_index], "HW_TABLE1")
63036305
hw_mux_cable_tbl_peer[asic_index] = swsscommon.Table(
63046306
test_db[asic_index], "HW_TABLE2")
6307+
mux_tbl[asic_index] = swsscommon.Table(
6308+
test_db[asic_index], "MUX_INFO_TABLE")
63056309

6306-
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
6310+
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
63076311
assert(rc == None)
63086312

63096313

@@ -6337,8 +6341,10 @@ def test_check_identifier_presence_and_setup_channel_with_mock_not_none(self):
63376341
test_db[asic_index], "HW_TABLE1")
63386342
hw_mux_cable_tbl_peer[asic_index] = swsscommon.Table(
63396343
test_db[asic_index], "HW_TABLE2")
6344+
mux_tbl[asic_index] = swsscommon.Table(
6345+
test_db[asic_index], "MUX_INFO_TABLE")
63406346

6341-
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
6347+
rc = check_identifier_presence_and_setup_channel("Ethernet0", port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
63426348
assert(rc == None)
63436349

63446350
@patch('proto_out.linkmgr_grpc_driver_pb2_grpc.DualToRActiveStub', MagicMock(return_value=True))

sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ def process_loopback_interface_and_get_read_side(loopback_keys):
663663
return -1
664664

665665

666-
def check_identifier_presence_and_setup_channel(logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence):
666+
def check_identifier_presence_and_setup_channel(logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence):
667667

668668
global grpc_port_stubs
669669
global grpc_port_channels
@@ -702,6 +702,7 @@ def check_identifier_presence_and_setup_channel(logical_port_name, port_tbl, hw_
702702
return
703703

704704
channel, stub = setup_grpc_channel_for_port(logical_port_name, soc_ipv4)
705+
post_port_mux_info_to_db(logical_port_name, mux_tbl, asic_index, hw_mux_cable_tbl, 'pseudo-cable')
705706
if channel is not None:
706707
grpc_port_channels[logical_port_name] = channel
707708
helper_logger.log_notice(
@@ -733,6 +734,7 @@ def setup_grpc_channels(stop_event):
733734
loopback_keys = {}
734735
hw_mux_cable_tbl = {}
735736
hw_mux_cable_tbl_peer = {}
737+
mux_tbl = {}
736738

737739
namespaces = multi_asic.get_front_end_namespaces()
738740
for namespace in namespaces:
@@ -748,6 +750,8 @@ def setup_grpc_channels(stop_event):
748750
state_db[asic_id], swsscommon.STATE_HW_MUX_CABLE_TABLE_NAME)
749751
hw_mux_cable_tbl_peer[asic_id] = swsscommon.Table(
750752
state_db[asic_id], "HW_MUX_CABLE_TABLE_PEER")
753+
mux_tbl[asic_id] = swsscommon.Table(
754+
state_db[asic_id], "MUX_CABLE_INFO")
751755

752756
if read_side == -1:
753757
read_side = process_loopback_interface_and_get_read_side(loopback_keys)
@@ -772,7 +776,7 @@ def setup_grpc_channels(stop_event):
772776

773777
if logical_port_name in port_table_keys[asic_index]:
774778
check_identifier_presence_and_setup_channel(
775-
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
779+
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
776780
else:
777781
# This port does not exist in Port table of config but is present inside
778782
# logical_ports after loading the port_mappings from port_config_file
@@ -1399,7 +1403,7 @@ def init_ports_status_for_y_cable(platform_sfp, platform_chassis, y_cable_presen
13991403
if status and cable_type == "active-active":
14001404
grpc_port_stats[logical_port_name] = {}
14011405
check_identifier_presence_and_setup_channel(
1402-
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
1406+
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
14031407
else:
14041408
# This port does not exist in Port table of config but is present inside
14051409
# logical_ports after loading the port_mappings from port_config_file
@@ -1469,7 +1473,7 @@ def change_ports_status_for_y_cable_change_event(port_dict, y_cable_presence, st
14691473
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
14701474
if status and cable_type == "active-active":
14711475
check_identifier_presence_and_setup_channel(
1472-
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, y_cable_presence)
1476+
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
14731477
elif value == SFP_STATUS_REMOVED:
14741478
helper_logger.log_info("Got SFP deleted ycable event")
14751479
check_identifier_presence_and_delete_mux_table_entry(
@@ -2232,7 +2236,7 @@ def post_port_mux_info_to_db(logical_port_name, mux_tbl, asic_index, y_cable_tbl
22322236

22332237
for physical_port in physical_port_list:
22342238

2235-
if not y_cable_wrapper_get_presence(physical_port):
2239+
if not y_cable_wrapper_get_presence(physical_port) or cable_type == 'pseudo-cable':
22362240
mux_info_dict = get_muxcable_info_without_presence()
22372241
elif cable_type == 'active-active':
22382242
helper_logger.log_warning("Error: trying to post mux info without presence of port {}".format(logical_port_name))

0 commit comments

Comments
 (0)