From 857200fa7fb0b683b3bc5333376a012d4d175e2c Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Tue, 31 Jul 2018 02:53:29 -0700 Subject: [PATCH] Update cliconf get_config api (#43472) * Change `filter` parameter to `flag` to be in sync with original naming convention --- lib/ansible/module_utils/network/eos/eos.py | 2 +- lib/ansible/module_utils/network/ios/ios.py | 2 +- lib/ansible/module_utils/network/nxos/nxos.py | 2 +- lib/ansible/plugins/cliconf/__init__.py | 4 ++-- lib/ansible/plugins/cliconf/eos.py | 4 ++-- lib/ansible/plugins/cliconf/ios.py | 8 ++++---- lib/ansible/plugins/cliconf/nxos.py | 6 +++--- lib/ansible/plugins/cliconf/vyos.py | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/ansible/module_utils/network/eos/eos.py b/lib/ansible/module_utils/network/eos/eos.py index 61a98e0c407..882bd45ce10 100644 --- a/lib/ansible/module_utils/network/eos/eos.py +++ b/lib/ansible/module_utils/network/eos/eos.py @@ -136,7 +136,7 @@ class Cli: except KeyError: conn = self._get_connection() try: - out = conn.get_config(filter=flags) + out = conn.get_config(flags=flags) except ConnectionError as exc: self._module.fail_json(msg=to_text(exc, errors='surrogate_then_replace')) diff --git a/lib/ansible/module_utils/network/ios/ios.py b/lib/ansible/module_utils/network/ios/ios.py index 4ccee0fbf66..17eb5252647 100644 --- a/lib/ansible/module_utils/network/ios/ios.py +++ b/lib/ansible/module_utils/network/ios/ios.py @@ -111,7 +111,7 @@ def get_config(module, flags=None): except KeyError: connection = get_connection(module) try: - out = connection.get_config(filter=flags) + out = connection.get_config(flags=flags) except ConnectionError as exc: module.fail_json(msg=to_text(exc, errors='surrogate_then_replace')) cfg = to_text(out, errors='surrogate_then_replace').strip() diff --git a/lib/ansible/module_utils/network/nxos/nxos.py b/lib/ansible/module_utils/network/nxos/nxos.py index bc591c44566..2a4b3f0be31 100644 --- a/lib/ansible/module_utils/network/nxos/nxos.py +++ b/lib/ansible/module_utils/network/nxos/nxos.py @@ -140,7 +140,7 @@ class Cli: except KeyError: connection = self._get_connection() try: - out = connection.get_config(filter=flags) + out = connection.get_config(flags=flags) except ConnectionError as exc: self._module.fail_json(msg=to_text(exc, errors='surrogate_then_replace')) diff --git a/lib/ansible/plugins/cliconf/__init__.py b/lib/ansible/plugins/cliconf/__init__.py index 31e67390e17..9485daa5a89 100644 --- a/lib/ansible/plugins/cliconf/__init__.py +++ b/lib/ansible/plugins/cliconf/__init__.py @@ -165,7 +165,7 @@ class CliconfBase(AnsiblePlugin): self.response_logging = False @abstractmethod - def get_config(self, source='running', filter=None, format=None): + def get_config(self, source='running', flag=None, format=None): """Retrieves the specified configuration from the device This method will retrieve the configuration specified by source and @@ -175,7 +175,7 @@ class CliconfBase(AnsiblePlugin): :param source: The configuration source to return from the device. This argument accepts either `running` or `startup` as valid values. - :param filter: For devices that support configuration filtering, this + :param flag: For devices that support configuration filtering, this keyword argument is used to filter the returned configuration. The use of this keyword argument is device dependent adn will be silently ignored on devices that do not support it. diff --git a/lib/ansible/plugins/cliconf/eos.py b/lib/ansible/plugins/cliconf/eos.py index 6267ec8e806..ce1cd219e67 100644 --- a/lib/ansible/plugins/cliconf/eos.py +++ b/lib/ansible/plugins/cliconf/eos.py @@ -75,7 +75,7 @@ class Cliconf(CliconfBase): return resp @enable_mode - def get_config(self, source='running', format='text', filter=None): + def get_config(self, source='running', format='text', flag=None): options_values = self.get_option_values() if format not in options_values['format']: raise ValueError("'format' value %s is invalid. Valid values are %s" % (format, ','.join(options_values['format']))) @@ -88,7 +88,7 @@ class Cliconf(CliconfBase): if format and format is not 'text': cmd += '| %s ' % format - cmd += ' '.join(to_list(filter)) + cmd += ' '.join(to_list(flag)) cmd = cmd.strip() return self.send_command(cmd) diff --git a/lib/ansible/plugins/cliconf/ios.py b/lib/ansible/plugins/cliconf/ios.py index 61379c0250d..bd97bb4ed91 100644 --- a/lib/ansible/plugins/cliconf/ios.py +++ b/lib/ansible/plugins/cliconf/ios.py @@ -37,21 +37,21 @@ from ansible.plugins.cliconf import CliconfBase, enable_mode class Cliconf(CliconfBase): @enable_mode - def get_config(self, source='running', filter=None, format=None): + def get_config(self, source='running', flag=None, format=None): if source not in ('running', 'startup'): return self.invalid_params("fetching configuration from %s is not supported" % source) if format: raise ValueError("'format' value %s is not supported for get_config" % format) - if not filter: - filter = [] + if not flag: + flag = [] if source == 'running': cmd = 'show running-config ' else: cmd = 'show startup-config ' - cmd += ' '.join(to_list(filter)) + cmd += ' '.join(to_list(flag)) cmd = cmd.strip() return self.send_command(cmd) diff --git a/lib/ansible/plugins/cliconf/nxos.py b/lib/ansible/plugins/cliconf/nxos.py index 0e999bde323..2d072b009b5 100644 --- a/lib/ansible/plugins/cliconf/nxos.py +++ b/lib/ansible/plugins/cliconf/nxos.py @@ -131,7 +131,7 @@ class Cliconf(CliconfBase): diff['config_diff'] = dumps(configdiffobjs, 'commands') if configdiffobjs else '' return diff - def get_config(self, source='running', format='text', filter=None): + def get_config(self, source='running', format='text', flag=None): options_values = self.get_option_values() if format not in options_values['format']: raise ValueError("'format' value %s is invalid. Valid values are %s" % (format, ','.join(options_values['format']))) @@ -144,8 +144,8 @@ class Cliconf(CliconfBase): if format and format is not 'text': cmd += '| %s ' % format - if filter: - cmd += ' '.join(to_list(filter)) + if flag: + cmd += ' '.join(to_list(flag)) cmd = cmd.strip() return self.send_command(cmd) diff --git a/lib/ansible/plugins/cliconf/vyos.py b/lib/ansible/plugins/cliconf/vyos.py index 15569fa4c02..746974cf477 100644 --- a/lib/ansible/plugins/cliconf/vyos.py +++ b/lib/ansible/plugins/cliconf/vyos.py @@ -54,7 +54,7 @@ class Cliconf(CliconfBase): return device_info - def get_config(self, filter=None, format=None): + def get_config(self, flag=None, format=None): if format: option_values = self.get_option_values() if format not in option_values['format']: