Skip to content

Commit

Permalink
resolve comment
Browse files Browse the repository at this point in the history
  • Loading branch information
wen587 committed Aug 8, 2022
1 parent a2c3abf commit 96ba055
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
12 changes: 5 additions & 7 deletions generic_config_updater/change_applier.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ def apply(self, change):
ret = self._services_validate(run_data, upd_data, upd_keys)
if not ret:
run_data = self._get_running_config()
upd_data = self.get_config_without_backend_tables(upd_data)
run_data = self.get_config_without_backend_tables(run_data)
self.remove_backend_tables_from_config(upd_data)
self.remove_backend_tables_from_config(run_data)
if upd_data != run_data:
self._report_mismatch(run_data, upd_data)
ret = -1
Expand All @@ -157,11 +157,9 @@ def apply(self, change):
return ret


def get_config_without_backend_tables(self, data):
cropped_data = {
k: v for k, v in data.items() if k not in self.backend_tables
}
return cropped_data
def remove_backend_tables_from_config(self, data):
for key in self.backend_tables:
data.pop(key, None)


def _get_running_config(self):
Expand Down
4 changes: 2 additions & 2 deletions generic_config_updater/generic_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def apply(self, patch):
# Validate config updated successfully
self.logger.log_notice("Verifying patch updates are reflected on ConfigDB.")
new_config = self.config_wrapper.get_config_db_as_json()
target_config = self.changeapplier.get_config_without_backend_tables(target_config)
new_config = self.changeapplier.get_config_without_backend_tables(new_config)
self.changeapplier.remove_backend_tables_from_config(target_config)
self.changeapplier.remove_backend_tables_from_config(new_config)
if not(self.patch_wrapper.verify_same_json(target_config, new_config)):
raise GenericConfigUpdaterError(f"After applying patch to config, there are still some parts not updated")

Expand Down
2 changes: 0 additions & 2 deletions tests/generic_config_updater/generic_updater_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ def __create_patch_applier(self,

changeapplier = Mock()
changeapplier.apply.side_effect = create_side_effect_dict({(str(changes[0]),): 0, (str(changes[1]),): 0})
changeapplier.get_config_without_backend_tables.side_effect = \
[Files.CONFIG_DB_AFTER_MULTI_PATCH, Files.CONFIG_DB_AFTER_MULTI_PATCH]

return gu.PatchApplier(patchsorter, changeapplier, config_wrapper, patch_wrapper)

Expand Down

0 comments on commit 96ba055

Please sign in to comment.