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:
parent
5a8ebf5953
commit
4dc09e19ea
1 changed files with 11 additions and 10 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue