Skip to content

Commit e474335

Browse files
authored
[ycabled] fix minor appl_db retrieving logic for update (sonic-net#319)
Signed-off-by: vaibhav-dahiya [email protected] This PR fixes the app DB access fix logic by updating the values causing some failures for ycabled's response for mux probe from linkmgrd. This PR essentially fixes that logic, calling the correct method to access the app DB self.appl_db -> self.table_helper.get_appl_db() Description Motivation and Context How Has This Been Tested? UT and deploying changes to kvm Additional Information (Optional)
1 parent 9b84b58 commit e474335

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed

sonic-ycabled/tests/test_y_cable_helper.py

+22
Original file line numberDiff line numberDiff line change
@@ -5798,3 +5798,25 @@ def test_apply_grpc_secrets_configuration(self, open):
57985798
patched_util.return_value = parsed_data
57995799
rc = apply_grpc_secrets_configuration(None)
58005800
assert(rc == None)
5801+
5802+
5803+
5804+
def test_handle_ycable_active_standby_probe_notification(self):
5805+
5806+
test_db = "TEST_DB"
5807+
status = True
5808+
port_m = "Ethernet0"
5809+
fvp_m = [('command', "probe"), ('read_side', 1), ('cable_type','active-standby'), ('soc_ipv4','192.168.0.1')]
5810+
fvp_dict = {"command": "probe"}
5811+
hw_mux_cable_tbl = {}
5812+
y_cable_response_tbl = {}
5813+
asic_index = 0
5814+
hw_mux_cable_tbl[asic_index] = swsscommon.Table(
5815+
test_db[asic_index], "PORT_INFO_TABLE")
5816+
y_cable_response_tbl[asic_index] = swsscommon.Table(
5817+
test_db[asic_index], "PORT_INFO_TABLE")
5818+
hw_mux_cable_tbl[asic_index].get.return_value = (status, fvp_m)
5819+
5820+
rc = handle_ycable_active_standby_probe_notification("active-standby", fvp_dict, test_db, hw_mux_cable_tbl, port_m, asic_index, y_cable_response_tbl)
5821+
assert(rc == True)
5822+

sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py

+24-14
Original file line numberDiff line numberDiff line change
@@ -3411,6 +3411,29 @@ def handle_hw_mux_cable_table_grpc_notification(fvp, hw_mux_cable_tbl, asic_inde
34113411
helper_logger.log_info("Got a change event on port {} of table {} that does not contain state".format(
34123412
port, swsscommon.APP_HW_MUX_CABLE_TABLE_NAME))
34133413

3414+
3415+
def handle_ycable_active_standby_probe_notification(cable_type, fvp_dict, appl_db, hw_mux_cable_tbl, port_m, asic_index, y_cable_response_tbl):
3416+
3417+
if cable_type == 'active-standby' and "command" in fvp_dict:
3418+
3419+
# check if xcvrd got a probe command
3420+
probe_identifier = fvp_dict["command"]
3421+
3422+
if probe_identifier == "probe":
3423+
3424+
(status, fv) = hw_mux_cable_tbl[asic_index].get(port_m)
3425+
3426+
if status is False:
3427+
helper_logger.log_warning("Could not retreive fieldvalue pairs for {}, inside state_db table {}".format(
3428+
port_m, hw_mux_cable_tbl[asic_index].getTableName()))
3429+
return False
3430+
3431+
mux_port_dict = dict(fv)
3432+
read_side = mux_port_dict.get("read_side")
3433+
update_appdb_port_mux_cable_response_table(port_m, asic_index, appl_db, int(read_side), y_cable_response_tbl)
3434+
3435+
return True
3436+
34143437
def handle_ycable_enable_disable_tel_notification(fvp_m, key):
34153438

34163439
global disable_telemetry
@@ -3576,21 +3599,8 @@ def task_worker(self):
35763599
(status, cable_type) = check_mux_cable_port_type(port_m, self.table_helper.get_port_tbl(), asic_index)
35773600

35783601
if status:
3602+
handle_ycable_active_standby_probe_notification(cable_type, fvp_dict, self.table_helper.get_appl_db(), self.table_helper.get_hw_mux_cable_tbl(), port_m, asic_index, self.table_helper.get_y_cable_response_tbl())
35793603

3580-
if cable_type == 'active-standby' and "command" in fvp_dict:
3581-
3582-
# check if xcvrd got a probe command
3583-
probe_identifier = fvp_dict["command"]
3584-
3585-
if probe_identifier == "probe":
3586-
(status, fv) = self.table_helper.get_hw_mux_cable_tbl()[asic_index].get(port_m)
3587-
if status is False:
3588-
helper_logger.log_warning("Could not retreive fieldvalue pairs for {}, inside state_db table {}".format(
3589-
port_m, self.table_helper.get_hw_mux_cable_tbl()[asic_index].getTableName()))
3590-
continue
3591-
mux_port_dict = dict(fv)
3592-
read_side = mux_port_dict.get("read_side")
3593-
update_appdb_port_mux_cable_response_table(port_m, asic_index, self.appl_db, int(read_side), self.table_helper.get_y_cable_response_tbl())
35943604

35953605
while True:
35963606
(port_m, op_m, fvp_m) = self.table_helper.get_fwd_state_command_tbl()[asic_index].pop()

0 commit comments

Comments
 (0)