diff --git a/sa/profiles/Cisco/SMB/get_interfaces.py b/sa/profiles/Cisco/SMB/get_interfaces.py index 98adb16286c84b52682d4ba9f427f75e44e1f029..90f8f99ef7fb7dc1038febb17b8823cf258d3752 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 80468636912ac2618a57ec8a8d84d6f0ed466403..ca94165e209929fb143d5d24658b504cc0edd319 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")