From 35009d7a58b0e134773ee790fd316ebc9202f953 Mon Sep 17 00:00:00 2001 From: Manuel Domke Date: Tue, 4 Apr 2017 12:09:20 +0200 Subject: [PATCH 1/8] issue 116 - implemented request to get routes for ipv6 destinations --- napalm_iosxr/iosxr.py | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/napalm_iosxr/iosxr.py b/napalm_iosxr/iosxr.py index 6005bd2..bc2e10a 100644 --- a/napalm_iosxr/iosxr.py +++ b/napalm_iosxr/iosxr.py @@ -1240,15 +1240,32 @@ def get_route_to(self, destination='', protocol=''): prefix_tag = '{prefix_length}'.format( prefix_length=dest_split[1]) - route_info_rpc_command = 'default\ - IPv4\ - Unicast\ - default
\ - {network}
{prefix}
\ -
'.format( - network=network, - prefix=prefix_tag - ) + ipv = 4 + try: + ipv = IPAddress(destination).version + except AddrFormatError: + return {'error': 'Wrong destination IP Address!'} + + if ipv == 6: + route_info_rpc_command = 'default\ + IPv6\ + Unicast\ + default
\ + {network}
{prefix}
\ +
'.format( + network=network, + prefix=prefix_tag + ) + else: + route_info_rpc_command = 'default\ + IPv4\ + Unicast\ + default
\ + {network}
{prefix}
\ +
'.format( + network=network, + prefix=prefix_tag + ) routes_tree = ETREE.fromstring(self.device.make_rpc_call(route_info_rpc_command)) From 019c339d93b994681862a6c8bcc8263d16bad3d5 Mon Sep 17 00:00:00 2001 From: Manuel Domke Date: Tue, 4 Apr 2017 12:36:15 +0200 Subject: [PATCH 2/8] - use only ip-address (w/o prefix) to check protocol version, otherwise it will fail using cidr syntax. - fixed indentation --- napalm_iosxr/iosxr.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/napalm_iosxr/iosxr.py b/napalm_iosxr/iosxr.py index bc2e10a..ff5e92a 100644 --- a/napalm_iosxr/iosxr.py +++ b/napalm_iosxr/iosxr.py @@ -1240,12 +1240,12 @@ def get_route_to(self, destination='', protocol=''): prefix_tag = '{prefix_length}'.format( prefix_length=dest_split[1]) - ipv = 4 + ipv = 4 try: - ipv = IPAddress(destination).version + ipv = IPAddress(network).version except AddrFormatError: return {'error': 'Wrong destination IP Address!'} - + if ipv == 6: route_info_rpc_command = 'default\ IPv6\ From e537d1a9298ea80249d2f288019693292168487d Mon Sep 17 00:00:00 2001 From: Manuel Domke Date: Tue, 4 Apr 2017 12:41:51 +0200 Subject: [PATCH 3/8] fixed long line & indentation --- napalm_iosxr/iosxr.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/napalm_iosxr/iosxr.py b/napalm_iosxr/iosxr.py index ff5e92a..fd92467 100644 --- a/napalm_iosxr/iosxr.py +++ b/napalm_iosxr/iosxr.py @@ -1246,16 +1246,14 @@ def get_route_to(self, destination='', protocol=''): except AddrFormatError: return {'error': 'Wrong destination IP Address!'} - if ipv == 6: + if ipv == 6: route_info_rpc_command = 'default\ IPv6\ Unicast\ default
\ {network}
{prefix}
\ -
'.format( - network=network, - prefix=prefix_tag - ) +
' + .format(network=network, prefix=prefix_tag) else: route_info_rpc_command = 'default\ IPv4\ From 0ab3d262d3932b661ad83846093b798f2df31622 Mon Sep 17 00:00:00 2001 From: Manuel Domke Date: Tue, 4 Apr 2017 12:52:06 +0200 Subject: [PATCH 4/8] fixed syntax error introduced while shortening lines --- napalm_iosxr/iosxr.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/napalm_iosxr/iosxr.py b/napalm_iosxr/iosxr.py index fd92467..21af79e 100644 --- a/napalm_iosxr/iosxr.py +++ b/napalm_iosxr/iosxr.py @@ -1252,8 +1252,8 @@ def get_route_to(self, destination='', protocol=''): Unicast\ default
\ {network}
{prefix}
\ -
' - .format(network=network, prefix=prefix_tag) + '.format( + network=network, prefix=prefix_tag) else: route_info_rpc_command = 'default\ IPv4\ From 7230f41e95f6484dde4c7bb07eed48edfcefaa4d Mon Sep 17 00:00:00 2001 From: Manuel Domke Date: Tue, 4 Apr 2017 13:01:20 +0200 Subject: [PATCH 5/8] reformatted xml request --- napalm_iosxr/iosxr.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/napalm_iosxr/iosxr.py b/napalm_iosxr/iosxr.py index 21af79e..c06c75f 100644 --- a/napalm_iosxr/iosxr.py +++ b/napalm_iosxr/iosxr.py @@ -1247,13 +1247,13 @@ def get_route_to(self, destination='', protocol=''): return {'error': 'Wrong destination IP Address!'} if ipv == 6: - route_info_rpc_command = 'default\ - IPv6\ - Unicast\ + route_info_rpc_command = '\ + defaultIPv6\ + Unicast\ default
\ - {network}
{prefix}
\ -
'.format( - network=network, prefix=prefix_tag) + {network}{prefix}
\ +
\ +
'.format(network=network, prefix=prefix_tag) else: route_info_rpc_command = 'default\ IPv4\ From ecb6eb14c02bae2ed8bc51a2a8dad43cbb89b9b7 Mon Sep 17 00:00:00 2001 From: Manuel Domke Date: Tue, 4 Apr 2017 13:26:58 +0200 Subject: [PATCH 6/8] renamed testdata --- ..._AFTable__AF__Naming__AFName_IPv4__AFName___Naming__SAFTa.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/unit/mocked_data/test_get_route_to/SR638170159/{_Get__Operational__RIB__VRFTable__VRF__Naming__VRFName_default__________VRFName___Naming__AFTable__AF__Naming__AFName_IPv4__AFName___Naming__SAFTable_.txt => _Get__Operational__RIB__VRFTable__VRF__Naming__VRFName_default______________VRFName___Naming__AFTable__AF__Naming__AFName_IPv4__AFName___Naming__SAFTa.txt} (100%) diff --git a/test/unit/mocked_data/test_get_route_to/SR638170159/_Get__Operational__RIB__VRFTable__VRF__Naming__VRFName_default__________VRFName___Naming__AFTable__AF__Naming__AFName_IPv4__AFName___Naming__SAFTable_.txt b/test/unit/mocked_data/test_get_route_to/SR638170159/_Get__Operational__RIB__VRFTable__VRF__Naming__VRFName_default______________VRFName___Naming__AFTable__AF__Naming__AFName_IPv4__AFName___Naming__SAFTa.txt similarity index 100% rename from test/unit/mocked_data/test_get_route_to/SR638170159/_Get__Operational__RIB__VRFTable__VRF__Naming__VRFName_default__________VRFName___Naming__AFTable__AF__Naming__AFName_IPv4__AFName___Naming__SAFTable_.txt rename to test/unit/mocked_data/test_get_route_to/SR638170159/_Get__Operational__RIB__VRFTable__VRF__Naming__VRFName_default______________VRFName___Naming__AFTable__AF__Naming__AFName_IPv4__AFName___Naming__SAFTa.txt From 205bcc2ff484af438392dab47030fda1952a4732 Mon Sep 17 00:00:00 2001 From: Manuel Domke Date: Tue, 4 Apr 2017 13:51:49 +0200 Subject: [PATCH 7/8] added testdata for get_route_to for ipv6 --- ..._AFTable__AF__Naming__AFName_IPv6__AFName___Naming__SAFTa.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/unit/mocked_data/test_get_route_to/SR638170159/_Get__Operational__IPV6_RIB__VRFTable__VRF__Naming__VRFName_default______________VRFName___Naming__AFTable__AF__Naming__AFName_IPv6__AFName___Naming__SAFTa.txt diff --git a/test/unit/mocked_data/test_get_route_to/SR638170159/_Get__Operational__IPV6_RIB__VRFTable__VRF__Naming__VRFName_default______________VRFName___Naming__AFTable__AF__Naming__AFName_IPv6__AFName___Naming__SAFTa.txt b/test/unit/mocked_data/test_get_route_to/SR638170159/_Get__Operational__IPV6_RIB__VRFTable__VRF__Naming__VRFName_default______________VRFName___Naming__AFTable__AF__Naming__AFName_IPv6__AFName___Naming__SAFTa.txt new file mode 100644 index 0000000..fb9a5f0 --- /dev/null +++ b/test/unit/mocked_data/test_get_route_to/SR638170159/_Get__Operational__IPV6_RIB__VRFTable__VRF__Naming__VRFName_default______________VRFName___Naming__AFTable__AF__Naming__AFName_IPv6__AFName___Naming__SAFTa.txt @@ -0,0 +1 @@ +defaultIPv6Unicastdefault
dead:beef:210:210::53
From d6a1a8d55cdd72879c792b2e1d9136ed93c23994 Mon Sep 17 00:00:00 2001 From: thorko Date: Fri, 28 Apr 2017 13:14:43 +0200 Subject: [PATCH 8/8] Update iosxr.py --- napalm_iosxr/iosxr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napalm_iosxr/iosxr.py b/napalm_iosxr/iosxr.py index c06c75f..cbe9e39 100644 --- a/napalm_iosxr/iosxr.py +++ b/napalm_iosxr/iosxr.py @@ -1244,7 +1244,7 @@ def get_route_to(self, destination='', protocol=''): try: ipv = IPAddress(network).version except AddrFormatError: - return {'error': 'Wrong destination IP Address!'} + raise TypeError('Wrong destination IP Address!') if ipv == 6: route_info_rpc_command = '\