[Python-modules-commits] [napalm-iosxr] 01/03: Import napalm-iosxr_0.4.5.orig.tar.gz

Vincent Bernat bernat at moszumanska.debian.org
Sun Jan 8 17:19:49 UTC 2017


This is an automated email from the git hooks/post-receive script.

bernat pushed a commit to branch master
in repository napalm-iosxr.

commit c36c2b3fcbbb9920526db3868b278a3f22591785
Author: Vincent Bernat <bernat at debian.org>
Date:   Sun Jan 8 18:16:36 2017 +0100

    Import napalm-iosxr_0.4.5.orig.tar.gz
---
 PKG-INFO                          |   2 +-
 napalm_iosxr.egg-info/PKG-INFO    |   2 +-
 napalm_iosxr.egg-info/SOURCES.txt |   1 +
 napalm_iosxr/constants.py         |  23 ++++++++
 napalm_iosxr/iosxr.py             | 115 +++++++++++++++++++-------------------
 setup.cfg                         |   7 ++-
 setup.py                          |   2 +-
 test/unit/conftest.py             |   9 ++-
 8 files changed, 97 insertions(+), 64 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index e4387e5..ac85b3a 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: napalm-iosxr
-Version: 0.4.2
+Version: 0.4.5
 Summary: Network Automation and Programmability Abstraction Layer with Multivendor support
 Home-page: https://github.com/napalm-automation/napalm-iosxr
 Author: David Barroso, Mircea Ulinic
diff --git a/napalm_iosxr.egg-info/PKG-INFO b/napalm_iosxr.egg-info/PKG-INFO
index e4387e5..ac85b3a 100644
--- a/napalm_iosxr.egg-info/PKG-INFO
+++ b/napalm_iosxr.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: napalm-iosxr
-Version: 0.4.2
+Version: 0.4.5
 Summary: Network Automation and Programmability Abstraction Layer with Multivendor support
 Home-page: https://github.com/napalm-automation/napalm-iosxr
 Author: David Barroso, Mircea Ulinic
diff --git a/napalm_iosxr.egg-info/SOURCES.txt b/napalm_iosxr.egg-info/SOURCES.txt
index ec19830..d0e02df 100644
--- a/napalm_iosxr.egg-info/SOURCES.txt
+++ b/napalm_iosxr.egg-info/SOURCES.txt
@@ -3,6 +3,7 @@ requirements.txt
 setup.cfg
 setup.py
 napalm_iosxr/__init__.py
+napalm_iosxr/constants.py
 napalm_iosxr/iosxr.py
 napalm_iosxr.egg-info/PKG-INFO
 napalm_iosxr.egg-info/SOURCES.txt
diff --git a/napalm_iosxr/constants.py b/napalm_iosxr/constants.py
new file mode 100644
index 0000000..64111a5
--- /dev/null
+++ b/napalm_iosxr/constants.py
@@ -0,0 +1,23 @@
+"""Constants for the IOS-XR driver."""
+
+from __future__ import unicode_literals
+
+from napalm_base.constants import *  # noqa
+
+SR_638170159_SOLVED = False
+# this flag says if the Cisco TAC SR 638170159
+# has been solved
+#
+# "XML Agent Does not retrieve correct BGP routes data"
+# is a weird bug reported on 2016-02-22 22:54:21
+# briefly, all BGP routes are handled by the XML agent
+# in such a way they have the following details:
+#
+# - all neighbors are 0.0.0.0
+# - all routes are 0.0.0.0/0
+# - all RD = 0000000000000000
+#
+# because of this none of the data retrieved
+# from the BGP oper is usable thus has direct implications
+# in our implementation of `get_route_to` when retrieving
+# the BGP protocol specific attributes.
diff --git a/napalm_iosxr/iosxr.py b/napalm_iosxr/iosxr.py
index d6a1221..83304ea 100644
--- a/napalm_iosxr/iosxr.py
+++ b/napalm_iosxr/iosxr.py
@@ -33,13 +33,14 @@ from pyIOSXR.exceptions import InvalidInputError
 
 # import NAPALM base
 import napalm_base.helpers
