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 pull the necessary Python standard library and PyEZ framework definitions into the global namespace so that we can make use of them. And then in step 2, we establish a general-purpose handler routine that should be called if any exceptions are thrown.

In step 3, we pick apart the command-line arguments with arpgarse help. We’re configured to recognise switches to define the user name and the destination TCP port for the NETCONF over SSH session. Then the extra parameters after the switches are the target hostname, and the actual command line – in quotation marks – respectively:

unix$ ./pyez-command-line.py -husage: pyez-command-line.py [-h] [-p port] [-u username] target commandPython JUNOS PyEZ Command Line Tool ...

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