...
 
Commits (2)
...@@ -46,7 +46,7 @@ class Script(BaseScript): ...@@ -46,7 +46,7 @@ class Script(BaseScript):
port = "port" + match.group("port") port = "port" + match.group("port")
i = { i = {
"name": port, "name": port,
"type": "physical", "type": self.profile.get_interface_type(port),
"admin_status": True, "admin_status": True,
"oper_status": match.group("oper_status") == "Up", "oper_status": match.group("oper_status") == "Up",
"subinterfaces": [ "subinterfaces": [
...@@ -96,7 +96,7 @@ class Script(BaseScript): ...@@ -96,7 +96,7 @@ class Script(BaseScript):
vlan_id = vlan.replace("vlan", "") vlan_id = vlan.replace("vlan", "")
i = { i = {
"name": vlan, "name": vlan,
"type": "SVI", "type": self.profile.get_interface_type(vlan),
"admin_status": True, "admin_status": True,
"oper_status": True, "oper_status": True,
"subinterfaces": [ "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): ...@@ -22,8 +22,32 @@ class Script(BaseScript):
r"^(Allied Telesis|x900-24XS) (?P<platform>AT[/\w-]+)(, | )version (?P<version>[\d.]+-[\d]+)", r"^(Allied Telesis|x900-24XS) (?P<platform>AT[/\w-]+)(, | )version (?P<version>[\d.]+-[\d]+)",
re.MULTILINE | re.DOTALL, 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(): if self.has_snmp():
try: try:
pl = self.snmp.get("1.3.6.1.4.1.207.8.17.1.3.1.6.1") 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): ...@@ -38,8 +62,14 @@ class Script(BaseScript):
pass pass
v = self.cli("show system") v = self.cli("show system")
match = self.re_search(self.rx_ver, v) 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 { return {
"vendor": "Allied Telesis", "vendor": "Allied Telesis",
"platform": match.group("platform"), "platform": platform,
"version": match.group("version"), "version": version,
"attributes": {"HW version": hardware, "Serial Number": serial},
} }
...@@ -20,3 +20,20 @@ class Profile(BaseProfile): ...@@ -20,3 +20,20 @@ class Profile(BaseProfile):
command_save_config = "create config=boot1.cfg" command_save_config = "create config=boot1.cfg"
pattern_prompt = r"^Manager.*>" pattern_prompt = r"^Manager.*>"
convert_mac = BaseProfile.convert_mac_to_dashed 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())