From ff5167a1c4f2289b1c7b5cf23c802fa3ccde673a Mon Sep 17 00:00:00 2001 From: Jing Zhang Date: Mon, 23 Jan 2023 15:49:32 -0800 Subject: [PATCH] [muxcable][config] Add support to enable/disable ceasing to be an advertisement interface when `radv` service is stopped (#2622) This PR is to add CLI support to enable or disable the feature to send out a good-bye packet when radv service is stopped on active-active dualtor devices. sign-off: Jing Zhang zhangjing@microsoft.com --- config/muxcable.py | 16 ++++++++++++++++ tests/muxcable_test.py | 9 +++++++++ 2 files changed, 25 insertions(+) diff --git a/config/muxcable.py b/config/muxcable.py index 5a327f7b9e..ba80cb02af 100644 --- a/config/muxcable.py +++ b/config/muxcable.py @@ -380,6 +380,22 @@ def mode(db, state, port, json_output): sys.exit(CONFIG_SUCCESSFUL) +# 'muxcable' command ("config muxcable kill-radv ") +@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") +@click.argument('knob', metavar='', required=True, type=click.Choice(["enable", "disable"])) +@clicommon.pass_db +def kill_radv(db, knob): + """config muxcable kill radv""" + + namespaces = multi_asic.get_front_end_namespaces() + for namespace in namespaces: + config_db = ConfigDBConnector(use_unix_socket_path=True, namespace=namespace) + config_db.connect() + + mux_lmgrd_cfg_tbl = config_db.get_table("MUX_LINKMGR") + config_db.mod_entry("MUX_LINKMGR", "SERVICE_MGMT", {"kill_radv": "True" if knob == "enable" else "False"}) + + #'muxcable' command ("config muxcable packetloss reset ") @muxcable.command() @click.argument('action', metavar='', required=True, type=click.Choice(["reset"])) diff --git a/tests/muxcable_test.py b/tests/muxcable_test.py index 5a84a65484..b8eb3dce62 100644 --- a/tests/muxcable_test.py +++ b/tests/muxcable_test.py @@ -959,6 +959,15 @@ def test_config_muxcable_packetloss_reset_Ethernet0(self): assert result.exit_code == 0 + def test_config_muxcable_kill_radv_enable(self): + runner = CliRunner() + db = Db() + + result = runner.invoke(config.config.commands["muxcable"].commands["kill-radv"], ["enable"], obj=db) + + assert result.exit_code == 0 + assert result.output == "" + @mock.patch('show.muxcable.delete_all_keys_in_db_table', mock.MagicMock(return_value=0)) @mock.patch('show.muxcable.update_and_get_response_for_xcvr_cmd', mock.MagicMock(return_value={0: 0, 1: "active"}))