Commit 75f19c41 authored by bee26's avatar bee26 Committed by Andrey Vertiprahov

add_get_lldp_neighbors_AlliedTelesis.AT9900

parent af4b6af0
......@@ -46,7 +46,7 @@ class Script(BaseScript):
port = "port" + match.group("port")
i = {
"name": port,
"type": "physical",
"type": self.profile.get_interface_type(port),
"admin_status": True,
"oper_status": match.group("oper_status") == "Up",
"subinterfaces": [
......@@ -96,7 +96,7 @@ class Script(BaseScript):
vlan_id = vlan.replace("vlan", "")
i = {
"name": vlan,
"type": "SVI",
"type": self.profile.get_interface_type(vlan),
"admin_status": True,
"oper_status": True,
"subinterfaces": [
......
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# AlliedTelesis.AT9900.get_lldp_neighbors
# ---------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from noc.sa.profiles.Generic.get_lldp_neighbors import Script as BaseScript
from noc.sa.interfaces.igetlldpneighbors import IGetLLDPNeighbors
class Script(BaseScript):
name = "AlliedTelesis.AT9900.get_lldp_neighbors"
interface = IGetLLDPNeighbors
......@@ -22,8 +22,32 @@ class Script(BaseScript):
r"^(Allied Telesis|x900-24XS) (?P<platform>AT[/\w-]+)(, | )version (?P<version>[\d.]+-[\d]+)",
re.MULTILINE | re.DOTALL,
)
rx_serial = re.compile(
r"^Base\s+\d+\s+(?P<platform>\S+)\s+\S+\s+(?P<hardware>\S+)\s+(?P<serial>\S+)",
re.MULTILINE | re.DOTALL,
)
def execute_snmp(self):
v = self.snmp.get("1.3.6.1.2.1.1.1.0")
match = self.re_search(self.rx_ver, v)
version = match.group("version")
for board_num, board_name, board_hw, board_serial in self.snmp.get_tables(
[
"1.3.6.1.4.1.207.8.4.4.5.2.1.3",
"1.3.6.1.4.1.207.8.4.4.5.2.1.4",
"1.3.6.1.4.1.207.8.4.4.5.2.1.5",
],
max_retries=1,
):
if board_num == "1":
return {
"vendor": "Allied Telesis",
"platform": board_name[board_name.find("AT-") :],
"version": version,
"attributes": {"HW version": board_hw.strip(), "Serial Number": board_serial},
}
def execute(self):
def execute_cli(self):
if self.has_snmp():
try:
pl = self.snmp.get("1.3.6.1.4.1.207.8.17.1.3.1.6.1")
......@@ -38,8 +62,14 @@ class Script(BaseScript):
pass
v = self.cli("show system")
match = self.re_search(self.rx_ver, v)
platform = match.group("platform")
version = match.group("version")
match = self.re_search(self.rx_serial, v)
hardware = match.group("hardware")
serial = match.group("serial")
return {
"vendor": "Allied Telesis",
"platform": match.group("platform"),
"version": match.group("version"),
"platform": platform,
"version": version,
"attributes": {"HW version": hardware, "Serial Number": serial},
}
......@@ -20,3 +20,20 @@ class Profile(BaseProfile):
command_save_config = "create config=boot1.cfg"
pattern_prompt = r"^Manager.*>"
convert_mac = BaseProfile.convert_mac_to_dashed
def convert_interface_name(self, s):
if s.startswith("Port "):
return s[5:]
return s
INTERFACE_TYPES = {
"eth": "physical",
"por": "physical",
"loo": "loopback", # Loopback
"vla": "SVI", # vlan
"un": "unknown",
}
@classmethod
def get_interface_type(cls, name):
return cls.INTERFACE_TYPES.get(name[:3].lower())
Markdown is supported
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