Fix in eos get_config cliconf api (#38682) (#38720)

If format is passed as None to get_config api, wrong command is
genereted ie. `show running-configuration | None | section interface`.
Add format type in command only if format value is either not `text`
or  `None`.
(cherry picked from commit 88662d0c56)

Update changelog
pull/38734/head
Ganesh Nalawade 8 years ago committed by GitHub
parent fdcbcf313a
commit 0143aa9416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- eos cliconf get_config() format type fix (https://github.com/ansible/ansible/pull/38682)

@ -51,13 +51,12 @@ class Cliconf(CliconfBase):
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]
else:
cmd = b'show %s | %s' % (lookup[source], format)
flags = [] if flags is None else flags
cmd += ' '.join(flags)
cmd = b'show %s ' % lookup[source]
if format and format is not 'text':
cmd += b'| %s ' % format
cmd += ' '.join(to_list(flags))
cmd = cmd.strip()
return self.send_command(cmd)

Loading…
Cancel
Save