mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-09 09:54:02 -07:00
Remove cliconf from httpapi connection (#46813)
* Bare minimum rip out cliconf * nxapi changeover * Update documentation, move options * Memoize device_info * Gratuitous rename to underscore use of local api implementation Fixup eos module_utils like nxos * Streamline version and image scans * Expose get_capabilities through module_utils * Add load_config to module_utils * Support rpcs using both args and kwargs * Add get_config for nxos * Add get_diff * module context, pulled from nxapi We could probably do this correctly later * Fix eos issues * Limit connection._sub_plugin to only one plugin
This commit is contained in:
parent
32dbb99bb8
commit
02432565cd
14 changed files with 568 additions and 255 deletions
|
@ -50,8 +50,6 @@ from ansible.module_utils.common._collections_compat import Mapping
|
|||
from ansible.module_utils.network.common.utils import to_list
|
||||
from ansible.module_utils.network.common.config import NetworkConfig, dumps
|
||||
from ansible.plugins.cliconf import CliconfBase, enable_mode
|
||||
from ansible.plugins.connection.network_cli import Connection as NetworkCli
|
||||
from ansible.plugins.connection.httpapi import Connection as HttpApi
|
||||
|
||||
|
||||
class Cliconf(CliconfBase):
|
||||
|
@ -60,20 +58,6 @@ class Cliconf(CliconfBase):
|
|||
super(Cliconf, self).__init__(*args, **kwargs)
|
||||
self._session_support = None
|
||||
|
||||
def send_command(self, command, **kwargs):
|
||||
"""Executes a cli command and returns the results
|
||||
This method will execute the CLI command on the connection and return
|
||||
the results to the caller. The command output will be returned as a
|
||||
string
|
||||
"""
|
||||
if isinstance(self._connection, NetworkCli):
|
||||
resp = super(Cliconf, self).send_command(command, **kwargs)
|
||||
elif isinstance(self._connection, HttpApi):
|
||||
resp = self._connection.send_request(command, **kwargs)
|
||||
else:
|
||||
raise ValueError("Invalid connection type")
|
||||
return resp
|
||||
|
||||
@enable_mode
|
||||
def get_config(self, source='running', format='text', flags=None):
|
||||
options_values = self.get_option_values()
|
||||
|
@ -294,13 +278,8 @@ class Cliconf(CliconfBase):
|
|||
result['device_info'] = self.get_device_info()
|
||||
result['device_operations'] = self.get_device_operations()
|
||||
result.update(self.get_option_values())
|
||||
result['network_api'] = 'cliconf'
|
||||
|
||||
if isinstance(self._connection, NetworkCli):
|
||||
result['network_api'] = 'cliconf'
|
||||
elif isinstance(self._connection, HttpApi):
|
||||
result['network_api'] = 'eapi'
|
||||
else:
|
||||
raise ValueError("Invalid connection type")
|
||||
return json.dumps(result)
|
||||
|
||||
def _get_command_with_output(self, command, output):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue