as in PyEZ. PyEZ is a micro-framework to remotely manage and automate Juniper devices. It works with Python and allows you to pull Junos specific features into an abstraction layer. This is great because you don't have to do any screen scraping to pull out any fields. I installed this module on my Mac to test this out.
The documentation is located here is great because you can look at the apis on how to create your script. The first script I wanted to test out is how to pull information from a router.
PyEZ can use YAML which is a human readable format markup language. I created a yaml file to extract the fields I was looking for.
Here's my yaml file.
My script will parse VRFs on a router. I created two routing instances for this demo.
jnpr@R1# show routing-instances
Now I can test this in python.
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
First I import all the necessary libraries.
>>> from pprint import pprint
>>> from jnpr.junos import Device
>>> from jnpr.junos.op.routes import RouteTable
>>> from lxml import etree
>>> from jnpr.junos.factory import loadyaml
>>> globals().update( loadyaml('vrf.yml') )
Then I open a connection to a junos device
>>> dev = Device('hostname_or_ip', user='username', password='password')
Next I create a table
>>> tbl = VRF(dev)
Then get the fields for the table
>>> tbl.get(values=True) #make sure to pass values=True
VRF:x.x.x.x: 2 items
Now I can iterate through the table an print the contents.
>>> for item in tbl:
... print 'instance_name:', item.instance_name
... print 'instance_type:', item.instance_type
... print 'rd_type:', item.rd_type
... print 'vrf_target:', item.vrf_target
... print 'interface:', item.interface
Now I can then manipulate the tables and look at individual fields.
>>> find = tbl['VRF1']
Now imagine a router with a hundred VRFs. I can now parse through this router remotely and automate operations.