-import napalm_base.constants as C
+import napalm_iosxr.constants as C
 from napalm_base.base import NetworkDriver
 from napalm_base.utils import py23_compat
 from napalm_base.exceptions import ConnectionException
 from napalm_base.exceptions import MergeConfigException
 from napalm_base.exceptions import ReplaceConfigException
 from napalm_base.exceptions import CommandTimeoutException
+from napalm_base.utils.py23_compat import text_type
 
 
 class IOSXRDriver(NetworkDriver):
@@ -68,7 +69,7 @@ class IOSXRDriver(NetworkDriver):
         try:
             self.device.open()
         except ConnectError as conn_err:
-            raise ConnectionException(conn_err.message)
+            raise ConnectionException(conn_err.args[0])
 
     def close(self):
         self.device.close()
@@ -89,7 +90,7 @@ class IOSXRDriver(NetworkDriver):
         except InvalidInputError as e:
             self.pending_changes = False
             self.replace = False
-            raise ReplaceConfigException(e.message)
+            raise ReplaceConfigException(e.args[0])
 
     def load_merge_candidate(self, filename=None, config=None):
         self.pending_changes = True
@@ -102,7 +103,7 @@ class IOSXRDriver(NetworkDriver):
         except InvalidInputError as e:
             self.pending_changes = False
             self.replace = False
-            raise MergeConfigException(e.message)
+            raise MergeConfigException(e.args[0])
 
     def compare_config(self):
         if not self.pending_changes:
@@ -153,16 +154,16 @@ class IOSXRDriver(NetworkDriver):
         platform_attr_tree = facts_rpc_reply.xpath(platform_attr_xpath)[0]
 
         hostname = napalm_base.helpers.convert(
-            unicode, napalm_base.helpers.find_txt(system_time_tree, 'Hostname'))
+            text_type, napalm_base.helpers.find_txt(system_time_tree, 'Hostname'))
         uptime = napalm_base.helpers.convert(
             int, napalm_base.helpers.find_txt(system_time_tree, 'Uptime'), -1)
         serial = napalm_base.helpers.convert(
-            unicode, napalm_base.helpers.find_txt(platform_attr_tree, 'SerialNumber'))
+            text_type, napalm_base.helpers.find_txt(platform_attr_tree, 'SerialNumber'))
         os_version = napalm_base.helpers.convert(
-            unicode, napalm_base.helpers.find_txt(platform_attr_tree, 'SoftwareRevision'))
+            text_type, napalm_base.helpers.find_txt(platform_attr_tree, 'SoftwareRevision'))
         model = napalm_base.helpers.convert(
-            unicode, napalm_base.helpers.find_txt(platform_attr_tree, 'ModelName'))
-        interface_list = self.get_interfaces().keys()
+            text_type, napalm_base.helpers.find_txt(platform_attr_tree, 'ModelName'))
+        interface_list = sorted(list(self.get_interfaces().keys()))
 
         facts.update({
             'os_version': os_version,
@@ -191,7 +192,8 @@ class IOSXRDriver(NetworkDriver):
 
         interfaces_rpc_request = '<Get><Operational><Interfaces/></Operational></Get>'
 
-        interfaces_rpc_reply = ETREE.fromstring(self.device.make_rpc_call(interfaces_rpc_request))
+        interfaces_rpc_reply = ETREE.fromstring(
+            self.device.make_rpc_call(interfaces_rpc_request))
 
         for interface_tree in interfaces_rpc_reply.xpath('.//Interfaces/InterfaceTable/Interface'):
             interface_name = napalm_base.helpers.find_txt(interface_tree, 'Naming/InterfaceName')
@@ -319,12 +321,12 @@ class IOSXRDriver(NetworkDriver):
 
             if vrf == "global":
                 this_vrf['router_id'] = napalm_base.helpers.convert(
-                    unicode, napalm_base.helpers.find_txt(result_tree,
+                    text_type, napalm_base.helpers.find_txt(result_tree,
                         'Get/Operational/BGP/InstanceTable/Instance/InstanceActive/DefaultVRF\
                         /GlobalProcessInfo/VRF/RouterID'))
             else:
                 this_vrf['router_id'] = napalm_base.helpers.convert(
-                    unicode, napalm_base.helpers.find_txt(result_tree,
+                    text_type, napalm_base.helpers.find_txt(result_tree,
                         'Get/Operational/BGP/InstanceTable/Instance/InstanceActive/VRFTable/VRF\
                         /GlobalProcessInfo/VRF/RouterID'))
 
@@ -337,13 +339,13 @@ class IOSXRDriver(NetworkDriver):
                 this_neighbor['remote_as'] = napalm_base.helpers.convert(
                     int, napalm_base.helpers.find_txt(neighbor, 'RemoteAS'))
                 this_neighbor['remote_id'] = napalm_base.helpers.convert(
-                    unicode, napalm_base.helpers.find_txt(neighbor, 'RouterID'))
+                    text_type, napalm_base.helpers.find_txt(neighbor, 'RouterID'))
 
                 if napalm_base.helpers.find_txt(neighbor, 'ConnectionAdminStatus') is "1":
                     this_neighbor['is_enabled'] = True
                 try:
                     this_neighbor['description'] = napalm_base.helpers.convert(
-                        unicode, napalm_base.helpers.find_txt(neighbor, 'Description'))
+                        text_type, napalm_base.helpers.find_txt(neighbor, 'Description'))
                 except AttributeError:
                     this_neighbor['description'] = u''
 
@@ -561,7 +563,7 @@ class IOSXRDriver(NetworkDriver):
         #
 
         slot_list = set()
-        for category, slot in active_modules.iteritems():
+        for category, slot in active_modules.items():
             slot_list |= set(slot)
 
         if not is_xrv:
@@ -600,9 +602,9 @@ class IOSXRDriver(NetworkDriver):
 
             lldp[local_interface].append({
                 'hostname': napalm_base.helpers.convert(
-                    unicode, n.split()[0]),
+                    text_type, n.split()[0]),
                 'port': napalm_base.helpers.convert(
-                    unicode, n.split()[4])
+                    text_type, n.split()[4])
             })
 
         return lldp
