Skip to content

Commit

Permalink
Update get probe code to make it work it IOS XE 16.12.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Castillo Alcíbar committed Sep 1, 2020
1 parent bfb9484 commit d1979cd
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
22 changes: 13 additions & 9 deletions napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -2697,18 +2697,22 @@ def process_mac_fields(vlan, mac, mac_type, interface):

def get_probes_config(self):
probes = {}

probes_regex = (
r"ip\s+sla\s+(?P<id>\d+)\n"
r"\s+(?P<probe_type>\S+)\s+(?P<probe_args>.*\n).*"
r"\s+tag\s+(?P<name>\S+)\n.*"
r"\s+history\s+buckets-kept\s+(?P<probe_count>\d+)\n.*"
r"\s+frequency\s+(?P<interval>\d+)$"
r"\s+(?P<probe_type>\S+)\s+(?P<probe_args>.*)\n"
r"\s+tag\s+(?P<name>[\S ]+)\n"
r"(\s+.*\n)*"
r"((\s+frequency\s+(?P<interval0>\d+)\n(\s+.*\n)*\s+history"
r"\s+buckets-kept\s+(?P<probe_count0>\d+))|(\s+history\s+buckets-kept"
r"\s+(?P<probe_count1>\d+)\n.*\s+frequency\s+(?P<interval1>\d+)))"
)

probe_args = {
"icmp-echo": r"^(?P<target>\S+)\s+source-(?:ip|interface)\s+(?P<source>\S+)$"
}
probe_type_map = {"icmp-echo": "icmp-ping"}
command = "show run | include ip sla [0-9]"
command = "show run | section ip sla [0-9]"
output = self._send_command(command)
for match in re.finditer(probes_regex, output, re.M):
probe = match.groupdict()
Expand All @@ -2724,8 +2728,8 @@ def get_probes_config(self):
"probe_type": probe_type_map[probe["probe_type"]],
"target": probe_data["target"],
"source": probe_data["source"],
"probe_count": int(probe["probe_count"]),
"test_interval": int(probe["interval"]),
"probe_count": int(probe["probe_count0"] or probe["probe_count1"]),
"test_interval": int(probe["interval0"] or probe["interval1"]),
}
}

Expand Down Expand Up @@ -3047,8 +3051,8 @@ def get_route_to(self, destination="", protocol="", longer=False):
destination, _vrf, nh, ip_version
)
nh_line_found = (
False
) # for next RT entry processing ...
False # for next RT entry processing ...
)
routes[route_match].append(route_entry)
return routes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,14 @@
"test_interval": 3,
"probe_count": 20
}
},
"3": {
"quad9": {
"source": "GigabitEthernet11",
"probe_type": "icmp-ping",
"target": "9.9.9.9",
"test_interval": 15,
"probe_count": 60
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ ip sla 2
history lives-kept 1
history buckets-kept 20
timeout 2000
frequency 3
frequency 3
ip sla 3
icmp-echo 9.9.9.9 source-interface GigabitEthernet11
tag quad9
frequency 15
history lives-kept 1
history buckets-kept 60

0 comments on commit d1979cd

Please sign in to comment.