mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00: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:
@@ -166,6 +166,7 @@ def load_config(module, commands):
|
||||
connection = get_connection(module)
|
||||
|
||||
try:
|
||||
return connection.edit_config(commands)
|
||||
diff, response = connection.edit_config(commands)
|
||||
return response
|
||||
except ConnectionError as exc:
|
||||
module.fail_json(msg=to_text(exc))
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user