diff --git a/files/build_templates/per_namespace/bgp.service.j2 b/files/build_templates/per_namespace/bgp.service.j2 index b44902c5d0..5ef30a164f 100644 --- a/files/build_templates/per_namespace/bgp.service.j2 +++ b/files/build_templates/per_namespace/bgp.service.j2 @@ -15,6 +15,7 @@ User={{ sonicadmin_user }} ExecStartPre=/usr/local/bin/{{docker_container_name}}.sh start{% if multi_instance == 'true' %} %i{% endif %} ExecStart=/usr/local/bin/{{docker_container_name}}.sh wait{% if multi_instance == 'true' %} %i{% endif %} ExecStop=/usr/local/bin/{{docker_container_name}}.sh stop{% if multi_instance == 'true' %} %i{% endif %} +ExecStopPost=/usr/local/bin/write_standby.py RestartSec=30 diff --git a/files/scripts/write_standby.py b/files/scripts/write_standby.py index 72c11a7ac4..52034f9ffc 100755 --- a/files/scripts/write_standby.py +++ b/files/scripts/write_standby.py @@ -65,6 +65,16 @@ class MuxStateWriter(object): """ return self.config_db.get_keys('TUNNEL')[0] + @property + def is_dualtor(self): + """ + Checks if script is running on a dual ToR system + """ + localhost_key = self.config_db.get_keys('DEVICE_METADATA')[0] + metadata = self.config_db.get_entry('DEVICE_METADATA', localhost_key) + + return 'subtype' in metadata and 'dualtor' in metadata['subtype'].lower() + def get_all_mux_intfs(self): """ Returns a list of all mux cable interfaces @@ -97,11 +107,13 @@ class MuxStateWriter(object): # If we timed out, return False else return True return curr_time - start < timeout - def apply_mux_config(self): """ Writes standby mux state to APP DB for all mux interfaces """ + if not self.is_dualtor: + # If not running on a dual ToR system, take no action + return intfs = self.get_all_mux_intfs() state = 'standby' if self.wait_for_tunnel():