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:
Ricardo Carrillo Cruz 2018-01-11 13:33:33 +01:00 committed by GitHub
parent 477cd3f775
commit 32e7c9bc9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 59 additions and 47 deletions

View file

@ -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