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 create a SLAX script to call the necessary RPC to get the BGP information, then iterate through the returned structure, printing only a small but hopefully relevant subset of the information. The steps for the recipe are as follows:

  1. Start with the mandatory SLAX boilerplate as recommended by Juniper. This typically defines version numbers for compatibility and declares namespaces.
       version 1.0;       ns junos = "http://xml.juniper.net/junos/*/junos";       ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";       ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";       import "../import/junos.xsl";
  1. Make the RPC call in order to query the operational state of the BGP protocol within the JUNOS routing protocol daemon:
 var $rpc ...

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