JSON Support for Junos OS

Similar documents
CSC Web Technologies, Spring Web Data Exchange Formats

This tutorial will help you understand JSON and its use within various programming languages such as PHP, PERL, Python, Ruby, Java, etc.

Assigns a number to 110,000 letters/glyphs U+0041 is an A U+0062 is an a. U+00A9 is a copyright symbol U+0F03 is an

Flat triples approach to RDF graphs in JSON


Configuring the JUNOS Software the First Time on a Router with a Single Routing Engine

Introduction to Bioinformatics

JSON is a light-weight alternative to XML for data-interchange JSON = JavaScript Object Notation

BDS Query. JSON Query Syntax

So, if you receive data from a server, in JSON format, you can use it like any other JavaScript object.

Grading for Assignment #1

External data representation

Introduction to JSON. Roger Lacroix MQ Technical Conference v

10/18/2017. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

Input File Syntax The parser expects the input file to be divided into objects. Each object must start with the declaration:

Junos OS. NETCONF Java Toolkit Developer Guide. Modified: Copyright 2017, Juniper Networks, Inc.

JSON as an XML Alternative. JSON is a light-weight alternative to XML for datainterchange

Using the YANG Development Kit (YDK) with Cisco IOS XE

JME Language Reference Manual

JUNOS OS. NETCONF XML Management Protocol Guide. Release Published: Copyright 2011, Juniper Networks, Inc.

User Interaction: XML and JSON

NETCONF Protocol. Restrictions for the NETCONF Protocol. Information About the NETCONF Protocol

PERL Scripting - Course Contents

Components to Use Data Models

DAY ONE: NAVIGATING THE JUNOS XML HIERARCHY

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Components to Use Data Models

ECMA-404. The JSON Data Interchange Syntax. 2 nd Edition / December Reference number ECMA-123:2009

[301] JSON. Tyler Caraza-Harter

Junos OS. J-Web User Guide for Security Devices. Modified: Copyright 2017, Juniper Networks, Inc.

B4M36DS2, BE4M36DS2: Database Systems 2

1 Lexical Considerations

Javascript. UNIVERSITY OF MASSACHUSETTS AMHERST CMPSCI 120 Fall 2010

5/1/17. Announcements. NoSQL Motivation. NoSQL. Serverless Architecture. What is the Problem? Database Systems CSE 414

Network Configuration Example

Junos Security. Chapter 3: Zones Juniper Networks, Inc. All rights reserved. Worldwide Education Services

Cisco MDS 9000 Series Programmability Guide

Decaf Language Reference

Data Collections. Welcome to the Fourth Dimension (and beyond) Martin Phillips Ladybridge Systems Ltd. International Spectrum Conference, 2014

Configuring Role-Based Access Control

Queens Library API Requirements Document For e-content Partners

Typescript on LLVM Language Reference Manual

Intro to XML. Borrowed, with author s permission, from:

Avro Specification

I2RS Protocol. I2RS built for High performance. Sue Hares. Not the Pizza box CLI

/ Introduction to XML

Junos OS. J-Web User Guide. Modified: Copyright 2018, Juniper Networks, Inc.

Category: Standards Track December 2006

Chapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.

Creating and Working with JSON in Oracle Database

NETCONF Design and Implementation of a Prototype

Lexical Considerations

Computer Science & Engineering 120 Learning to Code

CSC 337. JavaScript Object Notation (JSON) Rick Mercer

CSE 115. Introduction to Computer Science I

Administration of Cisco WLC

The basic format structure of the HTTP request / response messages are similar and consist of the following:

CP122 CS I. Chapter 7a: Java Arrays

\n is used in a string to indicate the newline character. An expression produces data. The simplest expression

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

JSON-LD 1.0 Processing Algorithms and API

Key Differences Between Python and Java

Composer Help. Web Request Common Block

Lexical Considerations

Internet Engineering Task Force (IETF) Request for Comments: 7951 Category: Standards Track August 2016 ISSN:

RESTCONF Programmable Interface

Password Management Guidelines for Cisco UCS Passwords

Network Configuration Example

Kyle Rainville Littleton Coin Company

NAPALM Documentation. Release 1. David Barroso

Role-Based Access Configuration

JavaScript Lecture 1

PHP and MySQL for Dynamic Web Sites. Intro Ed Crowley

Java EE 7: Back-end Server Application Development 4-2

This chapter provides information to configure NETCONF.

Avro Specification

Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1

Introduction to Azure DocumentDB. Jeff Renz, BI Architect RevGen Partners

YAGL: Yet Another Graphing Language Language Reference Manual

Cisco MDS 9000 Series Programmability Guide