@@ -617,24 +619,24 @@ class IOSXRDriver(NetworkDriver):
 
         for neighbor in result_tree.xpath('.//Neighbors/DetailTable/Detail/Entry'):
             interface_name = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(neighbor, 'ReceivingInterfaceName'))
+                text_type, napalm_base.helpers.find_txt(neighbor, 'ReceivingInterfaceName'))
             parent_interface = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(neighbor, 'ReceivingParentInterfaceName'))
+                text_type, napalm_base.helpers.find_txt(neighbor, 'ReceivingParentInterfaceName'))
             chassis_id_raw = napalm_base.helpers.find_txt(neighbor, 'ChassisID')
             chassis_id = napalm_base.helpers.convert(
                 napalm_base.helpers.mac, chassis_id_raw, chassis_id_raw)
             port_id = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(neighbor, 'PortIDDetail'))
+                text_type, napalm_base.helpers.find_txt(neighbor, 'PortIDDetail'))
             port_descr = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(neighbor, 'Detail/PortDescription'))
+                text_type, napalm_base.helpers.find_txt(neighbor, 'Detail/PortDescription'))
             system_name = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(neighbor, 'Detail/SystemName'))
+                text_type, napalm_base.helpers.find_txt(neighbor, 'Detail/SystemName'))
             system_descr = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(neighbor, 'Detail/SystemDescription'))
+                text_type, napalm_base.helpers.find_txt(neighbor, 'Detail/SystemDescription'))
             system_capabilities = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(neighbor, 'Detail/SystemCapabilities'))
+                text_type, napalm_base.helpers.find_txt(neighbor, 'Detail/SystemCapabilities'))
             enabled_capabilities = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(neighbor, 'Detail/EnabledCapabilities'))
+                text_type, napalm_base.helpers.find_txt(neighbor, 'Detail/EnabledCapabilities'))
 
             if interface_name not in lldp_neighbors.keys():
                 lldp_neighbors[interface_name] = []
@@ -660,9 +662,9 @@ class IOSXRDriver(NetworkDriver):
 
         for command in commands:
             try:
-                cli_output[unicode(command)] = unicode(self.device._execute_show(command))
+                cli_output[text_type(command)] = text_type(self.device._execute_show(command))
             except TimeoutError:
-                cli_output[unicode(command)] = 'Execution of command \
+                cli_output[text_type(command)] = 'Execution of command \
                     "{command}" took too long! Please adjust your params!'.format(command=command)
                 raise CommandTimeoutException(str(cli_output))
 
@@ -703,9 +705,6 @@ class IOSXRDriver(NetworkDriver):
         <InstanceName>default</InstanceName></Naming></Instance></BGP></Configuration></Get>'
         result_tree = ETREE.fromstring(self.device.make_rpc_call(rpc_command))
 
-        group = group.lower()
-        neighbor = neighbor.lower()
-
         if not group:
             neighbor = ''
 
@@ -807,7 +806,7 @@ class IOSXRDriver(NetworkDriver):
                 'apply_groups': [],  # on IOS-XR will always be empty list!
                 'description': description,
                 'local_as': local_as,
-                'type': unicode(bgp_type),
+                'type': text_type(bgp_type),
                 'import_policy': import_policy,
                 'export_policy': export_policy,
                 'local_address': local_address,
@@ -834,13 +833,14 @@ class IOSXRDriver(NetworkDriver):
         <Naming><InstanceName>default</InstanceName></Naming><ConfigInstanceVRFTable/>\
         </ConfigInstance></ConfigInstanceTable></BGP></Operational></Get>'
 
-        active_vrfs_rpc_reply = ETREE.fromstring(self.device.make_rpc_call(active_vrfs_rpc_request))
+        active_vrfs_rpc_reply = ETREE.fromstring(
+            self.device.make_rpc_call(active_vrfs_rpc_request))
         active_vrfs_tree = active_vrfs_rpc_reply.xpath('.//ConfigVRF')
 
         for active_vrf_tree in active_vrfs_tree:
             active_vrfs.append(napalm_base.helpers.find_txt(active_vrf_tree, 'Naming/VRFName'))
 
-        unique_active_vrfs = set(active_vrfs)
+        unique_active_vrfs = sorted(set(active_vrfs))
 
         bgp_neighbors_vrf_all_rpc = '<Get><Operational><BGP><InstanceTable><Instance><Naming>\
         <InstanceName>default</InstanceName></Naming>'
@@ -927,7 +927,7 @@ class IOSXRDriver(NetworkDriver):
                 if connection_state == u'Estab':
                     connection_state = u'Established'
                 previous_connection_state = napalm_base.helpers.convert(
-                    unicode, _BGP_STATE_.get(napalm_base.helpers.find_txt(
+                    text_type, _BGP_STATE_.get(napalm_base.helpers.find_txt(
                         neighbor, 'PreviousConnectionState', '0')))
                 active_prefix_count = napalm_base.helpers.convert(
                     int, napalm_base.helpers.find_txt(
@@ -954,7 +954,7 @@ class IOSXRDriver(NetworkDriver):
                     or vrf_keepalive
                 configured_keepalive = napalm_base.helpers.convert(
                     int, napalm_base.helpers.find_txt(neighbor, 'ConfiguredKeepalive'), 0)
-                flap_count = connection_down_count / 2
+                flap_count = int(connection_down_count / 2)
                 if up:
                     flap_count -= 1
                 if remote_as not in bgp_neighbors_detail[vrf_name].keys():
@@ -1009,9 +1009,9 @@ class IOSXRDriver(NetworkDriver):
 
         for arp_entry in result_tree.xpath('.//EntryTable/Entry'):
             interface = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(arp_entry, './/InterfaceName'))
+                text_type, napalm_base.helpers.find_txt(arp_entry, './/InterfaceName'))
             ip = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(arp_entry, './/Address'))
+                text_type, napalm_base.helpers.find_txt(arp_entry, './/Address'))
             age = napalm_base.helpers.convert(float,
                 napalm_base.helpers.find_txt(arp_entry, './/Age'), 0.0)
             mac_raw = napalm_base.helpers.find_txt(arp_entry, './/HardwareAddress')
@@ -1124,13 +1124,14 @@ class IOSXRDriver(NetworkDriver):
         <IPV6Network></IPV6Network></Operational></Get>'
 
         # only one request
