Commit 84d4d30a authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

noc/noc#1541 Cisco.SMB.get_interfaces. Add SNMP.

parent 7023fb67
......@@ -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"]}
......
......@@ -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")
......
Markdown is supported
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