From d5834fcb1b9cb1631545c894d4ab295e71871391 Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Fri, 18 Jun 2021 17:19:09 +0000 Subject: [PATCH] Merged PR 4679112: [write_standby]: Ignore non-auto interfaces [write_standby]: Ignore non-auto interfaces * In the event that `write_standby.py` is used to automatically switchover interfaces when linkmgrd or bgp crashes, ignore any interfaces that are not configured to auto-switch Signed-off-by: Lawrence Lee --- files/scripts/write_standby.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/files/scripts/write_standby.py b/files/scripts/write_standby.py index 52034f9ffc..4c5455803f 100755 --- a/files/scripts/write_standby.py +++ b/files/scripts/write_standby.py @@ -75,11 +75,14 @@ class MuxStateWriter(object): return 'subtype' in metadata and 'dualtor' in metadata['subtype'].lower() - def get_all_mux_intfs(self): + def get_auto_mux_intfs(self): """ - Returns a list of all mux cable interfaces + Returns a list of all mux cable interfaces that are configured to auto-switch """ - return self.config_db.get_keys('MUX_CABLE') + all_intfs = self.config_db.get_table('MUX_CABLE') + auto_intfs = [intf for intf, status in all_intfs.items() + if status['state'].lower() == 'auto'] + return auto_intfs def tunnel_exists(self): """ @@ -114,7 +117,7 @@ class MuxStateWriter(object): if not self.is_dualtor: # If not running on a dual ToR system, take no action return - intfs = self.get_all_mux_intfs() + intfs = self.get_auto_mux_intfs() state = 'standby' if self.wait_for_tunnel(): logger.log_warning("Applying {} state to interfaces {}".format(state, intfs))