-        ipv4_ipv6_tree = ETREE.fromstring(self.device.make_rpc_call(rpc_command_ipv4_ipv6))
+        ipv4_ipv6_tree = ETREE.fromstring(
+            self.device.make_rpc_call(rpc_command_ipv4_ipv6))
 
         # parsing IPv4
         ipv4_xpath = './/IPV4Network/InterfaceTable/Interface'
         for interface in ipv4_ipv6_tree.xpath(ipv4_xpath):
             interface_name = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(interface, 'Naming/InterfaceName'))
+                text_type, napalm_base.helpers.find_txt(interface, 'Naming/InterfaceName'))
             primary_ip = napalm_base.helpers.ip(napalm_base.helpers.find_txt(
                     interface, 'VRFTable/VRF/Detail/PrimaryAddress'))
             primary_prefix = napalm_base.helpers.convert(
@@ -1160,7 +1161,7 @@ class IOSXRDriver(NetworkDriver):
         )
         for interface in ipv4_ipv6_tree.xpath(ipv6_xpath):
             interface_name = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(interface, 'Naming/InterfaceName'))
+                text_type, napalm_base.helpers.find_txt(interface, 'Naming/InterfaceName'))
             if interface_name not in interfaces_ip.keys():
                 interfaces_ip[interface_name] = {}
             if u'ipv6' not in interfaces_ip[interface_name].keys():
@@ -1212,13 +1213,10 @@ class IOSXRDriver(NetworkDriver):
         if not isinstance(destination, py23_compat.string_types):
             raise TypeError('Please specify a valid destination!')
 
-        if not isinstance(protocol, py23_compat.string_types) or \
-           protocol.lower() not in ('static', 'bgp', 'isis'):
-            raise TypeError("Protocol not supported: {protocol}.".format(
-                protocol=protocol
-            ))
-
         protocol = protocol.lower()
+        if protocol == 'direct':
+            protocol = 'connected'
+
         dest_split = destination.split('/')
         network = dest_split[0]
         prefix_tag = ''
@@ -1240,9 +1238,10 @@ class IOSXRDriver(NetworkDriver):
 
         for route in routes_tree.xpath('.//Route'):
             route_protocol = napalm_base.helpers.convert(
-                unicode, napalm_base.helpers.find_txt(route, 'ProtocolName').upper())
-            if route_protocol.lower() != protocol:
+                text_type, napalm_base.helpers.find_txt(route, 'ProtocolName').lower())
+            if protocol and route_protocol != protocol:
                 continue  # ignore routes learned via a different protocol
+                # only in case the user requested a certain protocol
             route_details = {}
             address = napalm_base.helpers.find_txt(route, 'Prefix')
             length = napalm_base.helpers.find_txt(route, 'PrefixLength')
@@ -1252,7 +1251,7 @@ class IOSXRDriver(NetworkDriver):
             age = napalm_base.helpers.convert(
                 int, napalm_base.helpers.find_txt(route, 'RouteAge'))
             destination = napalm_base.helpers.convert(
-                unicode,
+                text_type,
                 '{prefix}/{length}'.format(
                     prefix=address,
                     length=length
@@ -1276,7 +1275,7 @@ class IOSXRDriver(NetworkDriver):
             }
 
             # from BGP will try to get some more information
-            if protocol.lower() == 'bgp':
+            if route_protocol == 'bgp' and C.SR_638170159_SOLVED:
                 # looks like IOS-XR does not filter correctly
                 # !IMPORTANT
                 bgp_route_info_rpc_command = '<Get><Operational><BGP><Active><DefaultVRF><AFTable>\
@@ -1344,13 +1343,13 @@ class IOSXRDriver(NetworkDriver):
                             'remote_address': remote_address
                         }
                     routes[destination].append(single_route_details)
-
             else:
                 first_route = True
                 for route_entry in route.xpath('RoutePath/Entry'):
                     # get all possible entries
                     next_hop = napalm_base.helpers.find_txt(route_entry, 'Address')
