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 Aug 31, 2020
1 parent bfb9484 commit aff2481
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -2697,18 +2697,26 @@ 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+)$"
)

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

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 +2732,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

0 comments on commit aff2481

Please sign in to comment.