Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- ##----------------------------------------------------------------------
- ## Alcatel.AOS.get_interfaces
- ##----------------------------------------------------------------------
- ## Copyright (C) 2007-2011 The NOC Project
- ## See LICENSE for details
- ##----------------------------------------------------------------------
- """
- """
- # Python modules
- import re
- from collections import defaultdict
- # NOC modules
- from noc.sa.script import Script as NOCScript
- from noc.sa.interfaces import IGetInterfaces, InterfaceTypeError
- #from noc.sa.profiles.Cisco.IOS import uBR
- class Script(NOCScript):
- name = "Alcatel.AOS.get_interfaces"
- implements = [IGetInterfaces]
- rx_line = re.compile(r"\w*Slot/Port", re.MULTILINE)
- rx_name = re.compile(r"\s+(?P<name>.\S+)\s+:", re.MULTILINE)
- rx_mac_local = re.compile(r"\s+MAC address\s+: (?P<mac>.+),", re.MULTILINE | re.IGNORECASE)
- rx_oper_status = re.compile(r"\s+Operational Status\s+: (?P<status>.+),", re.MULTILINE | re.IGNORECASE)
- def execute(self):
- r = []
- try:
- v = self.cli("show interfaces")
- except self.CLISyntaxError:
- raise self.NotSupportedError()
- v = "\n" + v
- # For each interface
- i = {"forwarding_instance": "default", "interfaces": [], "type": "ip"}
- for s in self.rx_line.split(v)[1:]:
- n = {}
- match = self.rx_name.search(s)
- if not match:
- continue
- n["name"] = match.group("name")
- match = self.rx_mac_local.search(s)
- if not match:
- continue
- n["mac"] = match.group("mac")
- match = self.rx_oper_status.search(s)
- if not match:
- continue
- n["oper_status"] = match.group("status")
- n["admin_status"] = match.group("status")
- n["subinterfaces"] = []
- n["type"] = "physical"
- i["interfaces"] += [n]
- # iface = i["interfaces"]
- # print iface
- r += [n]
- return r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement