O'Reilly logo

JUNOS Automation Cookbook by Adam Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it…

We’re going to build a Python script, pyez-show-route.py, which will use the PyEZ framework to login to a JUNOS router and query the routing table for an internet destination, extract the returned data, and print it nicely on the user’s console. The user will be able to invoke our script in the following way:

pyez-show-route.py [-h] [-p port] [-u username] [-t target] [-R instance] destination

The following table provides the different arguments and their description:

Argument Description
-p TCP port to contact NETCONF-over-SSH
-u Username
-t Target device
-R Routing instance on the JUNOS router

 

The steps for the recipe are as follows:

  1. Start by defining the interpreter as usual and defining the Python modules ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required