Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for GCU function modification for HEAD PR #2993

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions generic_config_updater/generic_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def replace(self, target_config):
self.logger.log_notice("Getting current config db.")
old_config = self.config_wrapper.get_config_db_as_json()

# mode from PORT table will be remove from both old_config & target_config to resolve rollback & replace issue
old_config = self.switchport_mode_remove(old_config)
target_config = self.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 +126,21 @@ def replace(self, target_config):

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

@staticmethod
def switchport_mode_remove(config):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add some comments for the background reason for removing the config['PORT'][port]['mode']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added as per suggestion, thanks

"""
This method will check & remove mode attribute in PORT table.
It is to resolve rollback check patch where it failed
due to missing "mode" in patch applier.
"""
current_mode = 'mode'
exisitng_port = 'PORT'
if exisitng_port in config:
for port, port_data in config[exisitng_port].items():
if current_mode in port_data:
del config[exisitng_port][port][current_mode]
return config

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