Commit 934873f3 authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Merge branch 'aversant-release-19.2-patch-06041' into 'release-19.2'

release-19.2:Backport!2340

See merge request noc/noc!2342
parents 90d866db 60a4e80f
......@@ -73,8 +73,12 @@ class Script(BaseScript):
continue
ifname = value["name"]
if value.get("bss") and value.get("ssid"):
ssid = value["ssid"].replace(" ", "").replace("Managed", "")
if ssid.startswith("2a2d"):
# 2a2d - hex string
ssid = ssid.decode("hex")
bss = self.get_bss_status(value["bss"])
if_ssid = "%s.%s" % (ifname, value["ssid"])
if_ssid = "%s.%s" % (ifname, ssid)
r[ifname] = {
"interface": ifname,
"admin_status": bss["admin_status"],
......
......@@ -79,9 +79,10 @@ class Script(BaseScript):
interfaces[ifname] = {
"type": self.profile.get_interface_type(ifname),
"name": ifname,
"mac": value["mac"],
"subinterfaces": [],
}
if value["mac"]:
interfaces[ifname]["mac"] = value["mac"]
if "eth" in ifname:
interfaces[ifname]["subinterfaces"] += [
{"name": ifname, "mac": value["mac"], "enabled_afi": ["BRIDGE"]}
......
......@@ -8,6 +8,7 @@
# Python modules
import re
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.iping import IPing
......@@ -19,17 +20,15 @@ class Script(BaseScript):
rx_result = re.compile(
r"^(?P<count>\d+) packets transmitted, (?P<success>\d+) "
r"(packets received|received),(?:\s|\s\S+ errors, )\d+% packet loss$",
re.MULTILINE)
r"(packets received|received),(?:\s|\s\S+ (errors|duplicates), )\d+% packet loss$",
re.MULTILINE,
)
rx_stat = re.compile(
r"^round-trip min/avg/max = (?P<min>.+)/(?P<avg>.+)/(?P<max>.+)\s.",
re.MULTILINE)
rx_count = re.compile(
r"^\d+ bytes from \d\S+\d+: seq=(\d+) ttl=\d+ time=\S+ ms",
re.MULTILINE)
r"^round-trip min/avg/max = (?P<min>.+)/(?P<avg>.+)/(?P<max>.+)\s.", re.MULTILINE
)
rx_count = re.compile(r"^\d+ bytes from \d\S+\d+: seq=(\d+) ttl=\d+ time=\S+ ms", re.MULTILINE)
def execute(self, address, count=None, source_address=None,
size=None, df=None):
def execute(self, address, count=None, source_address=None, size=None, df=None):
if count is None:
count = 5
cmd = "ping %s -c %d" % (address, int(count))
......@@ -37,15 +36,20 @@ class Script(BaseScript):
cmd += " -s %d" % int(size)
if source_address:
cmd += " -I %s" % source_address
ping = self.cli(cmd)
result = self.rx_result.search(ping)
result = None
try:
ping = self.cli(cmd, ignore_errors=True)
result = self.rx_result.search(ping)
except self.CLISyntaxError:
pass
"""
Workaround for this incident
PING 10.218.217.227 (10.218.217.227): 56 data bytes
64 bytes from 10.218.217.227: seq=0 ttl=61 time=15.436 ms
64 bytes from 10.218.217.227: seq=1 ttl=61 time=15.265 ms
64 bytes from 10.218.217.227: seq=2 ttl=61 time=15.365 ms
PING X.X.X.X (X.X.X.X): 56 data bytes
64 bytes from X.X.X.X: seq=0 ttl=61 time=15.436 ms
64 bytes from X.X.X.X: seq=1 ttl=61 time=15.265 ms
64 bytes from X.X.X.X: seq=2 ttl=61 time=15.365 ms
ping: sendto: Network is unreachable
Invalid command.
......@@ -54,15 +58,8 @@ class Script(BaseScript):
result = self.rx_count.findall(ping)
return {"success": len(result), "count": count}
r = {
"success": result.group("success"),
"count": result.group("count"),
}
r = {"success": result.group("success"), "count": result.group("count")}
stat = self.rx_stat.search(ping)
if stat:
r.update({
"min": stat.group("min"),
"avg": stat.group("avg"),
"max": stat.group("max"),
})
r.update({"min": stat.group("min"), "avg": stat.group("avg"), "max": stat.group("max")})
return r
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment