Learning paths › Automation › Parsing show output and testing conditions
Parsing show output and testing conditions
Getting a value out of show output by splitting a line into fields, finding where a marker starts and handling the case where it is absent, then the conditions that test it — comparison, and, or and not, True and False as names, and what Python treats as empty — and the containers underneath: a list built and indexed, lists nested into a table of devices, sorting and reversing without losing the original, copying without aliasing, and a tuple for a record that must not change. Explanation and checks; four written exercises.
Lessons
- Pull the software version out of show version
- Split a line into fields you can index
- Join a list back into one line
- Count interfaces from parsed output
- Find where a substring starts
- Extract a version string end to end
- Search output for a marker you care about
- Handle the case where it isn't there
- Compare two values and get a yes or no
- Combine conditions with and, or, not
- True and False are names, and case matters
- What Python treats as empty
- Pick a list when it changes, a tuple when it doesn't
- Build a list and reach any element by position
- Turn a line of output into a list of fields
- Nest lists to hold a table of devices
- Add one item or merge a whole list
- The list operations you actually use
- Insert at a position and remove by value
- Take an item off, and test whether one is there
- Sort and reverse without losing the original
- Count elements and copy without aliasing
- Hold a fixed record that can't be edited
- Leave notes the interpreter ignores
More in Automation
- First scripts that configure devices
- NAPALM: structured data across vendors
- Concurrency, and the Python types device output returns
- Readable code, branching and loops
- Build the workstation and the toolchain
- Files, CSV, JSON and pickle
- Paramiko: SSH to devices from Python
- Netmiko at fleet scale
- Tuples, sets and dictionaries for device records
- Exceptions and your first classes
- Plan and build the automation lab
- Files, formatting and regular expressions
- Addresses, functions, modules and classes
- CSV inventories, logging and scheduling
- Netmiko, SCP and structured parsing
- Agents, async and model-driven workflows
- NETCONF, YANG and RESTCONF
- NX-API, pyATS and Genie
- A small GenAI app, end to end
- macOS, Linux and the virtual lab
- Agile delivery and Python fundamentals
- REST APIs, authentication and requests
- Flask, Docker and Jenkins
- Managing a router with NETCONF and RESTCONF
- Ansible: inventory, ad-hoc commands and first playbooks
- Roles and zero-touch provisioning for Linux switches
- Installing the controller and applying a project
- Setting up Python 3
- The Ansible lab and the controller
- Vault, variables and config changes
- Parsing output and knowing which variable wins
- Jinja filters and PAN-OS automation
- Loops, callbacks, strategy and run control
- Roles, imports and writing your own module
- Running playbooks from AWX