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 3 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
11 changes: 11 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 = 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 +125,14 @@ 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

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

Choose a reason for hiding this comment

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

Please extract constants for string 'mode' and 'PORT'

Choose a reason for hiding this comment

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

updated as suggested,thanks

return config

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