mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-05 07:49:10 -07:00
Refactor EOS code to use cliconf (#34426)
* WIP Refactor EOS code to use cliconf * Fix connection.get where sendonly is True * Fix pylint issue * Remove return from send_config and various exec_commands Also, removed a few try/except, which are anyways handled in Connection.
This commit is contained in:
parent
477cd3f775
commit
32e7c9bc9c
2 changed files with 59 additions and 47 deletions
|
@ -47,14 +47,18 @@ class Cliconf(CliconfBase):
|
|||
return device_info
|
||||
|
||||
@enable_mode
|
||||
def get_config(self, source='running', format='text'):
|
||||
def get_config(self, source='running', format='text', flags=None):
|
||||
lookup = {'running': 'running-config', 'startup': 'startup-config'}
|
||||
if source not in lookup:
|
||||
return self.invalid_params("fetching configuration from %s is not supported" % source)
|
||||
if format == 'text':
|
||||
cmd = b'show %s' % lookup[source]
|
||||
cmd = b'show %s ' % lookup[source]
|
||||
else:
|
||||
cmd = b'show %s | %s' % (lookup[source], format)
|
||||
|
||||
flags = [] if flags is None else flags
|
||||
cmd += ' '.join(flags)
|
||||
cmd = cmd.strip()
|
||||
return self.send_command(cmd)
|
||||
|
||||
@enable_mode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue