Skip to content

Commit

Permalink
Mode removal from config replacer to fix HEAD PR issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sabakram committed Sep 21, 2023
1 parent 3df1f18 commit 88eb058
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions generic_config_updater/generic_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def replace(self, target_config):
self.logger.log_notice("Getting current config db.")
old_config = self.config_wrapper.get_config_db_as_json()

old_config = switchport_mode_remove(old_config)
target_config = switchport_mode_remove(target_config)

self.logger.log_notice("Generating patch between target config and current config db.")
patch = self.patch_wrapper.generate_patch(old_config, target_config)
self.logger.log_debug(f"Generated patch: {patch}.") # debug since the patch will printed again in 'patch_applier.apply'
Expand All @@ -122,6 +125,12 @@ def replace(self, target_config):

self.logger.log_notice("Config replacement completed.")

def switchport_mode_remove(config):
if 'PORT' in config:
for port, port_data in config['PORT'].items():
if 'mode' in port_data:
del config['PORT'][port]['mode']

class FileSystemConfigRollbacker:
def __init__(self,
checkpoints_dir=CHECKPOINTS_DIR,
Expand Down

0 comments on commit 88eb058

Please sign in to comment.