From 93efe89ed9a4586c195fdc90ba3b0de5203ef045 Mon Sep 17 00:00:00 2001 From: Andrey Vertiprahov Date: Mon, 10 Jan 2022 10:21:55 +0500 Subject: [PATCH] Cisco.SMB.get_interfaces. Add SNMP. --- sa/profiles/Cisco/SMB/get_interfaces.py | 18 +++--------------- sa/profiles/Cisco/SMB/profile.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/sa/profiles/Cisco/SMB/get_interfaces.py b/sa/profiles/Cisco/SMB/get_interfaces.py index 98adb16286..90f8f99ef7 100644 --- a/sa/profiles/Cisco/SMB/get_interfaces.py +++ b/sa/profiles/Cisco/SMB/get_interfaces.py @@ -9,7 +9,7 @@ import re # NOC modules -from noc.core.script.base import BaseScript +from noc.sa.profiles.Generic.get_interfaces import Script as BaseScript from noc.sa.interfaces.igetinterfaces import IGetInterfaces from noc.core.text import parse_table @@ -26,18 +26,6 @@ class Script(BaseScript): re.IGNORECASE, ) - INTERFACE_TYPES = { - "Et": "physical", # Ethernet - "Fa": "physical", # FastEthernet - "Gi": "physical", # GigabitEthernet - "Te": "physical", # TenGigabitEthernet - "Lo": "loopback", # Loopback - "Po": "aggregated", # Port-channel/Portgroup - "Tu": "tunnel", # Tunnel - "Vl": "SVI", # Vlan - "oo": "management", # oob - } - def execute_cli(self): reply = [{"forwarding_instance": "default", "type": "ip", "interfaces": []}] @@ -63,7 +51,7 @@ class Script(BaseScript): oper_status = True interface = { "name": iface, - "type": self.INTERFACE_TYPES.get(iface[:2], "unknown"), + "type": self.profile.get_interface_type(iface), "admin_status": admin_status, "oper_status": oper_status, "subinterfaces": [ @@ -104,7 +92,7 @@ class Script(BaseScript): oper_status = row[5].strip().lower() == "up" interface = { "name": iface, - "type": self.INTERFACE_TYPES.get(iface[:2], "unknown"), + "type": self.profile.get_interface_type(iface), "oper_status": oper_status, "subinterfaces": [ {"name": iface, "oper_status": oper_status, "enabled_afi": ["BRIDGE"]} diff --git a/sa/profiles/Cisco/SMB/profile.py b/sa/profiles/Cisco/SMB/profile.py index 8046863691..ca94165e20 100644 --- a/sa/profiles/Cisco/SMB/profile.py +++ b/sa/profiles/Cisco/SMB/profile.py @@ -38,6 +38,22 @@ class Profile(BaseProfile): return "oob" return self.convert_interface_name_cisco(interface) + INTERFACE_TYPES = { + "Et": "physical", # Ethernet + "Fa": "physical", # FastEthernet + "Gi": "physical", # GigabitEthernet + "Te": "physical", # TenGigabitEthernet + "Lo": "loopback", # Loopback + "Po": "aggregated", # Port-channel/Portgroup + "Tu": "tunnel", # Tunnel + "Vl": "SVI", # Vlan + "oo": "management", # oob + } + + @classmethod + def get_interface_type(cls, name): + return cls.INTERFACE_TYPES.get(name[:2], "unknown") + def setup_session(self, script): script.cli("terminal no prompt") -- GitLab