parsing Cisco configuration


There is a very nice Python module to parse Cisco configurations. I had to find all ip-helpers over 400+ Cisco router configuration files. Thank to ciscoconfparse, that’s only a few lines of code:

from ciscoconfparse import CiscoConfParse
parse = CiscoConfParse(cisco_config.txt)
interfaces_with_helpers = parse.find_parents_w_child( "^interf", "ip helper-address")
for interface in interfaces_with_helpers:
    print interface

Thanks to David Michael Pennington for the module !