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.
pull/21040/head
Ganesh Nalawade 8 years ago committed by Peter Sprygada
parent 46503c6d1f
commit 95a75e7c3a

@ -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…
Cancel
Save