Fix invalid escape sequence DeprecationWarnings
This commit is contained in:
parent
3b53afd852
commit
cbfe8ae0c4
|
|
@ -308,7 +308,7 @@ class VyOSDriver(NetworkDriver):
|
||||||
output_iface = self.device.send_command("show interfaces")
|
output_iface = self.device.send_command("show interfaces")
|
||||||
|
|
||||||
# Collect all interfaces' name and status
|
# Collect all interfaces' name and status
|
||||||
match = re.findall("(\S+)\s+[:\-\d/\.]+\s+([uAD])/([uAD])", output_iface)
|
match = re.findall(r"(\S+)\s+[:\-\d/\.]+\s+([uAD])/([uAD])", output_iface)
|
||||||
|
|
||||||
# 'match' example:
|
# 'match' example:
|
||||||
# [("br0", "u", "D"), ("eth0", "u", "u"), ("eth1", "u", "u")...]
|
# [("br0", "u", "D"), ("eth0", "u", "u"), ("eth1", "u", "u")...]
|
||||||
|
|
@ -431,7 +431,7 @@ class VyOSDriver(NetworkDriver):
|
||||||
# 'remote' contains '*' if the machine synchronized with NTP server
|
# 'remote' contains '*' if the machine synchronized with NTP server
|
||||||
synchronized = "*" in remote
|
synchronized = "*" in remote
|
||||||
|
|
||||||
match = re.search("(\d+\.\d+\.\d+\.\d+)", remote)
|
match = re.search(r"(\d+\.\d+\.\d+\.\d+)", remote)
|
||||||
ip = match.group(1)
|
ip = match.group(1)
|
||||||
|
|
||||||
when = when if when != '-' else 0
|
when = when if when != '-' else 0
|
||||||
|
|
@ -459,7 +459,7 @@ class VyOSDriver(NetworkDriver):
|
||||||
|
|
||||||
for line in output_peers:
|
for line in output_peers:
|
||||||
if len(line) > 0:
|
if len(line) > 0:
|
||||||
match = re.search("(\d+\.\d+\.\d+\.\d+)\s+", line)
|
match = re.search(r"(\d+\.\d+\.\d+\.\d+)\s+", line)
|
||||||
ntp_peers.update({
|
ntp_peers.update({
|
||||||
match.group(1): {}
|
match.group(1): {}
|
||||||
})
|
})
|
||||||
|
|
@ -485,7 +485,7 @@ class VyOSDriver(NetworkDriver):
|
||||||
output = self.device.send_command("show ip bgp summary")
|
output = self.device.send_command("show ip bgp summary")
|
||||||
output = output.split("\n")
|
output = output.split("\n")
|
||||||
|
|
||||||
match = re.search(".* router identifier (\d+\.\d+\.\d+\.\d+), local AS number (\d+)",
|
match = re.search(r".* router identifier (\d+\.\d+\.\d+\.\d+), local AS number (\d+)",
|
||||||
output[0])
|
output[0])
|
||||||
if not match:
|
if not match:
|
||||||
return {}
|
return {}
|
||||||
|
|
@ -537,10 +537,10 @@ class VyOSDriver(NetworkDriver):
|
||||||
"""
|
"""
|
||||||
bgp_detail = self.device.send_command("show ip bgp neighbors %s" % peer_id)
|
bgp_detail = self.device.send_command("show ip bgp neighbors %s" % peer_id)
|
||||||
|
|
||||||
match_rid = re.search("remote router ID (\d+\.\d+\.\d+\.\d+).*", bgp_detail)
|
match_rid = re.search(r"remote router ID (\d+\.\d+\.\d+\.\d+).*", bgp_detail)
|
||||||
remote_rid = match_rid.group(1)
|
remote_rid = match_rid.group(1)
|
||||||
|
|
||||||
match_prefix_accepted = re.search("(\d+) accepted prefixes", bgp_detail)
|
match_prefix_accepted = re.search(r"(\d+) accepted prefixes", bgp_detail)
|
||||||
accepted_prefixes = match_prefix_accepted.group(1)
|
accepted_prefixes = match_prefix_accepted.group(1)
|
||||||
|
|
||||||
bgp_neighbor_data["global"]["peers"].setdefault(peer_id, {})
|
bgp_neighbor_data["global"]["peers"].setdefault(peer_id, {})
|
||||||
|
|
@ -573,19 +573,19 @@ class VyOSDriver(NetworkDriver):
|
||||||
return -1
|
return -1
|
||||||
else:
|
else:
|
||||||
if "y" in bgp_uptime:
|
if "y" in bgp_uptime:
|
||||||
match = re.search("(\d+)(\w)(\d+)(\w)(\d+)(\w)", bgp_uptime)
|
match = re.search(r"(\d+)(\w)(\d+)(\w)(\d+)(\w)", bgp_uptime)
|
||||||
uptime = ((int(match.group(1)) * self._YEAR_SECONDS) +
|
uptime = ((int(match.group(1)) * self._YEAR_SECONDS) +
|
||||||
(int(match.group(3)) * self._WEEK_SECONDS) +
|
(int(match.group(3)) * self._WEEK_SECONDS) +
|
||||||
(int(match.group(5)) * self._DAY_SECONDS))
|
(int(match.group(5)) * self._DAY_SECONDS))
|
||||||
return uptime
|
return uptime
|
||||||
elif "w" in bgp_uptime:
|
elif "w" in bgp_uptime:
|
||||||
match = re.search("(\d+)(\w)(\d+)(\w)(\d+)(\w)", bgp_uptime)
|
match = re.search(r"(\d+)(\w)(\d+)(\w)(\d+)(\w)", bgp_uptime)
|
||||||
uptime = ((int(match.group(1)) * self._WEEK_SECONDS) +
|
uptime = ((int(match.group(1)) * self._WEEK_SECONDS) +
|
||||||
(int(match.group(3)) * self._DAY_SECONDS) +
|
(int(match.group(3)) * self._DAY_SECONDS) +
|
||||||
(int(match.group(5)) * self._HOUR_SECONDS))
|
(int(match.group(5)) * self._HOUR_SECONDS))
|
||||||
return uptime
|
return uptime
|
||||||
elif "d" in bgp_uptime:
|
elif "d" in bgp_uptime:
|
||||||
match = re.search("(\d+)(\w)(\d+)(\w)(\d+)(\w)", bgp_uptime)
|
match = re.search(r"(\d+)(\w)(\d+)(\w)(\d+)(\w)", bgp_uptime)
|
||||||
uptime = ((int(match.group(1)) * self._DAY_SECONDS) +
|
uptime = ((int(match.group(1)) * self._DAY_SECONDS) +
|
||||||
(int(match.group(3)) * self._HOUR_SECONDS) +
|
(int(match.group(3)) * self._HOUR_SECONDS) +
|
||||||
(int(match.group(5)) * self._MINUTE_SECONDS))
|
(int(match.group(5)) * self._MINUTE_SECONDS))
|
||||||
|
|
@ -612,9 +612,9 @@ class VyOSDriver(NetworkDriver):
|
||||||
32776498 279273 0 0 0 0
|
32776498 279273 0 0 0 0
|
||||||
"""
|
"""
|
||||||
output = self.device.send_command("show interfaces detail")
|
output = self.device.send_command("show interfaces detail")
|
||||||
interfaces = re.findall("(\S+): <.*", output)
|
interfaces = re.findall(r"(\S+): <.*", output)
|
||||||
# count = re.findall("(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+", output)
|
# count = re.findall("(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+", output)
|
||||||
count = re.findall("(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)", output)
|
count = re.findall(r"(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)", output)
|
||||||
counters = dict()
|
counters = dict()
|
||||||
|
|
||||||
j = 0
|
j = 0
|
||||||
|
|
@ -877,7 +877,7 @@ class VyOSDriver(NetworkDriver):
|
||||||
else:
|
else:
|
||||||
rtt_info = rtt_info[-2]
|
rtt_info = rtt_info[-2]
|
||||||
|
|
||||||
match = re.search("([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+)", rtt_info)
|
match = re.search(r"([\d\.]+)/([\d\.]+)/([\d\.]+)/([\d\.]+)", rtt_info)
|
||||||
|
|
||||||
if match is not None:
|
if match is not None:
|
||||||
rtt_min = float(match.group(1))
|
rtt_min = float(match.group(1))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue