Skip to content

Commit c7cbbb8

Browse files
authored
[ycabled] add capability to enable/disable telemetry (#279)
This PR provides a capability to sonic-utilities CLI to enable/disable telemetry for ycabled. Basically there is a periodic loop for ycabled which posts telemetry data for that configured interval of time(currently 60 sec). This PR diables this data posting, and does not call platform API calls for ycable. This PR is required for the initiative of getting some failover/switchover not get interfered because of sonic-telemetry API calls. The CLI for enabling/disabling telemetry is config muxcable telemetry enable/disable Description Motivation and Context How Has This Been Tested? UT and deploying changes on Arista testbed Signed-off-by: vaibhav-dahiya <[email protected]>
1 parent cc56367 commit c7cbbb8

File tree

2 files changed

+56
-15
lines changed

2 files changed

+56
-15
lines changed

sonic-ycabled/tests/test_y_cable_helper.py

+18
Original file line numberDiff line numberDiff line change
@@ -5331,3 +5331,21 @@ def test_get_grpc_credentials_root(self, open):
53315331
rc = get_grpc_credentials(type, kvp)
53325332

53335333
assert(rc != None)
5334+
5335+
5336+
@patch('ycable.ycable_utilities.y_cable_helper.disable_telemetry')
5337+
def test_handle_ycable_enable_disable_tel_notification(self, patch):
5338+
5339+
fvp_m = {"disable_telemetry": "True"}
5340+
rc = handle_ycable_enable_disable_tel_notification(fvp_m, "Y_CABLE")
5341+
assert(rc == None)
5342+
5343+
def test_handle_ycable_enable_disable_tel_notification_probe(self):
5344+
5345+
fvp_m = {"log_verbosity": "notice"}
5346+
rc = handle_ycable_enable_disable_tel_notification(fvp_m, "Y_CABLE")
5347+
assert(rc == None)
5348+
5349+
fvp_m = {"log_verbosity": "debug"}
5350+
rc = handle_ycable_enable_disable_tel_notification(fvp_m, "Y_CABLE")
5351+
assert(rc == None)

sonic-ycabled/ycable/ycable_utilities/y_cable_helper.py

+38-15
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
y_cable_port_instances = {}
9191
y_cable_port_locks = {}
9292

93+
disable_telemetry = False
9394

9495
Y_CABLE_STATUS_NO_TOR_ACTIVE = 0
9596
Y_CABLE_STATUS_TORA_ACTIVE = 1
@@ -1505,6 +1506,11 @@ def delete_ports_status_for_y_cable():
15051506

15061507
def check_identifier_presence_and_update_mux_info_entry(state_db, mux_tbl, asic_index, logical_port_name):
15071508

1509+
global disable_telemetry
1510+
1511+
if disable_telemetry == True:
1512+
return
1513+
15081514
# Get the namespaces in the platform
15091515
config_db, port_tbl = {}, {}
15101516
namespaces = multi_asic.get_front_end_namespaces()
@@ -3323,6 +3329,35 @@ def handle_hw_mux_cable_table_grpc_notification(fvp, hw_mux_cable_tbl, asic_inde
33233329
helper_logger.log_info("Got a change event on port {} of table {} that does not contain state".format(
33243330
port, swsscommon.APP_HW_MUX_CABLE_TABLE_NAME))
33253331

3332+
def handle_ycable_enable_disable_tel_notification(fvp_m, key):
3333+
3334+
global disable_telemetry
3335+
3336+
if fvp_m:
3337+
3338+
if key != "Y_CABLE":
3339+
return
3340+
3341+
fvp_dict = dict(fvp_m)
3342+
if "log_verbosity" in fvp_dict:
3343+
# check if xcvrd got a probe command
3344+
probe_identifier = fvp_dict["log_verbosity"]
3345+
3346+
if probe_identifier == "debug":
3347+
helper_logger.set_min_log_priority_debug()
3348+
3349+
elif probe_identifier == "notice":
3350+
helper_logger.set_min_log_priority_notice()
3351+
if "disable_telemetry" in fvp_dict:
3352+
# check if xcvrd got a probe command
3353+
enable = fvp_dict["disable_telemetry"]
3354+
3355+
helper_logger.log_notice("Y_CABLE_DEBUG: trying to enable/disable telemetry flag to {}".format(enable))
3356+
if enable == "True":
3357+
disable_telemetry = True
3358+
3359+
elif enable == "False":
3360+
disable_telemetry = False
33263361

33273362
# Thread wrapper class to update y_cable status periodically
33283363
class YCableTableUpdateTask(object):
@@ -3727,22 +3762,10 @@ def task_cli_worker(self):
37273762
if not key:
37283763
break
37293764

3730-
helper_logger.log_notice("Y_CABLE_DEBUG: trying to enable/disable debug logs")
37313765
if fvp_m:
3732-
3733-
if key == "Y_CABLE":
3734-
continue
3735-
3736-
fvp_dict = dict(fvp_m)
3737-
if "log_verbosity" in fvp_dict:
3738-
# check if xcvrd got a probe command
3739-
probe_identifier = fvp_dict["log_verbosity"]
3740-
3741-
if probe_identifier == "debug":
3742-
helper_logger.set_min_log_priority_debug()
3743-
3744-
elif probe_identifier == "notice":
3745-
helper_logger.set_min_log_priority_notice()
3766+
helper_logger.log_notice("Y_CABLE_DEBUG: trying to enable/disable debug logs")
3767+
handle_ycable_enable_disable_tel_notification(fvp_m, 'Y_CABLE')
3768+
break
37463769

37473770
while True:
37483771
# show muxcable hwmode state <port>

0 commit comments

Comments
 (0)