From 5c1d542fa9f2ccf74d69b411fc95c42cf67c3105 Mon Sep 17 00:00:00 2001 From: Dmitry Luhtionov Date: Tue, 2 Nov 2021 15:44:45 +0200 Subject: [PATCH 1/2] Fix Raisecom.ROS.get_version script --- sa/profiles/Raisecom/ROS/get_version.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sa/profiles/Raisecom/ROS/get_version.py b/sa/profiles/Raisecom/ROS/get_version.py index 1b9c2b1dfc..c845e70f7f 100644 --- a/sa/profiles/Raisecom/ROS/get_version.py +++ b/sa/profiles/Raisecom/ROS/get_version.py @@ -1,7 +1,7 @@ # --------------------------------------------------------------------- # Raisecom.ROS.get_version # --------------------------------------------------------------------- -# Copyright (C) 2007-2018 The NOC Project +# Copyright (C) 2007-2021 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- @@ -88,7 +88,7 @@ class Script(BaseScript): r"Product name:\s*(Gazelle |)(?P\S+)\s*\n" r"(ROS|QOS)\s+Version(:|)\s*(?P\S+)(\.|)\s*\(Compiled(?P.+)\)\s*\n" r"Product Version: \S+\s*\n" - r"BOOT Room Version\s*(:|)\s*(?P\S+)\s*\n" + r"BOOT Room Version\s*(:|)\s*(Gazelle |)(?P\S+)\s*\n" r"CPLD Version: \S+\s*\n" r"Hardware\s*(Gazelle |)\S*\s*Version(\sRev\.|:)?\s*(?P\S+)\s*\n\n" r"System MacAddress( is)?\s*:\s*(?P\S+)\s*\n" -- GitLab From 84d4abb5ad13c799f6c084243ca6cf6c81b092a1 Mon Sep 17 00:00:00 2001 From: Andrey Vertiprahov Date: Sat, 13 Nov 2021 10:18:36 +0500 Subject: [PATCH 2/2] Add is_gazelle matcher. --- core/profile/base.py | 10 +++++----- sa/profiles/Raisecom/ROS/get_interfaces.py | 19 +++++++++++++++---- sa/profiles/Raisecom/ROS/profile.py | 14 +++++++------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/core/profile/base.py b/core/profile/base.py index 7a3ea96538..21edf339e8 100644 --- a/core/profile/base.py +++ b/core/profile/base.py @@ -47,7 +47,7 @@ class BaseProfileMetaclass(type): "%s: 'command_more' is deprecated and will be removed in NOC 20.3" % n.name, RemovedInNOC2003Warning, ) - if isinstance(n.pattern_more, str): + if isinstance(n.pattern_more, (str, bytes)): warnings.warn( "%s: 'command_more' must be a list of (pattern, command). " "Support for textual 'command_more' will be removed in NOC 20.3" % n.name, @@ -119,12 +119,12 @@ class BaseProfile(object, metaclass=BaseProfileMetaclass): Deprecated """ - pattern_username = "([Uu]ser ?[Nn]ame|[Ll]ogin): ?" + pattern_username = rb"([Uu]ser ?[Nn]ame|[Ll]ogin): ?" """ List[str]: Regular expression to catch user name prompt. Usually during telnet sessions) """ - pattern_password = "[Pp]ass[Ww]ord: ?" + pattern_password = rb"[Pp]ass[Ww]ord: ?" """ Optional[regexp]: Regulal expression to catch password prompt (Telnet/SSH sessions) """ @@ -135,7 +135,7 @@ class BaseProfile(object, metaclass=BaseProfileMetaclass): (Telnet/SSH sessions) """ - pattern_prompt = r"^\S*[>#]" + pattern_prompt = rb"^\S*[>#]" """ Optional[regexp]: Regular expression to catch command prompt (CLI Sessions) """ @@ -146,7 +146,7 @@ class BaseProfile(object, metaclass=BaseProfileMetaclass): (CLI Session) """ - pattern_more = "^---MORE---" + pattern_more = rb"^---MORE---" """ Optional[regexp]: Regular expression to catch pager (Used in command results) diff --git a/sa/profiles/Raisecom/ROS/get_interfaces.py b/sa/profiles/Raisecom/ROS/get_interfaces.py index 8ea0cf2190..f1e008d2b1 100644 --- a/sa/profiles/Raisecom/ROS/get_interfaces.py +++ b/sa/profiles/Raisecom/ROS/get_interfaces.py @@ -124,7 +124,7 @@ class Script(BaseScript): def get_switchport_cli(self): r = {} - if self.is_rotek: + if self.is_rotek or self.is_gazelle: return r v = self.cli("show interface port switchport") for section in v.split("Port"): @@ -236,7 +236,7 @@ class Script(BaseScript): return self.execute_iscom2624g() lldp_ifaces = self.get_lldp_config() interfaces = {} - if not self.is_rotek: + if not self.is_rotek and not self.is_gazelle: v = self.cli("show interface port description") for line in v.splitlines()[2:-1]: ifname = int(line[:8]) @@ -285,7 +285,11 @@ class Script(BaseScript): "description": match.group("descr").strip(), "enabled_protocols": [], "subinterfaces": [ - {"name": match.group("port"), "description": match.group("descr").strip()} + { + "name": match.group("port"), + "enabled_afi": [], + "description": match.group("descr").strip(), + } ], } interfaces[i["name"]] = i @@ -307,12 +311,19 @@ class Script(BaseScript): interfaces[p_name]["subinterfaces"][0]["tagged_vlans"] = [vlan_id] else: interfaces[p_name]["subinterfaces"][0]["untagged_vlan"] = vlan_id + # Check vlans + for iface in interfaces.values(): + if ( + "tagged_vlans" in iface["subinterfaces"][0] + or "untagged_vlan" in iface["subinterfaces"][0] + ): + iface["subinterfaces"][0]["enabled_afi"] += ["BRIDGE"] ifdescr = self.get_iface_ip_description() v = self.scripts.get_chassis_id() mac = v[0]["first_chassis_mac"] # XXX: This is a dirty hack !!! # I do not know, how get ip interface MAC address - if not self.is_rotek: + if not self.is_rotek and not self.is_gazelle: try: v = self.cli("show interface ip") except self.CLISyntaxError: diff --git a/sa/profiles/Raisecom/ROS/profile.py b/sa/profiles/Raisecom/ROS/profile.py index 27f9f8f7e8..0c0fa71a3b 100644 --- a/sa/profiles/Raisecom/ROS/profile.py +++ b/sa/profiles/Raisecom/ROS/profile.py @@ -16,14 +16,13 @@ from noc.core.confdb.syntax.patterns import ANY class Profile(BaseProfile): name = "Raisecom.ROS" - pattern_more = r"^ --More--\s*" - pattern_unprivileged_prompt = r"^\S+?>" + pattern_unprivileged_prompt = rb"^\S+?>" command_super = "enable" - pattern_prompt = r"^\S+?#" - command_more = " " + pattern_prompt = rb"^\S+?#" command_exit = "exit" - pattern_syntax_error = r"(% \".+\" (?:Unknown command.)|Error input in the position marke[dt] by|%\s+Incomplete command\.)" - pattern_operation_error = r"% You Need higher priority!" + pattern_more = [(rb"^ --More--\s*", b" ")] + pattern_syntax_error = rb"(% \".+\" (?:Unknown command.)|Error input in the position marke[dt] by|%\s+Incomplete command\.)" + pattern_operation_error = rb"% You Need higher priority!" rogue_chars = [re.compile(rb"\x08+\s+\x08+"), b"\r"] config_volatile = [ r"radius(-server | accounting-server |-)encrypt-key \S+\n", @@ -38,8 +37,9 @@ class Profile(BaseProfile): collators = ["noc.core.confdb.collator.ifname.IfNameCollator"] matchers = { - "is_iscom2624g": {"platform": {"$regex": "ISCOM26(?:24|08)G"}}, + "is_iscom2624g": {"platform": {"$regex": r"ISCOM26(?:24|08)G"}}, "is_rotek": {"vendor": {"$in": ["Rotek", "ROTEK"]}}, + "is_gazelle": {"platform": {"$regex": r"^[SR]\d+[Ii]\S+"}}, "is_ifname_use": {"platform": {"$regex": "QSW-8200"}}, } -- GitLab