Commit 6a8e6635 authored by bee26's avatar bee26
Browse files

Merge branch 'cherry-pick-6e54c33b' into 'release-19.4'

release-19.4:Backport!3308

See merge request noc/noc!3326
parents 26db488c 1cba0f32
......@@ -2,7 +2,7 @@
# ---------------------------------------------------------------------
# Iskratel.ESCOM.get_capabilities
# ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -25,16 +25,24 @@ class Script(BaseScript):
"""
Check box has LLDP enabled
"""
cmd = self.cli("show lldp configuration")
return "LLDP state: Enabled" in cmd
if self.is_escom_l:
cmd = self.cli("show configuration")
return "lldp run" in cmd
else:
cmd = self.cli("show lldp configuration")
return "LLDP state: Enabled" in cmd
@false_on_cli_error
def has_stp_cli(self):
"""
Check box has STP enabled
"""
cmd = self.cli("show spanning-tree active")
return " enabled " in cmd
if self.is_escom_l:
cmd = self.cli("show spanning-tree")
return "Spanning tree enabled" in cmd
else:
cmd = self.cli("show spanning-tree active")
return " enabled " in cmd
def execute_platform_cli(self, caps):
try:
......
......@@ -2,7 +2,7 @@
# ---------------------------------------------------------------------
# Iskratel.ESCOM.get_interfaces
# ---------------------------------------------------------------------
# Copyright (C) 2007-2019 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -52,10 +52,7 @@ class Script(BaseScript):
re.MULTILINE,
)
rx_escom_l_port = re.compile(
r"(?P<name>\S+)\s+is (?P<admin_status>\S+), line protocol is (?P<oper_status>\S+)\n"
r"\s+Ifindex is (?P<ifindex>\d+).*(,\s*unique port number is (?P<unique_port>\d+?))?\n"
r"\s+Hardware is (?P<type>\S+), [Aa]ddress is (?P<mac>\S+)\s*(\(.+\))?\n"
r"(\s+Interface address is (?P<address>\S+))?",
r"(?P<name>\S+)\s+is (administratively |)(?P<admin_status>\S+), line protocol is (?P<oper_status>\S+)\n\s+Ifindex is (?P<ifindex>\d+).*(,\s*unique port number is (?P<unique_port>\d+?))?\n\s+(Description:\s+(?P<description>\S+)\n\s+|)Hardware is (?P<type>\S+), [Aa]ddress is (?P<mac>\S+)\s*(\(.+\))?(\n\s+Interface address is (?P<address>\S+)|)\n\s+MTU\s+(?P<mtu>\d+)?",
re.MULTILINE,
)
......
......@@ -2,7 +2,7 @@
# ---------------------------------------------------------------------
# Iskratel.ESCOM.get_lldp_neighbors
# ---------------------------------------------------------------------
# Copyright (C) 2007-2019 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -29,14 +29,36 @@ class Script(BaseScript):
r"^Port description:(?P<port_description>.*)\n",
re.MULTILINE,
)
rx_port2 = re.compile(
r"chassis id: (?P<device_id>\S+)\n+"
r"^port id: (?P<port_id>\S+)\n+"
r"^port description: (?P<port_description>.+)\n+"
r"^system name: (?P<system_name>\S+|)\n+"
r"^system description: (?P<system_description>\S+|)\n+"
r"^.+\n+^system capabilities: (?P<capabilities>.+)",
re.MULTILINE,
)
rx_search = re.compile(
r"^(?:(?P<chassis_id>\S+)|)\s+(?P<iface>\S+)\s+\d+\s+(?P<port_id>\S+)\s+(?:(?P<caps>\S+)|)?",
re.MULTILINE,
)
def execute(self):
r = []
data = []
try:
v = self.cli("show lldp neighbors")
except self.CLISyntaxError:
raise self.NotSupportedError()
t = parse_table(v, allow_wrap=True)
if not t:
for line in v.splitlines():
if not self.rx_search.search(line):
continue
data.append(
list([c[1], c[0], c[2], "", c[3]] for c in self.rx_search.findall(line))[0]
)
t = data
for i in t:
chassis_id = i[1]
if is_ipv4(chassis_id) or is_ipv6(chassis_id):
......@@ -84,15 +106,22 @@ class Script(BaseScript):
}
if i[3]:
neighbor["remote_system_name"] = i[3]
try:
v = self.cli("show lldp neighbors %s" % i[0])
match = self.rx_port.search(v)
if match:
neighbor["remote_system_description"] = match.group(
"system_description"
).strip()
neighbor["remote_port_description"] = match.group("port_description").strip()
except self.CLISyntaxError:
pass
if self.is_escom_l:
try:
v = self.cli("show lldp neighbors interface %s" % i[0])
match = self.rx_port2.search(v)
except self.CLISyntaxError:
pass
else:
try:
v = self.cli("show lldp neighbors %s" % i[0])
match = self.rx_port.search(v)
except self.CLISyntaxError:
pass
if match:
if not neighbor["remote_chassis_id"] and match.group("device_id"):
neighbor["remote_chassis_id"] = match.group("device_id")
neighbor["remote_system_description"] = match.group("system_description").strip()
neighbor["remote_port_description"] = match.group("port_description").strip()
r += [{"local_interface": i[0], "neighbors": [neighbor]}]
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