...
 
Commits (2)
......@@ -2,7 +2,7 @@
# ---------------------------------------------------------------------
# AlliedTelesis.AT9900
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -22,4 +22,6 @@ class Script(BaseScript):
def execute(self):
match = self.re_search(self.rx_ver, self.cli("show switch", cached=True))
return match.group("id")
first_mac = match.group("id")
last_mac = first_mac
return {"first_chassis_mac": first_mac, "last_chassis_mac": last_mac}
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# AlliedTelesis.AT9900.get_interfaces
# ---------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import re
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.igetinterfaces import IGetInterfaces
from noc.core.ip import IPv4
class Script(BaseScript):
name = "AlliedTelesis.AT9900.get_interfaces"
cache = True
interface = IGetInterfaces
rx_port = re.compile(
r" Port.+ (?P<port>\d+)\n"
r"\s*Description\s*\.+ (?P<descr>.+)\n"
r"\s*Status.+\n"
r"\s*Link State\s*\.+ (?P<oper_status>Up|Down)\s*\n",
re.MULTILINE,
)
rx_vlan = re.compile(
r"\s*Name\s*.+ (?P<name>\S+)\s*\n"
r"\s*Identifier\s*.+ (?P<vlan_id>\d+)\s*\n"
r"\s*Status.+\n"
r"\s*Type.+\n"
r"\s*Private.+\n"
r"\s*Nested.+\n"
r"\s*Untagged ports.+ (?P<untagged>.+)\n"
r"\s*Tagged ports.+ (?P<tagged>.+)\n",
re.MULTILINE,
)
def execute_cli(self):
ifaces = []
v = self.cli("show switch port")
for match in self.rx_port.finditer(v):
port = match.group("port")
i = {
"name": port,
"type": "physical",
"admin_status": True,
"oper_status": match.group("oper_status") == "Up",
"subinterfaces": [
{
"name": port,
"admin_status": True,
"oper_status": match.group("oper_status") == "Up",
"enabled_afi": ["BRIDGE"],
}
],
}
descr = match.group("descr").strip()
if descr:
i["description"] = descr
i["subinterfaces"][0]["description"] = descr
ifaces += [i]
v = self.cli("show vlan", cached=True)
for match in self.rx_vlan.finditer(v):
tagged = match.group("tagged").strip()
if tagged == "None":
continue
vlan_id = int(match.group("vlan_id"))
tagged = self.expand_rangelist(tagged)
for ifname in tagged:
for iface in ifaces:
if iface["name"] == str(ifname):
sub = iface["subinterfaces"][0]
if "tagged_vlans" in sub:
sub["tagged_vlans"] += [vlan_id]
else:
sub["tagged_vlans"] = [vlan_id]
break
v = self.cli("show ip interface")
ip = ""
vlan = ""
for l in v.splitlines():
line = re.split(r"\s+", l)
if len(line) > 2:
if line[0].startswith("vlan"):
vlan = line[0]
ip = line[2]
continue
if line[0] == "---" and ip != "":
ip_address = "%s/%s" % (ip, IPv4.netmask_to_len(line[2]))
mtu = line[3]
vlan_id = vlan.replace("vlan", "")
i = {
"name": vlan,
"type": "SVI",
"admin_status": True,
"oper_status": True,
"subinterfaces": [
{
"name": vlan,
"admin_status": True,
"oper_status": True,
"mtu": mtu,
"vlan_ids": [vlan_id],
"ipv4_addresses": [ip_address],
"enabled_afi": ["IPv4"],
}
],
}
ifaces += [i]
return [{"interfaces": ifaces}]
......@@ -2,7 +2,7 @@
# ---------------------------------------------------------------------
# AlliedTelesis.AT9900.get_mac_address_table
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -42,7 +42,7 @@ class Script(BaseScript):
"vlan_id": match.group("vlan_id"),
"mac": match.group("mac"),
"interfaces": [match.group("interfaces")],
"type": match.group("type"),
"type": {"dynamic": "D", "static": "S"}[match.group("type")],
}
]
return r
......@@ -2,7 +2,7 @@
# ---------------------------------------------------------------------
# AlliedTelesis.AT9900.get_version
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -19,7 +19,7 @@ class Script(BaseScript):
cache = True
interface = IGetVersion
rx_ver = re.compile(
r"^Allied Telesis (?P<platform>AT[/\w-]+) version " r"(?P<version>[\d.]+-[\d]+)",
r"^(Allied Telesis|x900-24XS) (?P<platform>AT[/\w-]+)(, | )version (?P<version>[\d.]+-[\d]+)",
re.MULTILINE | re.DOTALL,
)
......@@ -28,7 +28,12 @@ class Script(BaseScript):
try:
pl = self.snmp.get("1.3.6.1.4.1.207.8.17.1.3.1.6.1")
ver = self.snmp.get("1.3.6.1.4.1.207.8.17.1.3.1.5.1")
return {"vendor": "Allied Telesis", "platform": pl, "version": ver.lstrip("v")}
if pl and ver:
return {
"vendor": "Allied Telesis",
"platform": pl,
"version": ver.lstrip("v"),
}
except self.snmp.TimeOutError:
pass
v = self.cli("show system")
......
......@@ -3,7 +3,7 @@
# Vendor: Allied Telesis
# OS: AT9900
# ---------------------------------------------------------------------
# Copyright (C) 2007-2011 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -19,4 +19,9 @@ class Profile(BaseProfile):
command_submit = "\r"
command_save_config = "create config=boot1.cfg"
pattern_prompt = r"^Manager.*>"
convert_mac = BaseProfile.convert_mac_to_cisco
convert_mac = BaseProfile.convert_mac_to_dashed
def convert_interface_name(self, s):
if s.startswith("Port "):
return s[5:]
return s