Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Javier Castillo Alcíbar committed Aug 31, 2020

Unverified

This user has not yet uploaded their public signing key.
1 parent bfb9484 commit aff2481
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
@@ -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()
@@ -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"]),
}
}

0 comments on commit aff2481

Please sign in to comment.