Release Notes 6/22/2016

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

Managing the Collection Manager

A Short Summary of Javali

REST. Web-based APIs

Internet Engineering Task Force (IETF) Category: Standards Track August 2016 ISSN:

Management Tools. Management Tools. About the Management GUI. About the CLI. This chapter contains the following sections:

Oli Language Documentation

Mr. Monroe s Guide to Mastering Java Syntax

Reading XML: Introducing XPath. Andrew Walker

COMP9321 Web Application Engineering

JSON. Version 6.6. Eli Barzilay and Dave Herman. July 22, 2016

Universal Format Plug-in User s Guide. Version 10g Release 3 (10.3)

Python - Variable Types. John R. Woodward

Juniper Extension Toolkit Applications Guide

Datacom Systems Inc. 9 Adler Dr. East Syracuse, NY Phone: Support:

Take a Load Off with U2 RESTful Web Services. Nik Kesic, Lead Technical Support for Rocket U2

Multiple Context Mode

Cisco IOS XR Programmability for Cloud-Scale Networking

5/2/16. Announcements. NoSQL Motivation. The New Hipster: NoSQL. Serverless. What is the Problem? Database Systems CSE 414

Transcription:

JSON Support for Junos OS 1 Introduction: Java Script Object Notation alias JSON a light weight data exchange format is being extensively used for data exchange between web application and servers. With the JUNOS Automation tools extending its wings to Python language support and REST feature, JSON data format needs to be supported by JUNOS in addition to the existing XML to make the data exchange simpler and faster. JSON has an edge over XML when it comes to data interchange and some of its advantages over XML are listed below - Much simpler and far lesser content which makes it fat free when compared with XML. - The JSON grammar maps more directly onto the data structures used in modern programming languages like Python and Java script thereby makes it easier to process using the native language support. - Easier to read and interpret for both human and systems. JUNOS Support both the configuration and the operational data in JSON format. 2 JSON Representation and Data types: 2.1 Representation JSON is built on two structures: A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array. Example : Name : Value An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence. Example : "Alplhabhet_List": [ "a", "b", "c", "d" 2.2 Data Types Number "mynum": 123.456 A series of numbers; decimals ok; double-precision floating-point format. Page 1

String "mystring": "abcdef" A series of characters (letters, numbers, or symbols); double-quoted UTF-8 with backslash escaping. Boolean "mybool": true True or false. Array "myarray": [ "a", "b", "c", "d" Sequence of comma-separated values (any data type); enclosed in square brackets. Object Null "myobject": "id": 7 ; Unordered collection of comma-separated key/value pairs; enclosed in curly braces; properties (keys) are distinct strings. "mynull": null Variable with null (empty) value. 3 Configuration in JSON The configuration of JUNOS can be represented in JSON. This section provides some of the basic configuration models in XML and their equivalent JSON format. 3.1 Leaf nodes attributes in JSON The leaf nodes are just emitted as key value pairs in JSON. <system> </system> <host-name>hercules</host-name> "system": "host-name": " Hercules" Page 2

3.2 Leaf nodes attributes with meta-data in JSON The metadata of leaf nodes are emitted as separate entry with the key starting with @ character followed by the name of the corresponding leaf node. <system> </system> <host-name>hercules</host-name> "system": "host-name": " Hercules" "@host-name" : "inactive" : true 3.3 Leaf node with empty data NULL is used to represent the empty data and meta-data will be represented in the same fashion as leaf node. <system> <commit> <persist-groups-inheritance/> </commit> </system> "system" : "commit" : "persist-groups-inheritance" : [null "@persist-groups-inheritance" : "inactive" : true Page 3

3.4 Simple Objects with meta-data The metadata of the simple objects are emitted inside the JSON objects as separate JSON element with the key as @ character followed by the individual meta-data and their values. <system inactive="inactive"> <host-name>hercules</host-name> </system> "system" : "@" : "inactive" : true, "host-name" : "Hercules" 3.5 Containers Nodes Container Nodes are emitted as JSON Array. The meta-deta of the individual elements inside the container are represented inside the JSON element as a separate element with key as @. <interfaces> <interface inactive="inactive"> <name>ge-0/0/0</name> <description>foo</description> </interface> <interface> <name>ge-0/0/1</name> <description>bar</description> </interface> </interfaces> Page 4

3.6 Leaf List in JSON "interfaces" : "interface" : [ "@" : "inactive" : true, "name" : "ge-0/0/0", "description" : "foo", "name" : "ge-0/0/1", "description" : "bar" The Leaf List in JSON is also emitted as JSON Array. <system> <authentication-order>password</authentication-order> <authentication-order>tacplus</authentication-order> </system> "system": "authentication-order" : [ password, tacplus 4 Display/Loading of JUNOS Configuration in JSON Format The configuration of the JUNOS can be emitted and loaded both from CLI and Netconf / Junoscript. The configuration emitted can be parsed by any of the third party JSON parser. The parsed JSON data can be interpreted using any of the programming languages to access the configuration data and its values. The configuration can also be modified programmatically. The Modified configuration data can again be loaded to the JUNOS device using Netconf RPC. 4.1 CLI 4.1.1 Displaying Configuration in JSON The show configuration command is used to emit the configuration. A new option called "json" will be added under " display" option for emitting the configuration in JSON format. Page 5

The show configuration display json will display the configuration in JSON. Router> show configuration display? Possible completions: json Show output in JSON format Example: Router# show display json "configuration" : "system" : "services" : "ftp" : null, "ssh" : "root-login" : "allow", "telnet" : null, "xnm-clear-text" : null, 4.1.2 Load JSON Configuration The Configuration in JSON can be loaded using the following commands for various modes of operations. load json merge <filename/terminal> <relative> load json override <filename/terminal> load json update <filename/terminal> Example : Router# load override json config_file_json.txt 4.2 NETCONF/JUNOSCRIPT 4.2.1 Displaying Configuration in JSON The get-configuration RPC is used is used to emit the configuration. The JSON format can be specified as a XML attribute in the xml tag of get-configuration. Page 6

<rpc> <get-configuration format="json"/> </rpc> Example : <rpc> <get-configuration format="json"/> </rpc> <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> "configuration" : "version" : "15.1I20150610_1111_balasank [balasank", "system" : "services" : "ftp" : null, "ssh" : "root-login" : "allow", "telnet" : null, "xnm-clear-text" : null, "netconf" : "ssh" : "port" : "830", "web-management" : "http" : null </rpc-reply> 4.2.2 Load JSON Configuration The Configuration in JSON can be loaded using the load-configuration RPC <rpc> <load-configuration format="json" operation=[merge override update> <configuration-json> [Config in json </configuration-json> </load-configuration> </rpc> Page 7

Example : <rpc> <load-configuration format="json"> <configuration-json> "configuration" : "system" : "services" : "ftp" : null, "ssh" : "root-login" : "allow", "telnet" : null, "xnm-clear-text" : null, "netconf" : "ssh" : "port" : "834", "web-management" : "http" : null </configuration-json> </load-configuration> </rpc> 5 JSON Data for Operational Commands Junos emits the data for operational commands natively in XML. The XML data then gets converted to text depending upon the format defined in Output Definition Language (ODL). In order to emit the operational data in JSON, the XML data has to be converted to JSON. Some of the convention for the XML to JSON format for operational commands is mentioned below. The Operation data can be viewed in JSON using display json or format= json as already mentioned for configuration commands. Page 8

5.1 XML Leaf node The value of the leaf node will be emitted with "data" as name. Value for the xml toggle will be represented with "null". <name>fxp0</name> JSON: "name" : [ "data" : "fxp0", 5.2 Simple XML leaf node with attributes <admin-status junos:format="enabled">up</admin-status> "admin-status" : [ "data" : "up", "attributes" : "junos:format" : "Enabled" 5.3 Simple leaf node with empty data XML: <ifdf-present/> JSON: Page 9

"ifdf-present" : [ "data" : null, 5.4 Simple XML Element XML <physical-interface>... </physical-interface> JSON: "physical-interface" : [... Example : <rpc-reply xmlns:junos="http://xml.juniper.net/junos/13.3i0/junos"> <interface-information xmlns="http://xml.juniper.net/junos/13.3i0/junos-interface" junos:style="normal"> <physical-interface> <name>cbp0</name> <admin-status junos:format="enabled">up</adminstatus> </physical-interface> <physical-interface> <name>fxp0</name> <oper-status>up</oper-status> <if-device-flags> <ifdf-present/> <ifdf-running/> </if-device-flags> </physical-interface> </interface-information> Page 10

</rpc-reply> JSON: "interface-information" : [ " attributes" : "xmlns" : "http://xml.juniper.net/junos/13.3i0/junos-interface", "junos:style" : "normal", "physical-interface" : [ "name" : [ "data" : "cbp0",, "admin-status" : [ "data" : "up", "attributes" : "junos:format : "Enabled", "name" : [ "data" : "fxp0",, "oper-status" : [ "data" : "up",, "if-device-flags" : [ "ifdf-present" : [ "data" : null,, "ifdf-running" : [ "data" : null, Page 11

Page 12