Commit 5cba9b93 authored by MaksimSmile13's avatar MaksimSmile13
Browse files

Update Ericsson SEOS Profile

parent 86a47a47
......@@ -7,6 +7,8 @@
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import re
# NOC modules
from noc.core.profile.base import BaseProfile
......@@ -20,8 +22,9 @@ class Profile(BaseProfile):
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"
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"]
......@@ -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
......
......@@ -6,8 +6,6 @@
# See LICENSE for details
# ---------------------------------------------------------------------
# Third-party modules
import six
# NOC modules
from noc.sa.profiles.Generic.get_interface_status_ex import Script as BaseScript
from noc.sa.interfaces.igetinterfacestatusex import IGetInterfaceStatusEx
......@@ -78,7 +76,7 @@ class Script(BaseScript):
# Log unknown interfaces
if unknown_interfaces:
self.logger.info("%d unknown interfaces has been ignored", len(unknown_interfaces))
for ifindex, rr in six.iteritems(radio):
for ifindex, rr in radio.iteritems():
rr["in_speed"] = self.snmp.get("1.3.6.1.4.1.193.81.3.4.1.1.14.1.7.1")
rr["out_speed"] = self.snmp.get("1.3.6.1.4.1.193.81.3.4.1.1.14.1.7.1")
res[ifindex] = rr
......
......@@ -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:
......
# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------
# Ericsson.SEOS.get_inventory
# ---------------------------------------------------------------------
# Copyright (C) 2007-2013 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
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):
name = "Ericsson.SEOS.get_inventory"
interface = IGetInventory
rx_trans = re.compile(
r"Port\s*:\s*(\S+)\s*XFP\s*\S+\s*Media\s*"
r"Type\s*:\s*([A-Za-z0-9 \/]+)\s*"
r"Redback\s*Approved\s*:\s*(YES|NO)\s*"
r"Diagnostic\s*Monitoring\s*:\s*\S+\s*"
r"CLEI\s*code\s*:\s*\S*\s*"
r"Serial\s*Number\s*:\s*(\S+)\s*\S+\s*:\s*(\S*)",
re.DOTALL | re.IGNORECASE | re.MULTILINE)
def execute(self):
objects = []
v = self.cli("show hardware")
media = self.cli("show port trans")
for l in v.splitlines():
if "backplane" in l:
objects += [{
"builtin": False,
"description": "Chassis backplane",
"number": 0,
"part_no": "SE600",
"serial": l.split()[2].strip(),
"vendor": "Ericsson",
"type": "CHASSIS"
}]
elif "fan tray" in l:
objects += [{
"builtin": False,
"description": "Fan Tray",
"number": 1,
"part_no": "SE600-FAN",
"serial": l.split()[3].strip(),
"vendor": "Ericsson",
"type": "FAN"
}]
elif "alarm card" in l:
objects += [{
"builtin": False,
"description": "Alarm Card",
"number": 0,
"part_no": "SE600-ALARM",
"serial": l.split()[3].strip(),
"vendor": "Ericsson",
"type": "ALRM"
}]
elif "-port" in l:
objects += [{
"builtin": False,
"description": l.split()[1].strip(),
"number": l.split()[0].strip(),
"part_no": l.split()[1].strip(),
"serial": l.split()[2].strip(),
"vendor": "Ericsson",
"type": "CARD"
}]
for match in self.rx_trans.findall(media):
if l.split()[0].strip() == match[0].split("/")[0]:
objects += [{
"builtin": False,
"description": match[1].strip() + " " +
match[4].strip(),
"number": match[0][2:],
"part_no": match[1].strip(),
"serial": match[3],
"vendor": "NoName",
"type": "XCVR"
}]
elif "xcrp" in l:
objects += [{
"builtin": False,
"description": l.split()[1].strip(),
"number": l.split()[0].strip(),
"part_no": l.split()[1].strip(),
"serial": l.split()[2].strip(),
"vendor": "Ericsson",
"type": "MGMT"
}]
return objects
......@@ -24,12 +24,13 @@ class Script(BaseScript):
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
......
{
"$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