Advertisement
Guest User

Untitled

a guest
Sep 16th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import re
  2. ## NOC modules
  3. from noc.sa.script import Script as NOCScript
  4. from noc.sa.interfaces import IGetVlans
  5.  
  6.  
  7. class Script(NOCScript):
  8. name = "Alcatel.7324RU.get_vlans"
  9. implements = [IGetVlans]
  10. rx_vlan = re.compile(r"[ ]*(?P<vid>\d+)[ ]*(?P<vname>[A-Za-z0-9\-\.]+)\n([ 0-9]+)\n[ ]+(?P<vstatus>enabled|disabled)[ 0-9]+\n([ \-xnf]+)\n[ ]+(?P<portmask>[\-tu]+)[ ]*(?P<uplinkmask>[\-tu]*)", re.MULTILINE | re.IGNORECASE)
  11.  
  12. def execute(self):
  13. v = self.cli("switch vlan show *")
  14. r = []
  15. for match in re.finditer(rx_vlan, v):
  16. if match.group("vstatus")=="enabled":
  17. r += [{
  18. "vlan_id": int(match.group("vid")),
  19. "name": match.group("name")
  20. }]
  21. return r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement