From 3d365c5cf8683e043437c5d22657c2057a65c94d Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Fri, 9 Sep 2016 08:46:33 -0400 Subject: [PATCH] adds path kwarg when difference() is called from iosxr_config Adds the path kwarg to handle use cases with exact and strict matching --- network/iosxr/iosxr_config.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/network/iosxr/iosxr_config.py b/network/iosxr/iosxr_config.py index 206b3c6ab85..51a188db6f8 100644 --- a/network/iosxr/iosxr_config.py +++ b/network/iosxr/iosxr_config.py @@ -219,6 +219,12 @@ def check_args(module, warnings): warnings.append('ignoring unnecessary argument replace') if module.params['update'] == 'replace' and not module.params['src']: module.fail_json(msg='Must specify src when update is `replace`') + if module.params['src'] and module.params['match'] not in ['line', 'none']: + module.fail_json(msg='match argument must be set to either `line` or ' + '`none` when src argument is defined') + if module.params['src'] and module.params['replace'] != 'line': + module.fail_json(msg='replace argument must be set to `line` when ' + 'src argument is specified') if module.params['force']: warnings.append('The force argument is deprecated, please use ' 'match=none instead. This argument will be ' @@ -253,12 +259,14 @@ def run(module, result): match = module.params['match'] replace = module.params['replace'] update = module.params['update'] + path = module.params['parents'] candidate = get_candidate(module) if match != 'none' and update != 'replace': config = get_config(module, result) - configobjs = candidate.difference(config, match=match, replace=replace) + configobjs = candidate.difference(config, path=path, match=match, + replace=replace) else: config = None configobjs = candidate.items