Skip to content

Commit

Permalink
[ycable] add changes for correcting telemetry values for 'active-acti…
Browse files Browse the repository at this point in the history
…ve' (#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 <vdahiya@microsoft.com>
  • Loading branch information
vdahiya12 authored and StormLiangMS committed Mar 7, 2023
1 parent 2cb31c4 commit 6391de0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 9 additions & 3 deletions sonic-ycabled/tests/test_y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6271,8 +6271,10 @@ def test_check_identifier_presence_and_setup_channel(self):
test_db[asic_index], "HW_TABLE1")
hw_mux_cable_tbl_peer[asic_index] = swsscommon.Table(
test_db[asic_index], "HW_TABLE2")
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

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)
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)
assert(rc == None)

@patch('ycable.ycable_utilities.y_cable_helper.logical_port_name_to_physical_port_list', MagicMock(return_value=[0]))
Expand Down Expand Up @@ -6302,8 +6304,10 @@ def test_check_identifier_presence_and_setup_channel_with_mock(self):
test_db[asic_index], "HW_TABLE1")
hw_mux_cable_tbl_peer[asic_index] = swsscommon.Table(
test_db[asic_index], "HW_TABLE2")
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

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)
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)
assert(rc == None)


Expand Down Expand Up @@ -6337,8 +6341,10 @@ def test_check_identifier_presence_and_setup_channel_with_mock_not_none(self):
test_db[asic_index], "HW_TABLE1")
hw_mux_cable_tbl_peer[asic_index] = swsscommon.Table(
test_db[asic_index], "HW_TABLE2")
mux_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "MUX_INFO_TABLE")

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)
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)
assert(rc == None)

@patch('proto_out.linkmgr_grpc_driver_pb2_grpc.DualToRActiveStub', MagicMock(return_value=True))
Expand Down
14 changes: 9 additions & 5 deletions sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def process_loopback_interface_and_get_read_side(loopback_keys):
return -1


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):
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):

global grpc_port_stubs
global grpc_port_channels
Expand Down Expand Up @@ -702,6 +702,7 @@ def check_identifier_presence_and_setup_channel(logical_port_name, port_tbl, hw_
return

channel, stub = setup_grpc_channel_for_port(logical_port_name, soc_ipv4)
post_port_mux_info_to_db(logical_port_name, mux_tbl, asic_index, hw_mux_cable_tbl, 'pseudo-cable')
if channel is not None:
grpc_port_channels[logical_port_name] = channel
helper_logger.log_notice(
Expand Down Expand Up @@ -733,6 +734,7 @@ def setup_grpc_channels(stop_event):
loopback_keys = {}
hw_mux_cable_tbl = {}
hw_mux_cable_tbl_peer = {}
mux_tbl = {}

namespaces = multi_asic.get_front_end_namespaces()
for namespace in namespaces:
Expand All @@ -748,6 +750,8 @@ def setup_grpc_channels(stop_event):
state_db[asic_id], swsscommon.STATE_HW_MUX_CABLE_TABLE_NAME)
hw_mux_cable_tbl_peer[asic_id] = swsscommon.Table(
state_db[asic_id], "HW_MUX_CABLE_TABLE_PEER")
mux_tbl[asic_id] = swsscommon.Table(
state_db[asic_id], "MUX_CABLE_INFO")

if read_side == -1:
read_side = process_loopback_interface_and_get_read_side(loopback_keys)
Expand All @@ -772,7 +776,7 @@ def setup_grpc_channels(stop_event):

if logical_port_name in port_table_keys[asic_index]:
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)
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
else:
# This port does not exist in Port table of config but is present inside
# logical_ports after loading the port_mappings from port_config_file
Expand Down Expand Up @@ -1399,7 +1403,7 @@ def init_ports_status_for_y_cable(platform_sfp, platform_chassis, y_cable_presen
if status and cable_type == "active-active":
grpc_port_stats[logical_port_name] = {}
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)
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
else:
# This port does not exist in Port table of config but is present inside
# logical_ports after loading the port_mappings from port_config_file
Expand Down Expand Up @@ -1469,7 +1473,7 @@ def change_ports_status_for_y_cable_change_event(port_dict, y_cable_presence, st
state_db, port_tbl, y_cable_tbl, static_tbl, mux_tbl, asic_index, logical_port_name, y_cable_presence)
if status and cable_type == "active-active":
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)
logical_port_name, port_tbl, hw_mux_cable_tbl, hw_mux_cable_tbl_peer, asic_index, read_side, mux_tbl, y_cable_presence)
elif value == SFP_STATUS_REMOVED:
helper_logger.log_info("Got SFP deleted ycable event")
check_identifier_presence_and_delete_mux_table_entry(
Expand Down Expand Up @@ -2232,7 +2236,7 @@ def post_port_mux_info_to_db(logical_port_name, mux_tbl, asic_index, y_cable_tbl

for physical_port in physical_port_list:

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

0 comments on commit 6391de0

Please sign in to comment.