Book Image

JUNOS Automation Cookbook

By : Adam Chappell
Book Image

JUNOS Automation Cookbook

By: Adam Chappell

Overview of this book

The JUNOS Automation Cookbook is a companion guide for the complex field of automating tasks on JUNOS devices. With a foundation in industry-standrd XML, JUNOS provides an ideal environment for programmatic interation, allowing you to build upon the capabilities provided by Juniper, with your own original code. You will begin by learning about, and setting up, the industry-standard NETCONF remote procedure call mechanisms on your device. After initial setup, you'll walk through SLAX - Juniper's foundation scripting language - for manipulating XML representations of JUNOS concepts and elements. You'll learn how to write your own SLAX scripts to customise the operating environment, and also how to write proactive event handlers that deal with situations as they happen. You'll then delve into PyEZ - Juniper's bridging framework to make automation accessible to Python code - allowing you to build automation applications in the popular scripting language. You'll witness some examples of how to write applications that can monitor configuration changes, implement BGP security policies and implement ad-hoc routing protocols, for those really tricky situations. You'll also leaarn how asynchronous I/O frameworks like Node.js can be used to implement automation applications that present an acceptable web interface. Along with way, you'll explore how to make use of the latest RESTful APIs that JUNOS provides, how to visualize aspects of your JUNOS network, and how to integrate your automation capabilities with enterprise-wide orchestration systems like Ansible. By the end of the book, you'll be able to tackle JUNOS automation challenges with confidence and understanding, and without hassle.
Table of Contents (10 chapters)

Using custom tables and views

In this recipe, we’ll build on the learning from the previous recipe, regarding tables and views. PyEZ includes a built-in table for looking at BGP neighbors but with operational experience, it can be a bit lacking in utility. The deficiencies include:

  • The table uses the peer_id attribute to identify the remote peer. When the peering session is not established, this is simply the value of the configured neighbor to whom TCP sessions will be directed and it’s generally useful. But when the session establishes, this field changes to show the router ID of the remote peer - a system-wide identifier, rather than an interface identifier - which is unlikely to be the same for EBGP peers in an internet context.
  • The view associated with the table omits some of the BGP I/O parameters, which can be useful in troubleshooting slow readers and writers...