0% found this document useful (0 votes)
60 views22 pages

Juniper Extension Toolkit API Guide: Release

Uploaded by

cristian7epn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views22 pages

Juniper Extension Toolkit API Guide: Release

Uploaded by

cristian7epn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Juniper Extension Toolkit API Guide

Release

1.0

Modified: 2016-07-10

Copyright © 2016, Juniper Networks, Inc.


Juniper Networks, Inc.
1133 Innovation Way
Sunnyvale, California 94089
USA
408-745-2000
www.juniper.net
Copyright © 2016, Juniper Networks, Inc. All rights reserved.

Juniper Networks, Junos, Steel-Belted Radius, NetScreen, and ScreenOS are registered trademarks of Juniper Networks, Inc. in the United
States and other countries. The Juniper Networks Logo, the Junos logo, and JunosE are trademarks of Juniper Networks, Inc. All other
trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.

Juniper Networks assumes no responsibility for any inaccuracies in this document. Juniper Networks reserves the right to change, modify,
transfer, or otherwise revise this publication without notice.

Juniper Extension Toolkit API Guide


1.0
Copyright © 2016, Juniper Networks, Inc.
All rights reserved.

The information in this document is current as of the date on the title page.

YEAR 2000 NOTICE

Juniper Networks hardware and software products are Year 2000 compliant. Junos OS has no known time-related limitations through the
year 2038. However, the NTP application is known to have some difficulty in the year 2036.

END USER LICENSE AGREEMENT

The Juniper Networks product that is the subject of this technical documentation consists of (or is intended for use with) Juniper Networks
software. Use of such software is subject to the terms and conditions of the End User License Agreement (“EULA”) posted at
http://www.juniper.net/support/eula.html. By downloading, installing or using such software, you agree to the terms and conditions of
that EULA.

ii Copyright © 2016, Juniper Networks, Inc.


Table of Contents
About the Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Documentation and Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Supported Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Documentation Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Documentation Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Requesting Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
Self-Help Online Tools and Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
Opening a Case with JTAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
Chapter 1 Overview of the JET APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
JET API Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Chapter 2 JET Notification API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
JET Notification API Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
JSON Format of JET Notification Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Subscribing to Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Understanding the JET Notification API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Programming JET Notification for Non-Python Languages . . . . . . . . . . . . . . . 18
Chapter 3 JET Service APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
JET Service APIs Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Interfaces Service API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Firewall Service API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Copyright © 2016, Juniper Networks, Inc. iii


Juniper Extension Toolkit API Guide

iv Copyright © 2016, Juniper Networks, Inc.


List of Tables
About the Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
Table 1: Notice Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
Table 2: Text and Syntax Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
Chapter 2 JET Notification API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Table 3: Junos Event Topics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Table 4: MQTT Libraries by Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Copyright © 2016, Juniper Networks, Inc. v


Juniper Extension Toolkit API Guide

vi Copyright © 2016, Juniper Networks, Inc.


About the Documentation

• Documentation and Release Notes on page vii


• Supported Platforms on page vii
• Documentation Conventions on page vii
• Documentation Feedback on page ix
• Requesting Technical Support on page x

Documentation and Release Notes


®
To obtain the most current version of all Juniper Networks technical documentation,
see the product documentation page on the Juniper Networks website at
http://www.juniper.net/techpubs/.

If the information in the latest release notes differs from the information in the
documentation, follow the product Release Notes.

Juniper Networks Books publishes books by Juniper Networks engineers and subject
matter experts. These books go beyond the technical documentation to explore the
nuances of network architecture, deployment, and administration. The current list can
be viewed at http://www.juniper.net/books.

Supported Platforms

For the features described in this document, the following platforms are supported:

• MX104

• MX2010

• MX2020

• MX240

• MX480

• MX80

• MX960

Documentation Conventions

Table 1 on page viii defines notice icons used in this guide.

Copyright © 2016, Juniper Networks, Inc. vii


