Commit 163312d2 authored by bee26's avatar bee26
Browse files

Merge branch 'fix/nsn_timos_get_interfaces' into 'master'

NSN.TIMOS Fix get_intefaces script

See merge request noc/noc!3306
parents 86c18af5 600b02fc
......@@ -2,11 +2,10 @@
# ----------------------------------------------------------------------
# NSN.TIMOS.get_interfaces
# ----------------------------------------------------------------------
# Copyright (C) 2007-2019 The NOC Project
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
# Python modules
import re
......@@ -133,12 +132,11 @@ class Script(BaseScript):
)
re_port_info = re.compile(
r"""
^(?P<name>\d+/\d+/\d+)\s+
^(?P<name>((esat-|)\d+/\d+/(c\d+|\d+)(/\d+|/u\d+|)|\w+\/\d+))\s+
(?P<admin_status>\S*)\s+
(?P<bad_stat>\S*)\s+
(?:Link\s)?(?P<oper_status>\S*)\s+
(?P<mtu>\d*)\s+
(?P<oper_mtu>\d*)\s+
(?P<mtu>\d*)\s+(?P<oper_mtu>\d*)\s+
(?P<aggregated_interface>\d*)\s
""",
re.VERBOSE | re.MULTILINE | re.DOTALL,
......@@ -160,6 +158,16 @@ class Script(BaseScript):
""",
re.VERBOSE | re.MULTILINE | re.DOTALL,
)
re_port_detail_info_sr = re.compile(
r"""
Description\s*?:\s(?P<description>.*?)\n
Interface\s*?:\s(?P<name>((esat-|)\d+/\d+/(c\d+|\d+)(/\d+|/u\d+|)|\w+\/\d+))\s*[\S\s]+
Admin\sState\s*?:\s(?P<admin_status>.*?)\s.*?
Oper\sState\s*?:\s(?P<oper_status>.*?)\s.*?
IfIndex\s*?:\s(?P<snmp_ifindex>\d*)\s.*?
""",
re.VERBOSE | re.MULTILINE | re.DOTALL,
)
re_lag_detail = re.compile(
r"""
Description\s*?:\s(?P<description>.+?)\n-{79}
......@@ -500,14 +508,14 @@ class Script(BaseScript):
def get_base_router(self):
fi = {"forwarding_instance": "default", "type": "ip", "interfaces": []}
port_info = self.cli("show port")
for line in port_info.splitlines():
match = self.re_port_info.search(line)
if match:
port_detail = self.cli("show port %s detail" % match.group("name"))
match_detail = self.re_port_detail_info.search(port_detail)
if not match_detail:
match_detail = self.re_port_detail_info_sr.search(port_detail)
my_dict = match.groupdict()
my_dict.update(match_detail.groupdict())
if "aggregated_interface" in my_dict:
......
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