Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from noc.sa.script import Script as NOCScript
- from noc.sa.interfaces import IGetInterfaces
- import re
- class Script(NOCScript):
- name = "InfiNet.WANFlexX.get_interfaces"
- implements = [IGetInterfaces]
- rx_if_name = re.compile(r"^(?P<ifname>(?!lo|null)\S+)\s+Link:\s+")
- def execute(self):
- self.interfaces = []
- self.iface = {}
- for s in self.cli("net -i").splitlines():
- match = self.rx_if_name.search(s)
- if match:
- self.iface["name"] = match.group("ifname")
- return [{"interfaces": self.interfaces}]
Advertisement
Add Comment
Please, Sign In to add comment