Juniper Extension Toolkit API Guide

Table 1: Notice Icons


Icon Meaning Description

Informational note Indicates important features or instructions.

Caution Indicates a situation that might result in loss of data or hardware damage.

Warning Alerts you to the risk of personal injury or death.

Laser warning Alerts you to the risk of personal injury from a laser.

Tip Indicates helpful information.

Best practice Alerts you to a recommended use or implementation.

Table 2 on page viii defines the text and syntax conventions used in this guide.

Table 2: Text and Syntax Conventions


Convention Description Examples

Bold text like this Represents text that you type. To enter configuration mode, type the
configure command:

user@host> configure

Fixed-width text like this Represents output that appears on the user@host> show chassis alarms
terminal screen.
No alarms currently active

Italic text like this • Introduces or emphasizes important • A policy term is a named structure
new terms. that defines match conditions and
• Identifies guide names. actions.
• Junos OS CLI User Guide
• Identifies RFC and Internet draft titles.
• RFC 1997, BGP Communities Attribute

Italic text like this Represents variables (options for which Configure the machine’s domain name:
you substitute a value) in commands or
configuration statements. [edit]
root@# set system domain-name
domain-name

viii Copyright © 2016, Juniper Networks, Inc.


About the Documentation

Table 2: Text and Syntax Conventions (continued)


Convention Description Examples

Text like this Represents names of configuration • To configure a stub area, include the
statements, commands, files, and stub statement at the [edit protocols
directories; configuration hierarchy levels; ospf area area-id] hierarchy level.
or labels on routing platform • The console port is labeled CONSOLE.
components.

< > (angle brackets) Encloses optional keywords or variables. stub <default-metric metric>;

| (pipe symbol) Indicates a choice between the mutually broadcast | multicast


exclusive keywords or variables on either
side of the symbol. The set of choices is (string1 | string2 | string3)
often enclosed in parentheses for clarity.

# (pound sign) Indicates a comment specified on the rsvp { # Required for dynamic MPLS only
same line as the configuration statement
to which it applies.

[ ] (square brackets) Encloses a variable for which you can community name members [
substitute one or more values. community-ids ]

Indention and braces ( { } ) Identifies a level in the configuration [edit]


hierarchy. routing-options {
static {
route default {
; (semicolon) Identifies a leaf statement at a
nexthop address;
configuration hierarchy level.
retain;
}
}
}

GUI Conventions
Bold text like this Represents graphical user interface (GUI) • In the Logical Interfaces box, select
items you click or select. All Interfaces.
• To cancel the configuration, click
Cancel.

> (bold right angle bracket) Separates levels in a hierarchy of menu In the configuration editor hierarchy,
selections. select Protocols>Ospf.

Documentation Feedback

We encourage you to provide feedback, comments, and suggestions so that we can


improve the documentation. You can provide feedback by using either of the following
methods:

• Online feedback rating system—On any page of the Juniper Networks TechLibrary site
at http://www.juniper.net/techpubs/index.html, simply click the stars to rate the content,
and use the pop-up form to provide us with information about your experience.
Alternately, you can use the online feedback form at
http://www.juniper.net/techpubs/feedback/.

Copyright © 2016, Juniper Networks, Inc. ix


Juniper Extension Toolkit API Guide

• E-mail—Send your comments to [email protected]. Include the document


or topic name, URL or page number, and software version (if applicable).

Requesting Technical Support

Technical product support is available through the Juniper Networks Technical Assistance
Center (JTAC). If you are a customer with an active J-Care or Partner Support Service
support contract, or are covered under warranty, and need post-sales technical support,
you can access our tools and resources online or open a case with JTAC.

• JTAC policies—For a complete understanding of our JTAC procedures and policies,


review the JTAC User Guide located at
http://www.juniper.net/us/en/local/pdf/resource-guides/7100059-en.pdf.

• Product warranties—For product warranty information, visit


http://www.juniper.net/support/warranty/.

