From 0c1faa4150448f2d51f171fedd66c6e54e197549 Mon Sep 17 00:00:00 2001 From: Your Name Date: Thu, 16 Apr 2020 19:39:21 +0500 Subject: [PATCH] Orion.NOS. Add convert_interface_name method. --- sa/profiles/Orion/NOS/get_interfaces.py | 19 ++++++++++--------- sa/profiles/Orion/NOS/profile.py | 7 +++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/sa/profiles/Orion/NOS/get_interfaces.py b/sa/profiles/Orion/NOS/get_interfaces.py index 5985268644..4cdcefa9fa 100644 --- a/sa/profiles/Orion/NOS/get_interfaces.py +++ b/sa/profiles/Orion/NOS/get_interfaces.py @@ -5,12 +5,14 @@ # Copyright (C) 2007-2018 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 -import re class Script(BaseScript): @@ -53,11 +55,11 @@ class Script(BaseScript): def get_stp(self): # Need more examples return [] - try: - v = self.cli("show spanning-tree") - return self.rx_enabled.findall(v) - except self.CLISyntaxError: - return [] + # try: + # v = self.cli("show spanning-tree") + # return self.rx_enabled.findall(v) + # except self.CLISyntaxError: + # return [] def get_ctp(self): try: @@ -85,7 +87,6 @@ class Script(BaseScript): return self.rx_enabled.findall(v) except self.CLISyntaxError: return [] - return [] def execute_cli(self): interfaces = [] diff --git a/sa/profiles/Orion/NOS/profile.py b/sa/profiles/Orion/NOS/profile.py index 907129a5ac..acd3eaa835 100644 --- a/sa/profiles/Orion/NOS/profile.py +++ b/sa/profiles/Orion/NOS/profile.py @@ -29,6 +29,8 @@ class Profile(BaseProfile): r"tacacs(-server | accounting-server )encrypt-key \S+\n", ] + rx_interface_name = re.compile(r"port\s*(?P\d+)") + rx_ver = re.compile( r"^Product name\s*:\s*(?P.+)\s*\n" r"^NOS\s+Version:? NOS_(?P\d+\.\d+\.\d+).+\n" @@ -63,3 +65,8 @@ class Profile(BaseProfile): if not match: match = self.rx_ver2.search(c) return match.groupdict() + + def convert_interface_name(self, s): + if self.rx_interface_name.match(s): + return self.rx_interface_name.match(s).group("re_port") + return s -- GitLab