Guest User

Untitled

a guest
Dec 8th, 2014
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. from noc.sa.script import Script as NOCScript
  2. from noc.sa.interfaces import IGetInterfaces
  3. import re
  4.  
  5. class Script(NOCScript):
  6. name = "InfiNet.WANFlexX.get_interfaces"
  7. implements = [IGetInterfaces]
  8. rx_if_name = re.compile(r"^(?P<ifname>(?!lo|null)\S+)\s+Link:\s+")
  9.  
  10. def execute(self):
  11. self.interfaces = []
  12. self.iface = {}
  13. for s in self.cli("net -i").splitlines():
  14. match = self.rx_if_name.search(s)
  15. if match:
  16. self.iface["name"] = match.group("ifname")
  17. return [{"interfaces": self.interfaces}]
Advertisement
Add Comment
Please, Sign In to add comment