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 begin as always with the standard Python preamble, referencing the modules that we’re going to make use of. In step 2, we define a custom exception handler that will run in the event of an unanticipated exception. It will print the error message and exit, which is appropriate behavior for a short-lived script like this.

In step 3, we read the command line argument using the standard library argparse functions. The only command line options present influence the connection strategy affecting variables such as the remote TCP port number and username.

In step 4, we call the custom getPass() function if it is present and defined. If you’re in an environment where you’re using passwords rather than SSH-based key authentication, ...

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