fixes issue with config parents on eos modules (#21923)

eos_config module wasn't respecting config block path (parents).  This
patch fixes that problem.  Also fixes a number of integration tests
cases

fixes #21903
This commit is contained in:
Peter Sprygada 2017-02-25 16:40:13 -05:00 committed by GitHub
commit 1f9b503e89
11 changed files with 58 additions and 25 deletions

View file

@ -226,6 +226,12 @@ def get_candidate(module):
candidate.add(module.params['lines'], parents=parents)
return candidate
def get_running_config(module):
flags = []
if module.params['defaults'] is True:
flags.append('all')
return get_config(module, flags)
def run(module, result):
match = module.params['match']
replace = module.params['replace']
@ -233,9 +239,10 @@ def run(module, result):
candidate = get_candidate(module)
if match != 'none' and replace != 'config':
config_text = get_config(module)
config_text = get_running_config(module)
config = NetworkConfig(indent=3, contents=config_text)
configobjs = candidate.difference(config, match=match, replace=replace)
path = module.params['parents']
configobjs = candidate.difference(config, match=match, replace=replace, path=path)
else:
configobjs = candidate.items
@ -256,8 +263,10 @@ def run(module, result):
commit = not module.check_mode
response = load_config(module, commands, replace=replace, commit=commit)
if 'diff' in response:
result['diff'] = {'prepared': response['diff']}
if 'session' in response:
result['session'] = response['session']