@@ -277,52 +277,14 @@ def lookup_statedb_and_update_configdb(db, per_npu_statedb, config_db, port, sta
277277 port_status_dict [port_name ] = 'OK'
278278
279279def update_configdb_pck_loss_data (config_db , port , val ):
280- fvs = {}
281280 configdb_state = get_value_for_key_in_config_tbl (config_db , port , "state" , "MUX_CABLE" )
282- fvs ["state" ] = configdb_state
283281 ipv4_value = get_value_for_key_in_config_tbl (config_db , port , "server_ipv4" , "MUX_CABLE" )
284- fvs ["server_ipv4" ] = ipv4_value
285282 ipv6_value = get_value_for_key_in_config_tbl (config_db , port , "server_ipv6" , "MUX_CABLE" )
286- fvs ["server_ipv6" ] = ipv6_value
287- soc_ipv4_value = get_optional_value_for_key_in_config_tbl (config_db , port , "soc_ipv4" , "MUX_CABLE" )
288- if soc_ipv4_value is not None :
289- fvs ["soc_ipv4" ] = soc_ipv4_value
290- cable_type = get_optional_value_for_key_in_config_tbl (config_db , port , "cable_type" , "MUX_CABLE" )
291- if cable_type is not None :
292- fvs ["cable_type" ] = cable_type
293- prober_type_val = get_optional_value_for_key_in_config_tbl (config_db , port , "prober_type" , "MUX_CABLE" )
294- if prober_type_val is not None :
295- fvs ["prober_type" ] = prober_type_val
296283
297- fvs ["pck_loss_data_reset" ] = val
298284 try :
299- config_db .set_entry ("MUX_CABLE" , port , fvs )
300- except ValueError as e :
301- ctx = click .get_current_context ()
302- ctx .fail ("Invalid ConfigDB. Error: {}" .format (e ))
303-
304-
305- def update_configdb_prober_type (config_db , port , val ):
306- fvs = {}
307- configdb_state = get_value_for_key_in_config_tbl (config_db , port , "state" , "MUX_CABLE" )
308- fvs ["state" ] = configdb_state
309- ipv4_value = get_value_for_key_in_config_tbl (config_db , port , "server_ipv4" , "MUX_CABLE" )
310- fvs ["server_ipv4" ] = ipv4_value
311- ipv6_value = get_value_for_key_in_config_tbl (config_db , port , "server_ipv6" , "MUX_CABLE" )
312- fvs ["server_ipv6" ] = ipv6_value
313- soc_ipv4_value = get_optional_value_for_key_in_config_tbl (config_db , port , "soc_ipv4" , "MUX_CABLE" )
314- if soc_ipv4_value is not None :
315- fvs ["soc_ipv4" ] = soc_ipv4_value
316- cable_type = get_optional_value_for_key_in_config_tbl (config_db , port , "cable_type" , "MUX_CABLE" )
317- if cable_type is not None :
318- fvs ["cable_type" ] = cable_type
319- pck_loss_data = get_optional_value_for_key_in_config_tbl (config_db , port , "pck_loss_data_reset" , "MUX_CABLE" )
320- if pck_loss_data is not None :
321- fvs ["pck_loss_data_reset" ] = pck_loss_data
322-
323- fvs ["prober_type" ] = val
324- try :
325- config_db .set_entry ("MUX_CABLE" , port , fvs )
285+ config_db .set_entry ("MUX_CABLE" , port , {"state" : configdb_state ,
286+ "server_ipv4" : ipv4_value , "server_ipv6" : ipv6_value ,
287+ "pck_loss_data_reset" : val })
326288 except ValueError as e :
327289 ctx = click .get_current_context ()
328290 ctx .fail ("Invalid ConfigDB. Error: {}" .format (e ))
@@ -419,73 +381,6 @@ def mode(db, state, port, json_output):
419381 sys .exit (CONFIG_SUCCESSFUL )
420382
421383
422- # 'muxcable' command ("config muxcable probertype hardware/software <port|all>")
423- @muxcable .command ()
424- @click .argument ('probertype' , metavar = '<operation_status>' , required = True , type = click .Choice (["hardware" , "software" ]))
425- @click .argument ('port' , metavar = '<port_name>' , required = True , default = None )
426- @clicommon .pass_db
427- def probertype (db , probertype , port ):
428- """Config muxcable probertype"""
429-
430- port = platform_sfputil_helper .get_interface_name (port , db )
431-
432- port_table_keys = {}
433- y_cable_asic_table_keys = {}
434- per_npu_configdb = {}
435- per_npu_statedb = {}
436-
437- # Getting all front asic namespace and correspding config and state DB connector
438-
439- namespaces = multi_asic .get_front_end_namespaces ()
440- for namespace in namespaces :
441- asic_id = multi_asic .get_asic_index_from_namespace (namespace )
442- # replace these with correct macros
443- per_npu_configdb [asic_id ] = ConfigDBConnector (use_unix_socket_path = True , namespace = namespace )
444- per_npu_configdb [asic_id ].connect ()
445- per_npu_statedb [asic_id ] = SonicV2Connector (use_unix_socket_path = True , namespace = namespace )
446- per_npu_statedb [asic_id ].connect (per_npu_statedb [asic_id ].STATE_DB )
447-
448- port_table_keys [asic_id ] = per_npu_statedb [asic_id ].keys (
449- per_npu_statedb [asic_id ].STATE_DB , 'MUX_CABLE_TABLE|*' )
450-
451- if port is not None and port != "all" :
452-
453- asic_index = None
454- if platform_sfputil is not None :
455- asic_index = platform_sfputil .get_asic_id_for_logical_port (port )
456- if asic_index is None :
457- # TODO this import is only for unit test purposes, and should be removed once sonic_platform_base
458- # is fully mocked
459- import sonic_platform_base .sonic_sfp .sfputilhelper
460- asic_index = sonic_platform_base .sonic_sfp .sfputilhelper .SfpUtilHelper ().get_asic_id_for_logical_port (port )
461- if asic_index is None :
462- click .echo ("Got invalid asic index for port {}, cant retreive mux status" .format (port ))
463- sys .exit (CONFIG_FAIL )
464-
465- if per_npu_statedb [asic_index ] is not None :
466- y_cable_asic_table_keys = port_table_keys [asic_index ]
467- logical_key = "MUX_CABLE_TABLE|{}" .format (port )
468- if logical_key in y_cable_asic_table_keys :
469- update_configdb_prober_type (per_npu_configdb [asic_index ], port , probertype )
470- sys .exit (CONFIG_SUCCESSFUL )
471- else :
472- click .echo ("this is not a valid port {} present on mux_cable" .format (port ))
473- sys .exit (CONFIG_FAIL )
474- else :
475- click .echo ("there is not a valid asic asic-{} table for this asic_index" .format (asic_index ))
476- sys .exit (CONFIG_FAIL )
477-
478- elif port == "all" and port is not None :
479-
480- for namespace in namespaces :
481- asic_id = multi_asic .get_asic_index_from_namespace (namespace )
482- for key in port_table_keys [asic_id ]:
483- logical_port = key .split ("|" )[1 ]
484- update_configdb_prober_type (per_npu_configdb [asic_id ], logical_port , probertype )
485-
486- sys .exit (CONFIG_SUCCESSFUL )
487-
488-
489384# 'muxcable' command ("config muxcable kill-radv <enable|disable> ")
490385@muxcable .command (short_help = "Kill radv service when it is meant to be stopped, so no good-bye packet is sent for ceasing To Be an Advertising Interface" )
491386@click .argument ('knob' , metavar = '<feature_knob>' , required = True , type = click .Choice (["enable" , "disable" ]))
@@ -501,7 +396,8 @@ def kill_radv(db, knob):
501396 mux_lmgrd_cfg_tbl = config_db .get_table ("MUX_LINKMGR" )
502397 config_db .mod_entry ("MUX_LINKMGR" , "SERVICE_MGMT" , {"kill_radv" : "True" if knob == "enable" else "False" })
503398
504- # 'muxcable' command ("config muxcable packetloss reset <port|all>")
399+
400+ #'muxcable' command ("config muxcable packetloss reset <port|all>")
505401@muxcable .command ()
506402@click .argument ('action' , metavar = '<action_name>' , required = True , type = click .Choice (["reset" ]))
507403@click .argument ('port' , metavar = '<port_name>' , required = True , default = None )
0 commit comments