|
15 | 15 |
|
16 | 16 | """Driver for JunOS devices.""" |
17 | 17 |
|
| 18 | +from __future__ import unicode_literals |
| 19 | + |
18 | 20 | # import stdlib |
19 | 21 | import re |
20 | 22 | import collections |
|
33 | 35 | import napalm_base.helpers |
34 | 36 | from napalm_base.base import NetworkDriver |
35 | 37 | from napalm_base.utils import string_parsers |
| 38 | +from napalm_base.utils import py23_compat |
36 | 39 | from napalm_base.exceptions import ConnectionException |
37 | 40 | from napalm_base.exceptions import MergeConfigException |
38 | 41 | from napalm_base.exceptions import CommandErrorException |
@@ -948,14 +951,15 @@ def get_mac_address_table(self): |
948 | 951 |
|
949 | 952 | return mac_address_table |
950 | 953 |
|
951 | | - def get_route_to(self, destination='', protocol=''): |
| 954 | + def get_route_to(self, destination=None, protocol=None): |
952 | 955 | """Return route details to a specific destination, learned from a certain protocol.""" |
953 | 956 | routes = {} |
954 | 957 |
|
955 | | - if not isinstance(destination, str): |
| 958 | + if not isinstance(destination, py23_compat.string_types): |
956 | 959 | raise TypeError('Please specify a valid destination!') |
957 | 960 |
|
958 | | - if not isinstance(protocol, str) or protocol.lower() not in ['static', 'bgp', 'isis']: |
| 961 | + if not isinstance(protocol, py23_compat.string_types) or \ |
| 962 | + protocol.lower() not in ('static', 'bgp', 'isis'): |
959 | 963 | raise TypeError("Protocol not supported: {protocol}.".format( |
960 | 964 | protocol=protocol |
961 | 965 | )) |
@@ -1253,6 +1257,10 @@ def get_users(self): |
1253 | 1257 | d[0]: d[1] for d in user_entry[1] if d[1] |
1254 | 1258 | }) |
1255 | 1259 | user_class = user_details.pop('class', '') |
| 1260 | + user_details = { |
| 1261 | + key: py23_compat.text_type(user_details[key]) |
| 1262 | + for key in user_details.keys() |
| 1263 | + } |
1256 | 1264 | level = _JUNOS_CLASS_CISCO_PRIVILEGE_LEVEL_MAP.get(user_class, 0) |
1257 | 1265 | user_details.update({ |
1258 | 1266 | 'level': level |
@@ -1335,11 +1343,11 @@ def get_config(self, retrieve='all'): |
1335 | 1343 |
|
1336 | 1344 | if retrieve in ('candidate', 'all'): |
1337 | 1345 | config = self.device.rpc.get_config(filter_xml=None, options=options) |
1338 | | - rv['candidate'] = config.text.encode('ascii', 'replace') |
| 1346 | + rv['candidate'] = py23_compat.text_type(config.text.encode('ascii', 'replace')) |
1339 | 1347 |
|
1340 | 1348 | if retrieve in ('running', 'all'): |
1341 | 1349 | options['database'] = 'committed' |
1342 | 1350 | config = self.device.rpc.get_config(filter_xml=None, options=options) |
1343 | | - rv['running'] = config.text.encode('ascii', 'replace') |
| 1351 | + rv['running'] = py23_compat.text_type(config.text.encode('ascii', 'replace')) |
1344 | 1352 |
|
1345 | 1353 | return rv |
0 commit comments