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 borrow the basic definitions from the PyEZ bundled BGP table and view but we’re going to modify them so that they include the extra fields in the view that we’re interested in.

We’ll do that by writing a new YAML definition to define our improved table and view, and loading that on-the-fly into the PyEZ class framework, without using a separate static import file.

  1. Start in the usual way by specifying the Python interpreter and import the namespaces that we require for the recipe:
      #!/usr/bin/env python      import sys      import getpass      import os      import json      import argparse      from jnpr.junos import Device      from jnpr.junos.factory.factory_loader import FactoryLoader      import yaml
  1. Trap any encountered errors:
 def onError(exception_type, ...

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