Commit 1d250c11 authored by MaksimSmile13's avatar MaksimSmile13
Browse files

Merge branch 'update/ericsson_soes_profile' into 'master'

Update Ericsson SEOS Profile

See merge request noc/noc!2218

(cherry picked from commit 2181732d)

5cba9b93 Update Ericsson SEOS Profile
574bf9e5 Fix profile Ericsson.SEOS
63bb861f some fix
8443dceb Some Fix
fb5ece07 Update Ericsson.SEOS Profile
parent c84d4330
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Vendor: Ericsson
# OS: SEOS
# ---------------------------------------------------------------------
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
"""
For correct polling on snmp it is necessary to enable "snmp extended read" in settings
"""
name = "Ericsson.SEOS"
pattern_more = "^---(more)---"
pattern_unprivileged_prompt = \
r"^(?:\[(?P<context>\S+)\])?(?P<hostname>\S+)>"
pattern_prompt = r"^(?:\[(?P<context>\S+)\])?(?P<hostname>\S+)#"
pattern_syntax_error = r"% Invalid input at"
command_disable_pager = "terminal length 0"
command_super = "enable"
command_enter_config = "configure"
command_leave_config = "exit"
......@@ -13,9 +13,10 @@ from noc.sa.interfaces.igetconfig import IGetConfig
class Script(BaseScript):
name = "Ericsson.SEOS.get_config"
cache = True
interface = IGetConfig
def execute_cli(self, **kwargs):
config = self.cli("show config")
config = self.strip_first_lines(config, 3)
config = self.cli("show running-config", cached=True)
config = self.strip_first_lines(config, 1)
return self.cleaned_config(config)
......@@ -27,13 +27,20 @@ class Script(BaseScript):
def execute_snmp(self):
r = {}
unknown_interfaces = []
for oid, index in self.snmp.getnext(mib["IF-MIB::ifIndex"], max_retries=self.get_getnext_retires()):
name = self.snmp.get(mib["IF-MIB::ifName", index])
descr = self.snmp.get(mib["IF-MIB::ifDescr", index])
d = {}
for doid, descr in self.snmp.getnext(mib["IF-MIB::ifDescr"], max_retries=self.get_getnext_retires()):
dindex = int(doid.split(".")[-1])
d[dindex] = descr
for oid, name in self.snmp.getnext(mib["IF-MIB::ifName"], max_retries=self.get_getnext_retires()):
index = int(oid.split(".")[-1])
if not name:
continue
if r.get(name):
name = "%s-%s" % (name, d[index])
try:
v = self.profile.convert_interface_name("%s/%s" % (name, descr))
v = self.profile.convert_interface_name(name.strip())
except InterfaceTypeError as e:
self.logger.debug("Ignoring unknown interface %s: %s", "%s/%s" % (name, descr), e)
self.logger.debug("Ignoring unknown interface %s: %s", name, e)
unknown_interfaces += [name]
continue
r[v] = index
......
......@@ -26,7 +26,7 @@ class Script(BaseScript):
1: "physical",
6: "physical", # ethernetCsmacd
18: "physical", # E1 - ds1
23: "tunnel", # ppp
23: "physical", # ppp
24: "loopback", # softwareLoopback
117: "physical", # gigabitEthernet
131: "tunnel", # tunnel
......@@ -36,12 +36,10 @@ class Script(BaseScript):
54: "physical" # propMultiplexor
}
def execute_snmp(self, interface=None, last_ifname=None):
last_ifname = self.collect_ifnames()
def execute_snmp(self, interface=None):
# v = self.scripts.get_interface_status_ex()
index = self.scripts.get_ifindexes()
# index = self.get_ifindexes()
aggregated, portchannel_members = self.get_aggregated_ifaces()
ifaces = dict((index[i], {"interface": i}) for i in index)
# Apply ifAdminStatus
self.apply_table(ifaces, "IF-MIB::ifAdminStatus", "admin_status", lambda x: x == 1)
......@@ -64,8 +62,6 @@ class Script(BaseScript):
"""
for l in ifaces:
iface = ifaces[l]
if last_ifname and iface["interface"] not in last_ifname:
continue
i_type = self.get_interface_type(iface["type"])
i = {
"name": iface["interface"],
......@@ -76,15 +72,8 @@ class Script(BaseScript):
if iface.get("admin_status") else False,
"snmp_ifindex": l,
}
if i["name"] in portchannel_members:
i["aggregated_interface"], lacp = portchannel_members[i["name"]]
if lacp:
i["enabled_protocols"] = ["LACP"]
if i["name"] in aggregated:
i["type"] = "aggregated"
if iface.get("mac_address") and is_mac(iface["mac_address"]):
i["mac"] = MAC(iface["mac_address"])
# sub = {"subinterfaces": [i.copy()]}
r += [i]
for l in r:
if l["name"] in subs:
......
......@@ -2,7 +2,7 @@
# ---------------------------------------------------------------------
# Ericsson.SEOS.get_inventory
# ---------------------------------------------------------------------
# Copyright (C) 2007-2013 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -11,7 +11,6 @@ import re
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.igetinventory import IGetInventory
from noc.sa.interfaces.base import InterfaceTypeError
class Script(BaseScript):
......@@ -27,10 +26,13 @@ class Script(BaseScript):
r"Serial\s*Number\s*:\s*(\S+)\s*\S+\s*:\s*(\S*)",
re.DOTALL | re.IGNORECASE | re.MULTILINE)
def execute(self):
def execute_cli(self):
objects = []
v = self.cli("show hardware")
media = self.cli("show port trans")
try:
v = self.cli("show hardware")
media = self.cli("show port trans")
except self.CLISyntaxError:
raise self.NotSupportedError("Not supported on")
for l in v.splitlines():
if "backplane" in l:
objects += [{
......@@ -76,8 +78,7 @@ class Script(BaseScript):
if l.split()[0].strip() == match[0].split("/")[0]:
objects += [{
"builtin": False,
"description": match[1].strip() + " " +
match[4].strip(),
"description": match[1].strip() + " " + match[4].strip(),
"number": match[0][2:],
"part_no": match[1].strip(),
"serial": match[3],
......@@ -95,4 +96,3 @@ class Script(BaseScript):
"type": "MGMT"
}]
return objects
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Ericsson.MINI_LINK.get_mac_address_table
# ---------------------------------------------------------------------
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# NOC modules
from noc.core.script.base import BaseScript
from noc.sa.interfaces.igetmacaddresstable import IGetMACAddressTable
from noc.lib.text import parse_table
from noc.lib.validators import is_int
class Script(BaseScript):
name = "Ericsson.SEOS.get_mac_address_table"
interface = IGetMACAddressTable
def execute(self, interface=None, vlan=None, mac=None):
cmd = self.cli("show mac-address-table")
# if mac is not None:
# cmd += " address %s" % mac
if interface is not None:
cmd += " port %s" % interface
if vlan is not None:
cmd += " vlan %s" % vlan
r = []
t = parse_table(cmd, footer="^show mac-address-table")
for i in t:
if is_int(i[0]):
r += [{
"vlan_id": i[0],
"mac": i[1],
"interfaces": [self.profile.convert_interface_name(i[4])],
"type": "D" if i[2] == "learned" else "S"
}]
return r
......@@ -20,16 +20,18 @@ class Script(BaseScript):
rx_ver = re.compile(r"^Active SBL\s+:\s+CXP:\s+(?P<version>\S+.*)\s+"
r"^Passive (?:NPU|SBL)\s+:\s+CXP:\s+[\S\s]+"
r"^Active BNS\s+:\s+CXCR:\s+(?P<sw_backup>\S+.*)$",
r"^Active BNS\s+:\s+CXCR:\s+(?P<sw_backup>\S+.*)\s+"
r"^Subrack\s+:\s+(?P<platform>\S+.*)\s+\-",
re.MULTILINE)
def execute_snmp(self):
platform = self.snmp.get("1.3.6.1.2.1.1.1.0", cached=True)
active_rev = self.snmp.get("1.3.6.1.4.1.193.81.2.7.1.3.0", cached=True)
version = self.snmp.get("1.3.6.1.4.1.193.81.2.7.1.2.1.3.%s" % active_rev, cached=True)
serial = self.snmp.get("1.3.6.1.4.1.193.81.2.7.1.2.1.2.%s" % active_rev, cached=True)
return {
"vendor": "Ericsson",
"platform": "Mini-Link",
"platform": platform.replace("Traffic Node", "TN").replace("Compact Node", "CN"),
"version": version,
"attributes": {
"Serial Number": serial
......@@ -39,12 +41,14 @@ class Script(BaseScript):
def execute_cli(self):
ver = self.cli("show version", cached=True)
for match in self.rx_ver.finditer(ver):
print match
version = match.group("version")
sw_backup = match.group("sw_backup")
platform = match.group("platform")
return {
"vendor": "Ericsson",
"platform": "Mini-Link",
"version": version,
"platform": platform.replace("Traffic Node", "TN").replace("Compact Node", "CN"),
"version": version.strip(),
"attributes": {
"sw_backup": sw_backup
}
......
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Vendor: Ericsson
# OS: SEOS
# ---------------------------------------------------------------------
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import re
# NOC modules
from noc.core.profile.base import BaseProfile
class Profile(BaseProfile):
"""
For correct polling on snmp it is necessary to enable "snmp extended read" in settings
"""
name = "Ericsson.SEOS"
pattern_more = "^---(more)---"
pattern_unprivileged_prompt = \
r"^(?:\[(?P<context>\S+)\])?(?P<hostname>\S+)>"
pattern_prompt = r"^(?:\[(?P<context>\S+)\])?(?P<hostname>\S+)#"
pattern_syntax_error = r"% Invalid input at|% ERROR Invalid input detected"
command_disable_pager = "terminal length 0"
command_super = "enable"
command_enter_config = "configure"
command_leave_config = "exit"
rogue_chars = [re.compile(r"\x08{4,}\S+"), "\r"]
rx_ifname = re.compile("\S+\s+\d+\/\d+\/\d+")
def convert_interface_name(self, s):
"""
>>> Profile().convert_interface_name("LAN 1/1/8")
'1/1/8-LAN'
>>> Profile().convert_interface_name("1/1/8-LAN")
'1/1/8-LAN'
"""
match = self.rx_ifname.match(s)
if match:
iface = s.split()
return "%s-%s" % (iface[1], iface[0])
else:
return s
{
"$metric": "Radio | RxPower",
"$type": "ifindex",
"oid": "1.3.6.1.4.1.193.81.3.4.3.1.3.1.10.{{ ifIndex }}",
"type": "gauge",
"scale": "scale(0.1)"
}
\ No newline at end of file
{
"$metric": "Radio | TxPower",
"$type": "ifindex",
"oid": "1.3.6.1.4.1.193.81.3.4.3.1.3.1.1.{{ ifIndex }}",
"type": "gauge"
}
\ No newline at end of file
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