-
Notifications
You must be signed in to change notification settings - Fork 3
Parsing Cisco CLI Output
Matthew Spangler edited this page Sep 17, 2021
·
7 revisions
crt_automation.utilities
contains some useful functions for parsing Cisco output, such as long_int_name()
.
This function allows you to convert interface abbreviation to the full interface name. Such as converting Gi1/1
to GigabitEthernet1/1
.
For parsing Cisco configurations, I recommend using another project, CiscoConfParse.
Here's an example of how you could use it in an automation script:
from ciscoconfparse import CiscoConfParse
sh_run_output = runner.get_command_output("sh run | b interface")
parse = CiscoConfParse(sh_run_output)
# Return a list of all active interfaces (i.e. not shutdown)
active_interfaces = parse.find_objects_wo_child(r"^interf", r"shutdown")