In this lesson, we will cover:

  • What is TextFSM?
  • How to use TextFSM parsers in Netmiko.
  • How to build a custom TextFSM parsing template.

The scripts and code for this lesson can be found within the Netmiko repo under the directory: examples/003_parsing/textfsm.

TextFSM Overview

TextFSM is a Python module developed by Google that allows you to take unstructured data and convert it to structured data via sets of regex-based templates. An example of a TextFSM template for parsing the output of show_version on an EOS is shown below:

Value MODEL (\S+)
Value HW_VERSION (\S+)
Value SYS_MAC (\S+)
Value IMAGE (\S+)
Value TOTAL_MEMORY (\d+)
Value FREE_MEMORY (\d+)

  ^Free\s+memory:\s+${FREE_MEMORY} -> Record
Members Only Content
Want to Learn Network Automation?
Join our membership to access:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Tech demos and sessions

Join Now ➜
Close You've successfully subscribed to Packet Coders.
Close Success! Your account is fully activated, you now have access to all content.
Close Welcome back! You've successfully signed in.
Close Nearly there! To activate your account, please click the link in the email we just sent you.