Commit 1b78dd52 authored by Dmitry Lukhtionov's avatar Dmitry Lukhtionov
Browse files

Update Symbol.AP profile

parent dffcd2b3
Pipeline #36579 passed with stages
in 15 minutes and 13 seconds
{
"name": "Symbol | AP | AP71XX sysObjectID",
"$collection": "sa.profilecheckrules",
"uuid": "498533e3-dceb-46ba-b7c0-d0efc09f6d98",
"description": null,
"preference": 10,
"method": "snmp_v2c_get",
"param": "SNMPv2-MIB::sysObjectID.0",
"match_method": "contains",
"value": "1.3.6.1.4.1.388.50.1.1",
"action": "match",
"profile__name": "Symbol.AP"
}
# ---------------------------------------------------------------------
# Symbol.AP.get_capabilities
# ---------------------------------------------------------------------
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from noc.sa.profiles.Generic.get_capabilities import Script as BaseScript
from noc.sa.profiles.Generic.get_capabilities import false_on_cli_error
class Script(BaseScript):
name = "Symbol.AP.get_capabilities"
@false_on_cli_error
def has_lldp_cli(self):
"""
Check box has LLDP enabled
"""
c = self.cli("show lldp neighbors", cached=True)
return "------------" in c
......@@ -103,7 +103,7 @@ class Script(BaseScript):
iface["mac"] = match.group("mac")
iface["subinterfaces"] += [
{
"name": match.group("sub_name"),
"name": match.group("sub_name").replace("R", "radio"),
"admin_status": match.group("oper_status") == "On",
"oper_status": match.group("oper_status") == "On",
"mac": match.group("sub_mac"),
......
# ---------------------------------------------------------------------
# Symbol.AP.get_lldp_neighbors
# ---------------------------------------------------------------------
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import re
# NOC modules
from noc.sa.profiles.Generic.get_lldp_neighbors import Script as BaseScript
from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors
from noc.sa.interfaces.base import MACAddressParameter, IPv4Parameter
from noc.core.validators import is_int, is_ipv4, is_ipv6, is_mac
from noc.core.lldp import (
LLDP_PORT_SUBTYPE_ALIAS,
LLDP_PORT_SUBTYPE_MAC,
LLDP_PORT_SUBTYPE_NETWORK_ADDRESS,
LLDP_PORT_SUBTYPE_LOCAL,
LLDP_CHASSIS_SUBTYPE_MAC,
LLDP_CHASSIS_SUBTYPE_NETWORK_ADDRESS,
LLDP_CHASSIS_SUBTYPE_LOCAL,
LLDP_CAP_BRIDGE,
LLDP_CAP_ROUTER,
lldp_caps_to_bits,
)
class Script(BaseScript):
name = "Symbol.AP.get_lldp_neighbors"
interface = IGetLLDPNeighbors
rx_lldp = re.compile(
r"^Chassis ID: (?P<remote_id>.+)\s*\n"
r"^System Name: (?P<remote_system_name>.+)\s*\n"
r"^Platform: (?P<remote_system_descr>(?:.+\n)+)"
r"^Capabilities: .+\n"
r"^Enabled Capabilities: (?P<caps>.+)\s*\n"
r"^Local Interface: (?P<local>ge\d+), Port ID \(outgoing port\): (?P<remote_port>.+)\s*\n",
re.MULTILINE,
)
def execute_cli(self):
r = []
c = self.cli("show lldp neighbors", cached=True)
for n in c.split("-------------------------\n"):
match = self.rx_lldp.search(n)
if not match:
continue
remote_chassis_id = match.group("remote_id")
if is_ipv4(remote_chassis_id) or is_ipv6(remote_chassis_id):
remote_chassis_id_subtype = LLDP_CHASSIS_SUBTYPE_NETWORK_ADDRESS
elif is_mac(remote_chassis_id):
remote_chassis_id_subtype = LLDP_CHASSIS_SUBTYPE_MAC
else:
n["remote_chassis_id_subtype"] = LLDP_CHASSIS_SUBTYPE_LOCAL
remote_port = match.group("remote_port")
remote_port_subtype = LLDP_PORT_SUBTYPE_ALIAS
if is_ipv4(remote_port):
remote_port = IPv4Parameter().clean(remote_port)
remote_port_subtype = LLDP_PORT_SUBTYPE_NETWORK_ADDRESS
elif is_mac(remote_port):
# Convert MAC to common form
remote_port = MACAddressParameter().clean(remote_port)
remote_port_subtype = LLDP_PORT_SUBTYPE_MAC
elif is_int(remote_port):
remote_port_subtype = LLDP_PORT_SUBTYPE_LOCAL
i = {
"local_interface": match.group("local"),
"neighbors": [
{
"remote_chassis_id": remote_chassis_id,
"remote_chassis_id_subtype": remote_chassis_id_subtype,
"remote_port": remote_port,
"remote_port_sybtype": remote_port_subtype,
"remote_system_name": match.group("remote_system_name"),
"remote_system_description": match.group("remote_system_descr").strip(),
"remote_capabilities": lldp_caps_to_bits(
match.group("caps").strip().split(" "),
{
"bridge": LLDP_CAP_BRIDGE,
"router": LLDP_CAP_ROUTER,
},
),
}
],
}
r += [i]
return r
......@@ -27,3 +27,6 @@ class Profile(BaseProfile):
@classmethod
def get_interface_type(cls, name):
return cls.INTERFACE_TYPES.get(name[:2])
def convert_interface_name(self, interface):
return interface
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