O'Reilly logo

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

JUNOS Automation Cookbook

Book Description

Administer, configure, and monitor Junos in your organization

About This Book
  • Get well acquainted with security and routing policies to identify the use of firewall filters.
  • Learn to provide end-user authentication and protect each layer in an enterprise network.
  • A recipe-based guide that will help you configure and monitor Junos OS and basic device operations.
Who This Book Is For

This book targets network engineers, developers, support personals, and administrators who are working on devices running Junos OS and are looking at automating their organisation's operations. Some understanding about Junos would be necessary

What You Will Learn
  • Start using NETCONF RPC standard and understand its usefulness in programming JUNOS
  • Write SLAX scripts to respond to events in the JUNOS environment
  • Automate JUNOS with PyEZ
  • Deal with events in the JUNOS environment, and writing response handlers to deal with them
  • Make the most of automation technologies to help with maintenance and monitoring of JUNOS
  • Use the Ansible framework to extend the automation functionality of Junos
In Detail

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.

Style and Approach

A guide that will cover all the automation tools along with steps on leveraging these tools

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Preface
    1. What this book covers?
      1. What you need for this book
      2. Who this book is for
    2. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    3. Conventions
    4. Reader feedback
    5. Customer support
      1. Downloading the example code
      2. Downloading the color images of this book
      3. Errata
      4. Piracy
      5. Questions
  2. Configuring JUNOS through NETCONF
    1. Introduction
    2. JUNOS NETCONF over SSH setup
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Making NETCONF RPC requests and replies
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Discovering NETCONF RPCs
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Using NETCONF to apply configuration changes
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Processing NETCONF using classic Expect/TCL
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Processing NETCONF with Python
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Processing NETCONF with Node.js
      1. Getting ready
      2. How to do it...
      3. How it works...
  3. Working with the Junos REST API
    1. Introduction
    2. Junos REST API setup
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more
    3. Making REST API calls to Junos with Python
      1. Getting ready...
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Making REST API calls to Junos with Node.js
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Managing passwords safely
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Applying configuration changes through the REST API
      1. Getting ready
      2. How to do it...
      3. How it works...
  4. Using SLAX to Write Op Scripts
    1. Introduction
    2. Making remote procedure calls
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Using XPath predicate expressions
      1. Getting started
      2. How to do it...
      3. How it works...
    4. Working with regular expressions
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Working with IP addresses
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more
    6. Debugging SLAX scripts
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more
    7. Making custom show commands
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Making configuration changes
      1. Getting ready
      2. How to do it...
      3. How it works...
  5. Event Programming
    1. Introduction
    2. Archiving configurations after a change
      1. Getting ready
      2. How to do it…
      3. How it works...
      4. There's more
    3. Capturing output after an event
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more
    4. Custom responses to an event
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more
    5. Dealing with a flapping interface
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Dealing with a flapping OSPF neighbor
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. DIY routing protocol
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Debugging event scripts
      1. Getting ready
      2. How to do it…
      3. How it works…
  6. Automating JUNOS with PyEZ
    1. Introduction
    2. Setting up a PyEZ environment
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more
    3. Exploring the XML RPC using PyEZ
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Calling operational RPCs and setting timeouts
      1. Getting ready
      2. How to do it…
      3. How it works…
    5. Configuration analysis and reporting
      1. Getting ready
      2. How to do it…
      3. How it works…
    6. Making raw CLI commands from PyEZ
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There’s more
    7. Using tables and views
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more
    8. Using custom tables and views
      1. Getting ready
      2. How to do it…
      3. How it works…
    9. Making configuration changes with PyEZ
      1. Getting ready
      2. How to do it…
      3. How it works...
      4. There’s more
    10. Template configurations with Jinja2
      1. Getting ready
      2. How to do it…
      3. How it works...
  7. Advanced Visualization Applications
    1. Introduction
    2. Visualizing graphs
      1. Getting ready
        1. Graph principles
        2. Graph data
      2. How to do it...
        1. Instantiating the template
        2. Drawing the graph
        3. Running the example graph
      3. How it works...
        1. Instantiating the template
        2. Drawing the graph
    3. Extracting graphs from ISIS
      1. Getting started
        1. ISIS primer
      2. How to do it...
      3. How it works...
    4. Extracting graphs from OSPF
      1. Getting ready
        1. OSPF primer
      2. How to do it...
      3. How it works...
    5. Extracting graphs from MPLS VPNs
      1. Getting ready
        1. BGP MPLS VPN primer
      2. How to do it...
      3. How it works...
      4. There's more
  8. Monitoring and Maintaining JUNOS
    1. Introduction
    2. Monitoring configuration changes network-wide
      1. Getting ready
      2. How to do it…
        1. SSH file transfer
        2. JUNOS OS event policy
        3. Web server application
        4. Web client application
      3. How it works...
        1. SSH File Transfer
        2. JUNOS OS event policy
        3. Web server application
        4. Web client application
      4. There's more
    3. Monitoring interface performance
      1. Getting ready
        1. Object-oriented primer for Node.js
      2. How to do it…
        1. Server application
        2. Web client application
        3. Setting up and Running
      3. How it works...
        1. Server application
        2. Web client application
      4. There's more
    4. Monitoring system health
      1. Getting ready
      2. How to do it...
        1. Server application
        2. Web client application
      3. How it works...
        1. Server application
        2. Client application
        3. Running the application
      4. There's more
    5. Monitoring MPLS LDP statistics
      1. Getting ready
      2. How to do it...
        1. Server application
        2. Web client application
      3. How it works...
        1. Server application
        2. Web client application
  9. Security Applications
    1. Introduction
    2. Enforcing configuration standards through commit scripts
      1. Getting ready
      2. How to do it...
      3. How it works...
        1. Loopback address
        2. IGP interface deletion
        3. EBGP policy default
    3. Building BGP route filters
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Applying anti-spoofing filters
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more
    5. Operating a distributed ACL function
      1. Getting ready
      2. How to do it...
      3. How it works...
  10. Extending JUNOS with Ansible
    1. Introduction
    2. Installing Ansible
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more
    3. Configuring Ansible for JUNOS
      1. Getting ready
      2. How to do it..
      3. How it works...
    4. Extracting estate-wide configurations
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    5. Performing platform-specific or group-specific operations
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Using variables and vaults
      1. Getting ready
      2. How to do it...
      3. How it works...