Closed jtjones1028 closed 7 years ago
it doesn't correctly identify children lines because of the lack of indentation
CiscoConfParse requires indentation, the configuration must be in the exact format rendered by "show running-config". As long as you have indented the configuration, CiscoConfParse associates NXOS parents with children... to wit, this script prints out the children of Ethernet1/3...
from operator import attrgetter
from ciscoconfparse import CiscoConfParse
CONFIG = """
hostname TestNXOS
interface Ethernet1/3
description E1/3 has child nodes
switchport mode fex-fabric
fex associate 103
channel-group 103
"""
parse = CiscoConfParse(CONFIG.splitlines())
children_lines = map(attrgetter('text'),
parse.find_objects('interface Ethernet1/3')[0].all_children)
print '\n'.join(children_lines)
CiscoConfParse knows very little about the syntax of the configuration itself, it just sees spaces as a way to delimit a child node. Parsing without indentation implies that I would have to re-implement the entire NXOS command parser inside CiscoConfParse; if someone hired me to do that full-time, I suppose it's possible but I already have a day-job that I like ;-)
Yup. Just realized that it was an issue with Cisco Prime, not NX-OS. Cisco Prime (for reasons unknown right now) is showing our Nexus configurations without indentation - however, Prime is showing all other IOS configurations correctly. Looks like I'll be troubleshooting Cisco Prime instead.
Thanks for the quick response man. I love this parser!
@jtjones1028 Depending on what you are parsing you may be able to add/decrement the indentations to fake the config back to something resembling the original. F5 configs for example contain "{" and "}" so it is possible to act when you see these in a pre-parse script before you use ciscoconfparse.
Hey man. Is there a way to fix the parent child relationship for interface on a NXOS configuration. The parsing works fine however, it doesn't correctly identify children lines because of the lack of indentation. Any ideas would be awesome.
Thanks