mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 05:12:45 +00:00
fixes bug with junos_config module not properly loading config (#5213)
This fixes two issues. First, it fixes an issue with the junos_config module not properly recognizing a file with set commands. The second bug would cause the diff_config() function to raise an exception due to a blank line when splitting the config
This commit is contained in:
committed by
Matt Clay
parent
5a8ebf5953
commit
4dc09e19ea
@@ -217,18 +217,19 @@ def diff_commands(commands, config):
|
||||
updates = list()
|
||||
visited = set()
|
||||
|
||||
for item in commands:
|
||||
if not item.startswith('set') and not item.startswith('delete'):
|
||||
raise ValueError('line must start with either `set` or `delete`')
|
||||
for item in commands.split('\n'):
|
||||
if len(item) > 0:
|
||||
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[4:] not in config:
|
||||
updates.append(item)
|
||||
elif item.startswith('set') and item[4:] not in config:
|
||||
updates.append(item)
|
||||
|
||||
elif item.startswith('delete'):
|
||||
for entry in config:
|
||||
if entry.startswith(item[7:]) and item not in visited:
|
||||
updates.append(item)
|
||||
visited.add(item)
|
||||
elif item.startswith('delete'):
|
||||
for entry in config:
|
||||
if entry.startswith(item[7:]) and item not in visited:
|
||||
updates.append(item)
|
||||
visited.add(item)
|
||||
|
||||
return updates
|
||||
|
||||
|
||||
Reference in New Issue
Block a user