Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EdgeOS - Intelligently insert set commands if a delete command is specified #40666

Merged
merged 1 commit into from
May 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 13 additions & 2 deletions lib/ansible/modules/network/edgeos/edgeos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,26 @@ def diff_config(commands, config):

updates = list()
visited = set()
delete_commands = [line for line in commands if line.startswith('delete')]

for line in commands:
item = str(line).replace("'", '')

if not item.startswith('set') and not item.startswith('delete'):
raise ValueError('line must start with either `set` or `delete`')

elif item.startswith('set') and item not in config:
updates.append(line)
elif item.startswith('set'):

if item not in config:
updates.append(line)

# If there is a corresponding delete command in the desired config, make sure to append
# the set command even though it already exists in the running config
else:
ditem = re.sub('set', 'delete', item)
for line in delete_commands:
if ditem.startswith(line):
updates.append(item)

elif item.startswith('delete'):
if not config:
Expand Down