mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
refactors eos_config module to use network_cli (#20741)
* update eos_config to use eapi exclusively and remove cli transport * add unit test cases for eos_config * updates action plugin to handle both eapi and network_cli connections
This commit is contained in:
parent
a60c051952
commit
6c89c587cc
6 changed files with 352 additions and 69 deletions
|
@ -19,10 +19,16 @@
|
|||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.plugins.action import ActionBase
|
||||
from ansible.plugins.action.net_config import ActionModule as NetActionModule
|
||||
from ansible.plugins.action.net_config import ActionModule as NetworkActionModule
|
||||
|
||||
class ActionModule(NetActionModule, ActionBase):
|
||||
pass
|
||||
try:
|
||||
from __main__ import display
|
||||
except ImportError:
|
||||
from ansible.utils.display import Display
|
||||
display = Display()
|
||||
|
||||
class ActionModule(NetworkActionModule):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
display.vvvvv('Using connection plugin %s' % self._play_context.connection)
|
||||
return NetworkActionModule.run(self, tmp, task_vars)
|
||||
|
|
|
@ -27,6 +27,7 @@ import glob
|
|||
from ansible.plugins.action.network import ActionModule as _ActionModule
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
||||
from ansible.utils.vars import merge_hash
|
||||
|
||||
|
||||
PRIVATE_KEYS_RE = re.compile('__.+__')
|
||||
|
@ -42,13 +43,17 @@ class ActionModule(_ActionModule):
|
|||
except ValueError as exc:
|
||||
return dict(failed=True, msg=exc.message)
|
||||
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
if self._play_context.connection == 'local':
|
||||
result = self.normal(tmp, task_vars)
|
||||
else:
|
||||
result = super(ActionModule, self).run(tmp, task_vars)
|
||||
|
||||
if self._task.args.get('backup') and result.get('__backup__'):
|
||||
# User requested backup and no error occurred in module.
|
||||
# NOTE: If there is a parameter error, _backup key may not be in results.
|
||||
filepath = self._write_backup(task_vars['inventory_hostname'],
|
||||
result['__backup__'])
|
||||
|
||||
result['backup_path'] = filepath
|
||||
|
||||
# strip out any keys that have two leading and two trailing
|
||||
|
@ -59,6 +64,22 @@ class ActionModule(_ActionModule):
|
|||
|
||||
return result
|
||||
|
||||
def normal(self, tmp=None, task_vars=None):
|
||||
if task_vars is None:
|
||||
task_vars = dict()
|
||||
|
||||
#results = super(ActionModule, self).run(tmp, task_vars)
|
||||
# remove as modules might hide due to nolog
|
||||
#del results['invocation']['module_args']
|
||||
|
||||
results = {}
|
||||
results = merge_hash(results, self._execute_module(tmp=tmp, task_vars=task_vars))
|
||||
|
||||
# hack to keep --verbose from showing all the setup module results
|
||||
if self._task.action == 'setup':
|
||||
results['_ansible_verbose_override'] = True
|
||||
|
||||
return results
|
||||
def _get_working_path(self):
|
||||
cwd = self._loader.get_basedir()
|
||||
if self._task._role is not None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue