Skip to content

Commit

Permalink
ios: get_probes_config: driver implementation and test for icmp-echo
Browse files Browse the repository at this point in the history
  • Loading branch information
nickethier committed Nov 16, 2017
1 parent a04c348 commit 1bdc4d1
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
35 changes: 35 additions & 0 deletions napalm/ios/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -1902,6 +1902,41 @@ def process_mac_fields(vlan, mac, mac_type, interface):

return mac_address_table

def get_probes_config(self):
probes = {}
probes_regex = r"ip\s+sla\s+(?P<id>\d+)\n" \
"\s+(?P<probe_type>\S+)\s+(?P<probe_args>.*\n).*" \
"\s+tag\s+(?P<name>\S+)\n.*" \
"\s+history\s+buckets-kept\s+(?P<probe_count>\d+)\n.*" \
"\s+frequency\s+(?P<interval>\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]"
output = self._send_command(command)
for match in re.finditer(probes_regex, output, re.M):
probe = match.groupdict()
if probe["probe_type"] not in probe_args:
# Probe type not supported yet
continue
probe_args_match = re.match(probe_args[probe["probe_type"]],
probe["probe_args"])
probe_data = probe_args_match.groupdict()
probes[probe["id"]] = {
probe["name"]: {
'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"])
}
}

return probes

def get_snmp_information(self):
"""
Returns a dict of dicts
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"1": {
"test-google-8": {
"source": "Loopback0",
"probe_type": "icmp-ping",
"target": "8.8.8.8",
"test_interval": 3,
"probe_count": 20
}
},
"2": {
"test-google-4": {
"source": "1.1.1.1",
"probe_type": "icmp-ping",
"target": "8.8.4.4",
"test_interval": 3,
"probe_count": 20
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ip sla 1
icmp-echo 8.8.8.8 source-interface Loopback0
tag test-google-8
history lives-kept 1
history buckets-kept 20
timeout 2000
frequency 3
ip sla 2
icmp-echo 8.8.4.4 source-ip 1.1.1.1
tag test-google-4
history lives-kept 1
history buckets-kept 20
timeout 2000
frequency 3

0 comments on commit 1bdc4d1

Please sign in to comment.