• JTAC hours of operation—The JTAC centers have resources available 24 hours a day,
7 days a week, 365 days a year.

Self-Help Online Tools and Resources


For quick and easy problem resolution, Juniper Networks has designed an online
self-service portal called the Customer Support Center (CSC) that provides you with the
following features:

• Find CSC offerings: http://www.juniper.net/customers/support/

• Search for known bugs: http://www2.juniper.net/kb/

• Find product documentation: http://www.juniper.net/techpubs/

• Find solutions and answer questions using our Knowledge Base: http://kb.juniper.net/

• Download the latest versions of software and review release notes:


http://www.juniper.net/customers/csc/software/

• Search technical bulletins for relevant hardware and software notifications:


http://kb.juniper.net/InfoCenter/

• Join and participate in the Juniper Networks Community Forum:


http://www.juniper.net/company/communities/

• Open a case online in the CSC Case Management tool: http://www.juniper.net/cm/

To verify service entitlement by product serial number, use our Serial Number Entitlement
(SNE) Tool: https://tools.juniper.net/SerialNumberEntitlementSearch/

Opening a Case with JTAC


You can open a case with JTAC on the Web or by telephone.

• Use the Case Management tool in the CSC at http://www.juniper.net/cm/.

• Call 1-888-314-JTAC (1-888-314-5822 toll-free in the USA, Canada, and Mexico).

x Copyright © 2016, Juniper Networks, Inc.


About the Documentation

For international or direct-dial options in countries without toll-free numbers, see


http://www.juniper.net/support/requesting-support.html.

Copyright © 2016, Juniper Networks, Inc. xi


Juniper Extension Toolkit API Guide

xii Copyright © 2016, Juniper Networks, Inc.


CHAPTER 1

Overview of the JET APIs

• JET API Overview on page 13

JET API Overview

The Juniper Extension Toolkit (JET) has the following APIs:

• Python JetHandler class

Establish connection with JET through the JetHandler interface.

• JET Notification API Overview on page 15

Provides interfaces in the JETHandler Python package that allow you to subscribe to
events and designate a callback function to receive events when they occur.

• JET Service APIs Overview on page 21

Provides interfaces to access the control plane on the device and a management
interface to run operational and configuration commands.

Related • JET Notification API Overview on page 15


Documentation
• JET Service APIs Overview on page 21

• JetHandler API

Copyright © 2016, Juniper Networks, Inc. 13


Juniper Extension Toolkit API Guide

14 Copyright © 2016, Juniper Networks, Inc.


CHAPTER 2

JET Notification API

• JET Notification API Overview on page 15

JET Notification API Overview

The JET Notification API includes interfaces in the JETHandler Python package that allow
you to subscribe to events and designate a callback function to receive events when they
occur. These Python interfaces provide an interface to the MQTT notification system
that for languages other than Python must be handled outside of JET (see “Programming
JET Notification for Non-Python Languages” on page 18). For details about MQTT and
Python, see http://mosquitto.org/ .

• JSON Format of JET Notification Messages on page 15


• Subscribing to Events on page 16
• Understanding the JET Notification API on page 16
• Programming JET Notification for Non-Python Languages on page 18

JSON Format of JET Notification Messages


JET notification is delivered in JSON format. The JSON message has two parts, one the
header, and other the event-information portion, called attributes. The header is common
for all events. It contains the event ID, hostname, time, severity, and facility of the event.
The attributes vary depending event’s topic name.

All kernel rtsock events will have info as the severity and KERNEL as the facility. For syslog
events, the severity and facility will be same as that of the Junos OS syslog messages.

The following is an example event JSON file.

