mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 21:30:22 -07:00
vyos and ios cliconf plugin refactor (#41846)
* vyos and ios cliconf plugin refactor * Refactor vyos cliconf plugin * Change vyos module_utils and vyos_config as per refactor * Minor changes in ios cliconf plugin * Fix unit test failure * Fix sanity issues * Add get_diff to rpc list
This commit is contained in:
parent
9c5d40ff15
commit
773c031d33
8 changed files with 285 additions and 101 deletions
|
@ -133,29 +133,8 @@ def load_config(module, commands, commit=False, comment=None):
|
|||
connection = get_connection(module)
|
||||
|
||||
try:
|
||||
out = connection.edit_config(commands)
|
||||
diff_config, resp = connection.edit_config(candidate=commands, commit=commit, diff=module._diff, comment=comment)
|
||||
except ConnectionError as exc:
|
||||
module.fail_json(msg=to_text(exc))
|
||||
|
||||
diff = None
|
||||
if module._diff:
|
||||
out = connection.get('compare')
|
||||
out = to_text(out, errors='surrogate_or_strict')
|
||||
|
||||
if not out.startswith('No changes'):
|
||||
out = connection.get('show')
|
||||
diff = to_text(out, errors='surrogate_or_strict').strip()
|
||||
|
||||
if commit:
|
||||
try:
|
||||
out = connection.commit(comment)
|
||||
except ConnectionError:
|
||||
connection.discard_changes()
|
||||
module.fail_json(msg='commit failed: %s' % out)
|
||||
else:
|
||||
connection.get('exit')
|
||||
else:
|
||||
connection.discard_changes()
|
||||
|
||||
if diff:
|
||||
return diff
|
||||
return diff_config
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue