Commit b931ee59 authored by Dmitry Lukhtionov's avatar Dmitry Lukhtionov
Browse files

Merge branch 'add-ubiquiti/wa-support' into 'master'

Add ubiquiti/wa support

See merge request noc/noc!3028
parents 5f9038c7 3ac19833
......@@ -11,6 +11,7 @@ import re
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.igetversion import IGetVersion
from noc.sa.interfaces.base import MACAddressParameter
class Script(BaseScript):
......@@ -18,20 +19,41 @@ class Script(BaseScript):
cache = True
interface = IGetVersion
rx_version = re.compile(r"^\S+\.v(?P<version>[^@]+)$")
rx_version = re.compile(r"^(?P<prefix>\S+)\.\S+?\.(?P<version>(v\d+\.\d+.\d+))\.\S+$")
def execute_cli(self):
# Replace # with @ to prevent prompt matching
v = self.cli("cat /etc/version").strip()
v_match = self.rx_version.search(v)
version = self.cli("cat /etc/version").strip()
board = self.cli("grep board.name /etc/board.info").strip()
board = board.split("=", 1)[1].strip()
return {"vendor": "Ubiquiti", "platform": board, "version": v_match.group("version")}
serial = self.cli("grep board.hwaddr /etc/board.info").strip()
serial = serial.split("=", 1)[1].strip()
return {
"vendor": "Ubiquiti",
"platform": board,
"version": version,
"attributes": {"Serial Number": serial},
}
def execute_snmp(self):
try:
platform = self.snmp.get("1.2.840.10036.3.1.2.1.3.5")
version = self.snmp.get("1.2.840.10036.3.1.2.1.4.5")
return {"vendor": "Ubiquiti", "platform": platform, "version": version}
serial = self.snmp.get("1.2.840.10036.2.1.1.1.5")
except self.snmp.SNMPError as e:
# NO_SUCH_NAME
if e.code == 2:
platform = self.snmp.get("1.2.840.10036.3.1.2.1.3.8")
version = self.snmp.get("1.2.840.10036.3.1.2.1.4.8")
serial = self.snmp.get("1.2.840.10036.2.1.1.1.8")
except self.snmp.TimeOutError:
raise self.UnexpectedResultError
v_match = self.rx_version.search(version)
version = v_match.group("prefix") + "." + v_match.group("version")
serial = MACAddressParameter().clean(serial).replace(":", "").upper()
return {
"vendor": "Ubiquiti",
"platform": platform,
"version": version,
"attributes": {"Serial Number": serial},
}
......@@ -14,7 +14,7 @@ class Profile(BaseProfile):
name = "Ubiquiti.AirOS"
pattern_username = r"([Uu][Bb][Nn][Tt] login|[Ll]ogin):"
pattern_more = r"CTRL\+C.+?a All"
pattern_prompt = r"^\S+?\.v(?P<version>\S+)#"
pattern_prompt = r"^\S+?(\.v(?P<version>\S+))?#"
command_more = "a"
config_volatile = [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