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 use the Python interactive shell (or REPL – read-evaluate-print loop) in order to use PyEZ to connect to a JUNOS device, and then we’re going to explore the XML RPCs for certain commands:

  1. Start up the Python interpreter and load the essential PyEZ framework classes and the associated XML parsing routines:
      Python 2.7.13 (default, Dec 17 2016, 23:03:43)       [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on           darwin      Type "help", "copyright", "credits" or "license" for more           information.       >>> from jnpr.junos import Device       >>> from lxml import etree
  1. Instantiate a device profile for the JUNOS router, and call the open() method in order to connect:
     >>> router = Device(host="10.0.201.201", user="auto",     

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