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 it works...

In step 1, we import the usual Python standard library and PyEZ frameworks. The notable additions, compared with previous recipes, are:

Module Description
jnpr.junos.utils.config.Config Models a JUNOS candidate configuration
jnpr.junos.exception.ConfigLoadError Represents an error that can occur during configuration load

 

argparse is used, as usual, to parse the command line arguments. We make use of the action=“Append” direction to the add_argument() method to ensure that the –a and –d switches can take on multiple values. In return, argparse will build a list of values rather than a single token. We make sure that the prefix-list and the target router are mandatory items by setting the attribute required=True ...

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