From 899eddf9e4ca67eaf72735fbe97d5fc52d2f2da1 Mon Sep 17 00:00:00 2001 From: Trishna Guha Date: Fri, 17 Aug 2018 12:59:24 +0530 Subject: [PATCH] fix diff precedence cli_config module (#44295) Signed-off-by: Trishna Guha --- lib/ansible/modules/network/cli/cli_config.py | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/ansible/modules/network/cli/cli_config.py b/lib/ansible/modules/network/cli/cli_config.py index fdbedf7442..d7b74d3b3b 100644 --- a/lib/ansible/modules/network/cli/cli_config.py +++ b/lib/ansible/modules/network/cli/cli_config.py @@ -207,7 +207,25 @@ def run(module, capabilities, connection, candidate, running): elif replace in ('no', 'false', 'False'): replace = False - if capabilities['device_operations']['supports_generate_diff']: + if capabilities['device_operations']['supports_onbox_diff']: + if diff_replace: + module.warn('diff_replace is ignored as the device supports onbox diff') + if diff_match: + module.warn('diff_mattch is ignored as the device supports onbox diff') + if diff_ignore_lines: + module.warn('diff_ignore_lines is ignored as the device supports onbox diff') + + if not isinstance(candidate, list): + candidate = candidate.strip('\n').splitlines() + + kwargs = {'candidate': candidate, 'commit': commit, 'replace': replace, + 'comment': commit_comment} + resp = connection.edit_config(**kwargs) + + if 'diff' in resp: + result['changed'] = True + + elif capabilities['device_operations']['supports_generate_diff']: kwargs = {'candidate': candidate, 'running': running} if diff_match: kwargs.update({'diff_match': diff_match}) @@ -241,24 +259,6 @@ def run(module, capabilities, connection, candidate, running): connection.edit_banner(**kwargs) result['changed'] = True - elif capabilities['device_operations']['supports_onbox_diff']: - if diff_replace: - module.warn('diff_replace is ignored as the device supports onbox diff') - if diff_match: - module.warn('diff_mattch is ignored as the device supports onbox diff') - if diff_ignore_lines: - module.warn('diff_ignore_lines is ignored as the device supports onbox diff') - - if not isinstance(candidate, list): - candidate = candidate.strip('\n').splitlines() - - kwargs = {'candidate': candidate, 'commit': commit, 'replace': replace, - 'comment': commit_comment} - resp = connection.edit_config(**kwargs) - - if 'diff' in resp: - result['changed'] = True - if module._diff: if 'diff' in resp: result['diff'] = {'prepared': resp['diff']}