-                    single_route_details = route_details.copy()
+                    single_route_details = {}
+                    single_route_details.update(route_details)
                     single_route_details.update({
                         'current_active': first_route,
                         'next_hop': next_hop
@@ -1404,7 +1403,8 @@ class IOSXRDriver(NetworkDriver):
 
         sla_config_rpc_command = '<Get><Configuration><IPSLA></IPSLA></Configuration></Get>'
 
-        sla_config_result_tree = ETREE.fromstring(self.device.make_rpc_call(sla_config_rpc_command))
+        sla_config_result_tree = ETREE.fromstring(
+            self.device.make_rpc_call(sla_config_rpc_command))
 
         for probe in sla_config_result_tree.xpath('.//Definition'):
             probe_name = napalm_base.helpers.find_txt(probe, 'Naming/OperationID')
@@ -1446,14 +1446,15 @@ class IOSXRDriver(NetworkDriver):
 
         sla_results_rpc_command = '<Get><Operational><IPSLA></IPSLA></Operational></Get>'
 
-        sla_results_tree = ETREE.fromstring(self.device.make_rpc_call(sla_results_rpc_command))
+        sla_results_tree = ETREE.fromstring(
+            self.device.make_rpc_call(sla_results_rpc_command))
 
         probes_config = self.get_probes_config()  # need to retrieve also the configuration
         # source and tag/test_name not provided
 
         for probe in sla_results_tree.xpath('.//Operation'):
             probe_name = napalm_base.helpers.find_txt(probe, 'Naming/OperationID')
-            test_name = probes_config.get(probe_name).keys()[0]
+            test_name = list(probes_config.get(probe_name).keys())[0]
             target = napalm_base.helpers.find_txt(
                 probe, 'History/Target/LifeTable/Life/BucketTable/Bucket[0]/TargetAddress\
                 /IPv4AddressTarget')
@@ -1631,9 +1632,9 @@ class IOSXRDriver(NetworkDriver):
                     last_probe_host_name = last_probe_ip_address
                 last_hop_dict['probes'][last_probe_index] = {
                     'ip_address': napalm_base.helpers.convert(
-                        unicode, last_probe_ip_address),
+                        text_type, last_probe_ip_address),
                     'host_name': napalm_base.helpers.convert(
-                        unicode, last_probe_host_name),
+                        text_type, last_probe_host_name),
                     'rtt': timeout * 1000.0
                 }
                 continue
diff --git a/setup.cfg b/setup.cfg
index b18e827..7330df1 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,15 +1,20 @@
 [pylama]
 linters = mccabe,pep8,pyflakes
 ignore = D203,C901,E128
+skip = .tox/*
 
 [pylama:pep8]
 max_line_length = 100
 
 [tool:pytest]
-addopts = --cov=./ -vs
+addopts = --cov=napalm_iosxr --cov-report term-missing -vs --pylama
 json_report = report.json
 jsonapi = true
 
+[coverage:run]
+include = 
+	napalm_iosxr/*
+
 [egg_info]
 tag_build = 
 tag_date = 0
diff --git a/setup.py b/setup.py
index 0a28f35..b8dc5d0 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ reqs = [str(ir.req) for ir in install_reqs]
 
 setup(
     name="napalm-iosxr",
-    version="0.4.2",
+    version="0.4.5",
     packages=find_packages(),
     author="David Barroso, Mircea Ulinic",
     author_email="dbarrosop at dravetech.com, mircea at cloudflare.com",
diff --git a/test/unit/conftest.py b/test/unit/conftest.py
index 3b948c3..f3ca74f 100644
--- a/test/unit/conftest.py
+++ b/test/unit/conftest.py
@@ -55,11 +55,14 @@ class FakeIOSXRDevice(BaseTestDouble):
     def close(self):
         pass
 
-    def make_rpc_call(self, rpc_call):
+    def make_rpc_call(self, rpc_call, encoded=True):
         filename = '{}.txt'.format(self.sanitize_text(rpc_call))
         full_path = self.find_file(filename)
         result = self.read_txt_file(full_path)
-        return result
+        if encoded:
+            return str.encode(result)
+        else:
+            return result
 
     def show_lldp_neighbors(self):
         filename = 'show_lldp_neighbors.txt'
@@ -71,4 +74,4 @@ class FakeIOSXRDevice(BaseTestDouble):
         rpc_request = '<CLI><Configuration>{show_command}</Configuration></CLI>'.format(
             show_command=show_command
         )
-        return self.make_rpc_call(rpc_request)
+        return self.make_rpc_call(rpc_request, encoded=False)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/napalm-iosxr.git



More information about the Python-modules-commits mailing list