Fix use of bytes in cliconf plugins for Python 3 (#37715)

* Remove raw byte-strings from cliconf plugins of supported platforms + edgeos

Remove uses of to_bytes, too

* Update CliConfBase docstring to reflect current position on byte strings
This commit is contained in:
Nathaniel Case 2018-04-17 10:15:21 -04:00 committed by GitHub
commit 3b3c72f3e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 41 additions and 48 deletions

View file

@ -33,13 +33,13 @@ class Cliconf(CliconfBase):
device_info = {}
device_info['network_os'] = 'eos'
reply = self.get(b'show version | json')
reply = self.get('show version | json')
data = json.loads(reply)
device_info['network_os_version'] = data['version']
device_info['network_os_model'] = data['modelName']
reply = self.get(b'show hostname | json')
reply = self.get('show hostname | json')
data = json.loads(reply)
device_info['network_os_hostname'] = data['hostname']
@ -52,9 +52,9 @@ class Cliconf(CliconfBase):
if source not in lookup:
return self.invalid_params("fetching configuration from %s is not supported" % source)
cmd = b'show %s ' % lookup[source]
cmd = 'show %s ' % lookup[source]
if format and format is not 'text':
cmd += b'| %s ' % format
cmd += '| %s ' % format
cmd += ' '.join(to_list(flags))
cmd = cmd.strip()
@ -62,7 +62,7 @@ class Cliconf(CliconfBase):
@enable_mode
def edit_config(self, command):
for cmd in chain([b'configure'], to_list(command), [b'end']):
for cmd in chain(['configure'], to_list(command), ['end']):
self.send_command(cmd)
def get(self, command, prompt=None, answer=None, sendonly=False):