In this lesson, we will cover:

  • An overview of Netmiko parsing.
  • How to use TTP templates within Netmiko.
  • How to build a custom TTP parser.

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

Netmiko Parsing

Netmiko provides the ability to parse the data returned from the device into a Python data structure. Having our data in a Python-based structure rather than a single block of text allows us to interact with the data programmatically. Below visualizes this further:


Nemiko provides support for the following open source parsing libraries. Below is a table showing Netmikos implementation of each. It shows whether you can supply your own template and if a template library for the parser is available.

Parser Custom Templates Template Library
TTP (Template Text Parser) Yes No
TextFSM Yes Yes
Genie No Yes

TTP Overview

TTP (Template Text Parser) is a fairly new tool. A TTP template (shown below) is defined, this is then applied to your data, and your structured data is rendered. TTP is straightforward to use; one of the main reasons for this is that it abstracts away much of the regex required when creating parsing templates.

interface {{ interface }}
 ip address {{ ip }}/{{ mask }}
 description {{ description }}
 ip vrf {{ vrf }}
Ready to Master Network Automation? Start Your Journey Today!
Our membership provides:
  • 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
  • Live monthly tech sessions
  • Access to tech session library

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.