Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- ## NOC modules
- from noc.sa.script import Script as NOCScript
- from noc.sa.interfaces import IGetVlans
- class Script(NOCScript):
- name = "Alcatel.7324RU.get_vlans"
- implements = [IGetVlans]
- 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)
- def execute(self):
- v = self.cli("switch vlan show *")
- r = []
- for match in re.finditer(rx_vlan, v):
- if match.group("vstatus")=="enabled":
- r += [{
- "vlan_id": int(match.group("vid")),
- "name": match.group("name")
- }]
- return r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement