Fixes #20412 junos_config delete command fix (#20450)

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:
Ganesh Nalawade 2017-02-04 19:46:16 +05:30 committed by Peter Sprygada
parent 46503c6d1f
commit 95a75e7c3a

View file

@ -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)