diff --git a/napalm_iosxr/iosxr.py b/napalm_iosxr/iosxr.py index 6005bd2..cbe9e39 100644 --- a/napalm_iosxr/iosxr.py +++ b/napalm_iosxr/iosxr.py @@ -1240,15 +1240,30 @@ 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(network).version + except AddrFormatError: + raise TypeError('Wrong destination IP Address!') + + if ipv == 6: + route_info_rpc_command = '\ + defaultIPv6\ + 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)) 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
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