In this lesson, we will cover:

  • What is Genie Parse?
  • What parsers are supported?
  • How to perform Genie parsing via the command line.
  • How to perform Genie parsing using Python.

The scripts and code for this lesson can be found within the pyATS repo under the directory: 003_genie/parse/.

What is Genie Parse?

Genie parse provides the ability to parse a given command into structured output. By having the output in a structured format, we can work with the data in a programmatic way, such as looping over the data or extracting certain elements.

For example, if we were to collect the show int ip br output, we would get an output much similar to this.

show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0         10.1.1.1        YES NVRAM  up                    up     
GigabitEthernet0/1         10.1.1.5        YES NVRAM  up                    up     
GigabitEthernet0/2         10.1.1.9        YES NVRAM  up                    up     
GigabitEthernet0/3         10.1.1.13       YES NVRAM  up                    up     
GigabitEthernet0/4         10.1.1.17       YES NVRAM  up                    up     
GigabitEthernet0/5         10.1.1.21       YES NVRAM  up                    up     
GigabitEthernet0/6         172.29.151.1    YES NVRAM  up                    up     
GigabitEthernet0/7         unassigned      YES NVRAM  administratively down down   
Loopback0                  1.1.1.1         YES NVRAM  up                    up     

This isn’t ideal! How would we pull out a given value from this block of text? Regex? Ouch! Instead, we can parse this through Genie parse to get structured output like so:

{
  "interface": {
    "GigabitEthernet0/0": {
      "ip_address": "10.1.1.1",
      "interface_is_ok": "YES",
      "method": "NVRAM",
      "status": "up",
      "protocol": "up"
    },
    "GigabitEthernet0/1": {
      "ip_address": "10.1.1.5",
      "interface_is_ok": "YES",
      "method": "NVRAM",
      "status": "up",
      "protocol": "up"
    },
...

With our data structured, we can now use programmatic methods for working with the data, such as performing key-value lookups, like so:

interface_output['interface']['GigabitEthernet0/0']['ip_address']
===
"10.1.1.1"

Supported Parsers

Genie supports various NOS’s (Network Operating Systems), as shown below. Furthermore, numerous parsers (on average, 10 to 40) are added in each pyATS release cycle.

  • IOS
  • IOSXE
  • IOSXR
  • NXOS
  • ASA - Cisco Adaptive Security Appliance Software
  • LINUX - Linux operating system
  • JUNOS - Juniper Junos
  • SROS - Nokia SROS
  • BIGIP - F5 BIG-IP
  • VIPTELA - Viptela operating system
  • APIC - Cisco API
  • DNAC - Cisco DNAC Centre
  • IRONWARE

A full list of commands which are supported can be found below:

https://pubhub.devnetcloud.com/media/genie-feature-browser/docs/#/parsers

The page is interactive so that you can enter in command, and the supported NOS will be presented:

image2-2

Alternatively, you can filter by network operating system as shown below:

image1-1

Members Only Content
Join today and get access to:
  • 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
  • Monthly online meetups

100% Satisfaction Guaranteed!
Cancel your membership at any time.


Join Today
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.