If same config hierarchy is set and deleted in one playbook for delete statement add support to check if the config is present on device or in the playbook. If it is present add delete statement in updated config list.
This commit is contained in:
parent
46503c6d1f
commit
95a75e7c3a
1 changed files with 4 additions and 2 deletions
|
@ -237,7 +237,7 @@ def diff_commands(commands, config):
|
|||
updates = list()
|
||||
visited = set()
|
||||
|
||||
for item in commands:
|
||||
for index, item in enumerate(commands):
|
||||
if len(item) > 0:
|
||||
if not item.startswith('set') and not item.startswith('delete'):
|
||||
raise ValueError('line must start with either `set` or `delete`')
|
||||
|
@ -246,7 +246,9 @@ def diff_commands(commands, config):
|
|||
updates.append(item)
|
||||
|
||||
elif item.startswith('delete'):
|
||||
for entry in config:
|
||||
for entry in config + commands[0:index]:
|
||||
if entry.startswith('set'):
|
||||
entry = entry[4:]
|
||||
if entry.startswith(item[7:]) and item not in visited:
|
||||
updates.append(item)
|
||||
visited.add(item)
|
||||
|
|
Loading…
Reference in a new issue