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…

The steps for the recipe are as follows:

  1. Use the boilerplate that has become standard in the PyEZ recipes: import Python namespaces, set up error handling, and then parse the command-line arguments:
      #!/usr/bin/env python      import sys      import getpass      import os      import json      import argparse      from jnpr.junos import Device      from jnpr.junos.utils.config import Config      from jnpr.junos.exception import ConfigLoadError            def onError(exception_type, exception, traceback):          print "%s: %s" % (exception_type.__name__, exception)      sys.excepthook = onError      cmdline = argparse.ArgumentParser(description="Python JUNOS PyEZ                             Prefix List Tool")      cmdline.add_argument("-t", metavar="router", help="Target router                              to query", required=True) cmdline.add_argument("-a", ...

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