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. Start the Python source code with the usual boilerplate to define the interpreter and the module import references. Include a general purpose exception handler.
      #!/usr/bin/env python      import sys      import argparse      import getpass      import os      import io      import email      import xml.etree.ElementTree as ET      import jxmlease      import urllib3      import requests      import re      def onError(exception_type, exception, traceback):       sys.stderr.write("%s: %s\n" % (exception_type.__name__,                            exception))     sys.excepthook = onError
  1. Define a function to specify the RPC calls necessary to load and commit a configuration. These will be concatenated together and delivered within a single POST request.
 def configRpc(config): ...

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