Add fetching default filter in ios cliconf plugin (#42339)
* Add capability to fetch default filter flag in ios cliconf plugin.
This commit is contained in:
parent
f7dbf581b1
commit
75382814f0
2 changed files with 22 additions and 13 deletions
|
@ -93,18 +93,8 @@ def check_args(module, warnings):
|
||||||
|
|
||||||
def get_defaults_flag(module):
|
def get_defaults_flag(module):
|
||||||
connection = get_connection(module)
|
connection = get_connection(module)
|
||||||
out = connection.get('show running-config ?')
|
out = connection.get_defaults_flag()
|
||||||
out = to_text(out, errors='surrogate_then_replace')
|
return to_text(out, errors='surrogate_then_replace').strip()
|
||||||
|
|
||||||
commands = set()
|
|
||||||
for line in out.splitlines():
|
|
||||||
if line.strip():
|
|
||||||
commands.add(line.strip().split()[0])
|
|
||||||
|
|
||||||
if 'all' in commands:
|
|
||||||
return ['all']
|
|
||||||
else:
|
|
||||||
return ['full']
|
|
||||||
|
|
||||||
|
|
||||||
def get_config(module, flags=None):
|
def get_config(module, flags=None):
|
||||||
|
|
|
@ -219,7 +219,7 @@ class Cliconf(CliconfBase):
|
||||||
|
|
||||||
def get_capabilities(self):
|
def get_capabilities(self):
|
||||||
result = dict()
|
result = dict()
|
||||||
result['rpc'] = self.get_base_rpc() + ['edit_banner', 'get_diff', 'run_commands']
|
result['rpc'] = self.get_base_rpc() + ['edit_banner', 'get_diff', 'run_commands', 'get_defaults_flag']
|
||||||
result['network_api'] = 'cliconf'
|
result['network_api'] = 'cliconf'
|
||||||
result['device_info'] = self.get_device_info()
|
result['device_info'] = self.get_device_info()
|
||||||
result['device_operations'] = self.get_device_operations()
|
result['device_operations'] = self.get_device_operations()
|
||||||
|
@ -279,6 +279,25 @@ class Cliconf(CliconfBase):
|
||||||
|
|
||||||
return responses
|
return responses
|
||||||
|
|
||||||
|
def get_defaults_flag(self):
|
||||||
|
"""
|
||||||
|
The method identifies the filter that should be used to fetch running-configuration
|
||||||
|
with defaults.
|
||||||
|
:return: valid default filter
|
||||||
|
"""
|
||||||
|
out = self.get('show running-config ?')
|
||||||
|
out = to_text(out, errors='surrogate_then_replace')
|
||||||
|
|
||||||
|
commands = set()
|
||||||
|
for line in out.splitlines():
|
||||||
|
if line.strip():
|
||||||
|
commands.add(line.strip().split()[0])
|
||||||
|
|
||||||
|
if 'all' in commands:
|
||||||
|
return 'all'
|
||||||
|
else:
|
||||||
|
return 'full'
|
||||||
|
|
||||||
def _extract_banners(self, config):
|
def _extract_banners(self, config):
|
||||||
banners = {}
|
banners = {}
|
||||||
banner_cmds = re.findall(r'^banner (\w+)', config, re.M)
|
banner_cmds = re.findall(r'^banner (\w+)', config, re.M)
|
||||||
|
|
Loading…
Reference in a new issue