Skip to content

Commit

Permalink
fixed vyos_config smart diffing ... incorrectly applying to children
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaelin committed Aug 1, 2021
1 parent b864842 commit e988518
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/cliconf_utils/vyosconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ def diff_to(self, other, structure):
(subset, subdel) = self.diff_to(other[key], structure[key])
for s in subset:
toset.append(quoted_key + " " + s)
if KEEP_EXISTING_VALUES not in other[key]:
for d in subdel:
todel.append(quoted_key + " " + d)
for d in subdel:
todel.append(quoted_key + " " + d)
else:
# keys only in this, pls del
todel.append(quoted_key)
# keys only in this, delete if KEEP_EXISTING_VALUES not set
if KEEP_EXISTING_VALUES not in other:
todel.append(quoted_key)
continue # del
for (key, value) in other.items():
if key == KEEP_EXISTING_VALUES:
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/cliconf/test_utils_vyosconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ def test_diff_commands_to(self):
["delete a b 'c a'", "set a b 'a c'"],
)

self.assertListEqual(
VyosConf(
["set a b c d", "set a b c e", "set a b d"]
).diff_commands_to(VyosConf(["set a b c d", "set a b ..."])),
["delete a b c e"],
)


if __name__ == "__main__":
unittest.main()

0 comments on commit e988518

Please sign in to comment.