“jet-event”: {
“event-id”: “KERNEL_EVENT_IFD_ADD”
“hostname”: “mydevice”,
“time”: “2016-01-07”,
“severity”: “info”,
“facility”: “KERNEL”,
“attributes”: {
“name”: “ge-0/0/0”,
“snmp-id”: 520,
“flags”: 8
}

Copyright © 2016, Juniper Networks, Inc. 15


Juniper Extension Toolkit API Guide

Subscribing to Events
Applications developed using JET can subscribe to the events listed in Table 3 on page 16.
A topic is an endpoint to which the clients connect. A topic acts as the central distribution
hub for publishing and subscribing messages. Topics are simple, hierarchical strings,
encoded in UTF-8, delimited by a forward slash.

Table 3: Junos Event Topics


Events Topic Event Information Returned

Physical Interface • /junos/events/kernel/interfaces/ifd/add//ifdname name, snmp-id, flags


(IFD) • /junos/events/kernel/interfaces/ifd/change/ifdname
• /junos/events/kernel/interfaces/ifd/delete/ifdname

Logical Inteface • /junos/events/kernel/interfaces/ifl/add/iflname name, subunit, snmp-id, flags


(IFL) • /junos/events/kernel/interfaces/ifl/change/iflname
• /junos/events/kernel/interfaces/ifl/delete/iflname

Family (IFF) • /junos/events/kernel/interfaces/iff/add/iflname/family-type name, subunit, family, table-name,


• /junos/events/kernel/interfaces/iff/change/iflname/family-type flags

• /junos/events/kernel/interfaces/iff/delete/iflname/family-type

Address • /junos/events/kernel/interfaces/ifa/add/iflname/family-type/address name, subunit, family,


• /junos/events/kernel/interfaces/ifa/change/iflname/family-type/address local-address, destination-address,
broadcast-address, flags
• /junos/events/kernel/interfaces/ifa/delete/iflname/family-type/address

Firewall • /junos/events/kernel/firewall/filter/add/filtername name, version, client-id, filter-type,


• /junos/events/kernel/firewall/filter/change/filtername protocol, interface-name, flags

• /junos/events/kernel/firewall/filter/delete/filtername

Route • /junos/events/kernel/route/add/family/prefix-with-length table-name, logical-router-name,


• /junos/events/kernel/route/change/family/prefix-with-length address-family, route-type,
route-prefix,
• /junos/events/kernel/route/delete/family/prefix-with-length
arrayof(nexthop-address), flags

Route-table • /junos/events/kernel/route-table/add/tablename/lrname name, logical-router-name,


• /junos/events/kernel/route-table/change/tablename/lrname address-family, flags

• /junos/events/kernel/route-table/delete/tablename/lrname

Syslog /junos/events/syslog/event-id arrayof(attribute-value pairs)

Understanding the JET Notification API


The JET Notification APIs are as follows:

OpenNotificationSession()—Creates a request-response session with the JET server.


Raises an exception in the case of invalid arguments or when JET notification server
is not accessible.

16 Copyright © 2016, Juniper Networks, Inc.


Chapter 2: JET Notification API

The user is required to configure allow-clients IP addresses using CLI. By default the
behavior is to disallow all clients to connect to broker unless user has configured to
allow them. The bind_address argument passed in the OpenNotificationSession()
call needs to be configured for the allow-clients configuration statement in device
to authorize the connection at mosquitto broker side.

Arguments

• device—JET Server IP address. Default is localhost.

• port—JET Notification port number. Default is 1883.

• user—Username on the JET server, used for authentication and authorization.

• password—Password to access the JET server, used for authentication and


authorization.

• keepalive—Maximum period in seconds between communications with the broker.

• bind_address—Client address to bind. Can be used to control access at broker side.

CloseNotificationSession()—Closes the notification connection with the broker. After this


method is executed successfully, further calls over this session will fail.

Subscribe()—Subscribes to a specific topic the client application is interested in.

Unsubscribe()—Takes the topic as argument and unsubscribes to the given topic. If topic
name is not given as argument (no arguments), this method unsubscribes to all the
topics that the application is already subscribed for.

CreateIFDTopic()—Creates physical interface topic.


Arguments

• op—Operation (ADD, DELETE, CHANGE, ALL). Default is ALL.

• ifd_name—The physical interface name to subscribe to. Default is all physical


interface names.

CreateIFLTopic()—Creates logical interface topic.


Arguments

• op—Operation (ADD, DELETE, CHANGE, ALL). Default is ALL.

• ifd_name—The physical interface name to subscribe to. Default is all physical


interface names.

• sub_unit—This argument is mandatory when an interface name is passed.

• family_type—Default is all family types.

CreateIFFTopic()—Creates family topic.


Arguments

• op—Operation (ADD, DELETE, CHANGE, ALL). Default is ALL.

Copyright © 2016, Juniper Networks, Inc. 17


Juniper Extension Toolkit API Guide

• ifd_name—The physical interface name to subscribe to. Default is all physical


interface names.

CreateIFATopic()—Creates address topic.


Arguments

• op—Operation (ADD, DELETE, CHANGE, ALL). Default is ALL.

• ifd_name—The physical interface name to subscribe to. Default is all physical


interface names.

• sub_unit—This argument is mandatory when an interface name is passed.

• family_type—Default is all family types.

• address—Default is all addresses.

CreateFirewallTopic()—Creates firewall topic.


Arguments

• op—Operation (ADD, DELETE, CHANGE, ALL). Default is ALL.

• filter_name—Filter name to subscribe to. Default is all filters.

CreateRouteTopic()—Creates route topic.


Arguments

• op—Operation (ADD, DELETE, CHANGE, ALL). Default is ALL.

• family—Family to subscribe to. Default is all families.

• prefix_length—Default is all prefix lengths.

CreateRouteTableTopic()—Creates route table topic.


Arguments

• op—Operation (ADD, DELETE, CHANGE, ALL). Default is ALL.

• table_name—Table name to subscribe to. Default is all table names.

• lr_name—LR name to subscribe to. Default is all LR names.

Programming JET Notification for Non-Python Languages


Many of the high-level languages have an MQTT library available. A JET application can
use the corresponding library to connect to MQTT broker running on Junos OS and
subscribe for events. For example, please refer the following link for a sample JAVA
program connecting to an MQTT broker and subscribing for events: Example MQTT
Messaging in Java.

For details on example MQTT libraries for different languages, see Table 4 on page 19.

18 Copyright © 2016, Juniper Networks, Inc.


Chapter 2: JET Notification API

Table 4: MQTT Libraries by Language


Language Name License Link

C, Mosquitto FreeBSD

C++, Mosquitto FreeBSD

Python, Mosquitto FreeBSD

Ruby, Ruby-mqtt MIT License

Java, Eclipse paho Java Eclipse Public License

Go, Eclipse Paho Go Eclipse Public License

C#, MqttDotNet Custom License

Related • Notification API


Documentation

Copyright © 2016, Juniper Networks, Inc. 19


Juniper Extension Toolkit API Guide

20 Copyright © 2016, Juniper Networks, Inc.


CHAPTER 3

JET Service APIs

• JET Service APIs Overview on page 21

JET Service APIs Overview

The JET Service APIs include interfaces in the JETHandler Python package that provide
access to the control plane on the device and a management interface to run operational
and configuration commands.

• Interfaces Service API on page 21


• Firewall Service API on page 21

Interfaces Service API


The InterfacesService API allows you to add or delete an IPv4 or IPv6 interface.

Firewall Service API


The FirewallService API provides the following firewall and traffic policer interfaces:

• Add, change, delete, or replace a firewall filter.

• Bind or unbind a firewall filter to an interface and direction.

• Add, change, or delete a single-rate two-color policer.

• Get statistics associated with a firewall filter counter or policer.

• Clear statistics associated with a firewall filter counter.

Related • JET Service APIs


Documentation

Copyright © 2016, Juniper Networks, Inc. 21


Juniper Extension Toolkit API Guide

22 Copyright © 2016, Juniper Networks, Inc.

You might also like