From d7f049ebf0fff0e40a0a8ef5b348d4fb4a89b839 Mon Sep 17 00:00:00 2001 From: Longxiang Lyu <35479537+lolyu@users.noreply.github.com> Date: Thu, 1 Sep 2022 04:10:22 +0800 Subject: [PATCH] [mux] Exit to write `standby` state to `active-active` ports (#11821) [mux] Exit to write standby state to `active-active` ports Signed-off-by: Longxiang Lyu --- files/build_templates/mux.service.j2 | 2 +- files/scripts/write_standby.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/files/build_templates/mux.service.j2 b/files/build_templates/mux.service.j2 index abc04ab30d..ee1f8ce753 100644 --- a/files/build_templates/mux.service.j2 +++ b/files/build_templates/mux.service.j2 @@ -14,7 +14,7 @@ ExecStartPre=/usr/local/bin/mark_dhcp_packet.py ExecStartPre=/usr/bin/{{docker_container_name}}.sh start ExecStart=/usr/bin/{{docker_container_name}}.sh wait ExecStop=/usr/bin/{{docker_container_name}}.sh stop -ExecStopPost=/usr/local/bin/write_standby.py +ExecStopPost=/usr/local/bin/write_standby.py --shutdown mux Restart=always RestartSec=30 diff --git a/files/scripts/write_standby.py b/files/scripts/write_standby.py index 86d50737b1..85b6ee8b04 100755 --- a/files/scripts/write_standby.py +++ b/files/scripts/write_standby.py @@ -178,6 +178,12 @@ if __name__ == '__main__': parser.add_argument('-s', '--active_standby', help='state: intial state for "auto" and/or "manual" config in active-standby mode, default "standby"', type=str, required=False, default='standby') + parser.add_argument('--shutdown', help='write mux state after shutdown other services, supported: mux', + type=str, required=False, choices=['mux']) args = parser.parse_args() - mux_writer = MuxStateWriter(activeactive=args.active_active, activestandby=args.active_standby) + active_active_state = args.active_active + active_standby_state = args.active_standby + if args.shutdown == 'mux': + active_active_state = "standby" + mux_writer = MuxStateWriter(activeactive=active_active_state, activestandby=active_standby_state) mux_writer.apply_mux_config()