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

There's more...

The support for JSON output in the Junos OS REST API is incredibly useful because it is so easily convenient to parse by applications. We can make a small modification to our program, for instance, to extract the details of the running software version and only print that rather than the raw response from the REST server:

   print response.status, httplib.responses[response.status]   if args.t=="json":     data = json.loads(responseData)   if 'software-information' in data:      print "Software version: ",            data['software-information'][0]                  ['junos-version'][0]['data']

When run, the application prompts for a password, combines this with the username in the -u switch—or whatever the OS determines as the current username—and then connects to ...

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