Update cliconf get_config api (#43472)
* Change `filter` parameter to `flag` to be in sync with original naming convention
This commit is contained in:
parent
c8fcbdef71
commit
857200fa7f
8 changed files with 15 additions and 15 deletions
|
@ -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'))
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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'))
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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']:
|
||||
|
|
Loading…
Reference in a new issue