Skip to content

Commit 965966d

Browse files
authored
Merge pull request #1285 from javcasalc/feature/cisco_ios_get_probes_results
Update get probe code to make it work it IOS XE 16.12.x
2 parents 2ac2b22 + 70da53f commit 965966d

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

napalm/ios/ios.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,18 +2697,22 @@ def process_mac_fields(vlan, mac, mac_type, interface):
26972697

26982698
def get_probes_config(self):
26992699
probes = {}
2700+
27002701
probes_regex = (
27012702
r"ip\s+sla\s+(?P<id>\d+)\n"
2702-
r"\s+(?P<probe_type>\S+)\s+(?P<probe_args>.*\n).*"
2703-
r"\s+tag\s+(?P<name>\S+)\n.*"
2704-
r"\s+history\s+buckets-kept\s+(?P<probe_count>\d+)\n.*"
2705-
r"\s+frequency\s+(?P<interval>\d+)$"
2703+
r"\s+(?P<probe_type>\S+)\s+(?P<probe_args>.*)\n"
2704+
r"\s+tag\s+(?P<name>[\S ]+)\n"
2705+
r"(\s+.*\n)*"
2706+
r"((\s+frequency\s+(?P<interval0>\d+)\n(\s+.*\n)*\s+history"
2707+
r"\s+buckets-kept\s+(?P<probe_count0>\d+))|(\s+history\s+buckets-kept"
2708+
r"\s+(?P<probe_count1>\d+)\n.*\s+frequency\s+(?P<interval1>\d+)))"
27062709
)
2710+
27072711
probe_args = {
27082712
"icmp-echo": r"^(?P<target>\S+)\s+source-(?:ip|interface)\s+(?P<source>\S+)$"
27092713
}
27102714
probe_type_map = {"icmp-echo": "icmp-ping"}
2711-
command = "show run | include ip sla [0-9]"
2715+
command = "show run | section ip sla [0-9]"
27122716
output = self._send_command(command)
27132717
for match in re.finditer(probes_regex, output, re.M):
27142718
probe = match.groupdict()
@@ -2724,8 +2728,8 @@ def get_probes_config(self):
27242728
"probe_type": probe_type_map[probe["probe_type"]],
27252729
"target": probe_data["target"],
27262730
"source": probe_data["source"],
2727-
"probe_count": int(probe["probe_count"]),
2728-
"test_interval": int(probe["interval"]),
2731+
"probe_count": int(probe["probe_count0"] or probe["probe_count1"]),
2732+
"test_interval": int(probe["interval0"] or probe["interval1"]),
27292733
}
27302734
}
27312735

test/ios/mocked_data/test_get_probes_config/normal/expected_result.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,14 @@
1616
"test_interval": 3,
1717
"probe_count": 20
1818
}
19+
},
20+
"3": {
21+
"quad9": {
22+
"source": "GigabitEthernet11",
23+
"probe_type": "icmp-ping",
24+
"target": "9.9.9.9",
25+
"test_interval": 15,
26+
"probe_count": 60
27+
}
1928
}
2029
}

test/ios/mocked_data/test_get_probes_config/normal/show_run___include_ip_sla__0_9_.txt renamed to test/ios/mocked_data/test_get_probes_config/normal/show_run___section_ip_sla__0_9_.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,10 @@ ip sla 2
1111
history lives-kept 1
1212
history buckets-kept 20
1313
timeout 2000
14-
frequency 3
14+
frequency 3
15+
ip sla 3
16+
icmp-echo 9.9.9.9 source-interface GigabitEthernet11
17+
tag quad9
18+
frequency 15
19+
history lives-kept 1
20+
history buckets-kept 60

0 commit comments

Comments
 (0)