Juniper Extension Toolkit Developer Guide
Release
1.0
Modified: 2016-07-28
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 Developer 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Documentation and Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Supported Platforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Documentation Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Documentation Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Requesting Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Self-Help Online Tools and Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Opening a Case with JTAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii
Chapter 1
JET Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Juniper Extension Toolkit Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
JET Interaction with Junos OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
JET Application Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
JET Application Deployment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Junos OS Automation Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
JET Developer Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
JET Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
MIB Support for JET Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Chapter 2
Developing JET Applications Using the JET VM and IDE . . . . . . . . . . . . . . . . 21
Overview of Developing a JET Application Using a VM . . . . . . . . . . . . . . . . . . . . . . 21
Setting Up the JET Virtual Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Downloading the Packages You Need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Downloading Vagrant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Downloading VirtualBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Downloading the JET Files from the Juniper Networks Download
Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Launching the JET VM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Updating the Build Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Stopping the JET VM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Juniper Extension Toolkit Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Developing an Application Using the JET IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Requesting the Certificate Using the JET IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Building and Creating a Package by Using the JET IDE . . . . . . . . . . . . . . . . . . . . . . 31
JSON File Format for JET Application Packaging . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Main Section Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Mandatory Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Optional Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Source Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Dependent Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Dependent Python Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Copyright © 2016, Juniper Networks, Inc.
iii
Juniper Extension Toolkit Developer Guide
JSON File with All Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Chapter 3
Developing JET Applications Manually Using the JET VM . . . . . . . . . . . . . . . 39
Working Manually in the Virtual Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Setting the PATH Environment Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Executing the Certificate Request Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Creating a Development Sandbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Developing an Application by Manual Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Building and Creating a JET Application Package Without Using an IDE . . . . . . . 44
Chapter 4
Developing JET Applications Using Python . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Overview of Developing a JET Application Using Python . . . . . . . . . . . . . . . . . . . . 47
Downloading and Installing the JET Python Client Package . . . . . . . . . . . . . . . . . 48
Developing an Application by Using the JET Python Client Package . . . . . . . . . . 49
Creating an Unsigned Package by Using the Python Packaging Tool . . . . . . . . . . . 51
Deploying a JET Python Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Chapter 5
Developing Applications Using Other Languages . . . . . . . . . . . . . . . . . . . . . . 53
Overview of Developing a JET Application Using IDL . . . . . . . . . . . . . . . . . . . . . . . 53
Downloading and Compiling the IDL File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Chapter 6
Debugging JET Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Debugging Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Debugging JET Applications on a Device Running Junos OS . . . . . . . . . . . . . . . . . 56
iv
Copyright © 2016, Juniper Networks, Inc.
List of Figures
Chapter 1
JET Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 1: JET Request-Response and Notification Services . . . . . . . . . . . . . . . . . . . 16
Chapter 2
Developing JET Applications Using the JET VM and IDE . . . . . . . . . . . . . . . . 21
Figure 2: Developing an Application Using a VM . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Chapter 4
Developing JET Applications Using Python . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Figure 3: Developing a JET Application Using Python . . . . . . . . . . . . . . . . . . . . . . . 47
Chapter 5
Developing Applications Using Other Languages . . . . . . . . . . . . . . . . . . . . . . 53
Figure 4: Developing a JET Application Using IDL . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Copyright © 2016, Juniper Networks, Inc.
v
Juniper Extension Toolkit Developer Guide
vi
Copyright © 2016, Juniper Networks, Inc.
List of Tables
About the Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Table 1: Notice Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
Table 2: Text and Syntax Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
Chapter 1
JET Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Table 3: JET Developer Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Chapter 2
Developing JET Applications Using the JET VM and IDE . . . . . . . . . . . . . . . . 21
Table 4: Steps Involved in Developing a JET Application Using a VM . . . . . . . . . . . 22
Table 5: Juniper Extension Toolkit Menu Options . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Table 6: Mandatory Attributes in the JSON File Main Section . . . . . . . . . . . . . . . . 33
Table 7: Optional Attributes in the JSON File Main Section . . . . . . . . . . . . . . . . . . 34
Table 8: Source Attributes You Can Use in a JSON File . . . . . . . . . . . . . . . . . . . . . . 35
Chapter 4
Developing JET Applications Using Python . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Table 9: Steps Involved in Developing a JET Application Using Python . . . . . . . . 48
Chapter 5
Developing Applications Using Other Languages . . . . . . . . . . . . . . . . . . . . . . 53
Table 10: Steps Involved in Developing a JET Application Using IDL . . . . . . . . . . . 53
Copyright © 2016, Juniper Networks, Inc.
vii
Juniper Extension Toolkit Developer Guide
viii
Copyright © 2016, Juniper Networks, Inc.
About the Documentation
•
Documentation and Release Notes on page ix
•
Supported Platforms on page ix
•
Documentation Conventions on page ix
•
Documentation Feedback on page xi
•
Requesting Technical Support on page xii
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 x defines notice icons used in this guide.
Copyright © 2016, Juniper Networks, Inc.
ix
Juniper Extension Toolkit Developer 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 x 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
Italic text like this
Italic text like this
x
Represents output that appears on the
terminal screen.
user@host> show chassis alarms
•
Introduces or emphasizes important
new terms.
•
•
Identifies guide names.
A policy term is a named structure
that defines match conditions and
actions.
•
Identifies RFC and Internet draft titles.
•
Junos OS CLI User Guide
•
RFC 1997, BGP Communities Attribute
Represents variables (options for which
you substitute a value) in commands or
configuration statements.
No alarms currently active
Configure the machine’s domain name:
[edit]
root@# set system domain-name
domain-name
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
statements, commands, files, and
directories; configuration hierarchy levels;
or labels on routing platform
components.
•
To configure a stub area, include the
stub statement at the [edit protocols
ospf area area-id] hierarchy level.
•
The console port is labeled CONSOLE.
< > (angle brackets)
Encloses optional keywords or variables.
stub <default-metric metric>;
| (pipe symbol)
Indicates a choice between the mutually
exclusive keywords or variables on either
side of the symbol. The set of choices is
often enclosed in parentheses for clarity.
broadcast | multicast
# (pound sign)
Indicates a comment specified on the
same line as the configuration statement
to which it applies.
rsvp { # Required for dynamic MPLS only
[ ] (square brackets)
Encloses a variable for which you can
substitute one or more values.
community name members [
community-ids ]
Indention and braces ( { } )
Identifies a level in the configuration
hierarchy.
; (semicolon)
Identifies a leaf statement at a
configuration hierarchy level.
(string1 | string2 | string3)
[edit]
routing-options {
static {
route default {
nexthop address;
retain;
}
}
}
GUI Conventions
Bold text like this
Represents graphical user interface (GUI)
items you click or select.
> (bold right angle bracket)
Separates levels in a hierarchy of menu
selections.
•
In the Logical Interfaces box, select
All Interfaces.
•
To cancel the configuration, click
Cancel.
In the configuration editor hierarchy,
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.
xi
Juniper Extension Toolkit Developer 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.
xii
•
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).
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.
xiii
Juniper Extension Toolkit Developer Guide
xiv
Copyright © 2016, Juniper Networks, Inc.
CHAPTER 1
JET Overview
•
Juniper Extension Toolkit Overview on page 15
•
JET Packages on page 18
•
MIB Support for JET Applications on page 19
Juniper Extension Toolkit Overview
Juniper Extension Toolkit (JET), an evolution of the Junos SDK, provides a modern,
programmatic interface for developers of third-party applications. It focuses on providing
®
a standards-based interface to the Juniper Networks Junos operating system (Junos
OS) for management and control plane functionality.
JET supports the following:
•
Multiple languages for applications that run off-box
•
Python for applications that run on a device running Junos OS
•
Applications written in C to run on devices that do not use the JET APIs
•
An event notification method that enables the applications to respond to selected
system events
JET does not use Junos OS APIs, which makes it independent of any Junos OS release.
The JET API release model supports installation of a JET service process (jsd) image
other than the base image from the Junos OS release. A corresponding JET client API
package is released for each jsd image.
JET APIs are synchronous in nature.
See the following sections for more developer overview information. For information on
configuring JET applications to run on a device running Junos OS, see the
Administration Guide for Juniper Extension Toolkit Applications.
•
JET Interaction with Junos OS on page 16
•
JET Application Development on page 16
•
JET Application Deployment on page 17
•
Junos OS Automation Tools on page 17
•
JET Developer Tasks on page 18
Copyright © 2016, Juniper Networks, Inc.
15
Juniper Extension Toolkit Developer Guide
JET Interaction with Junos OS
JET uses the Apache Thrift framework for cross-language services (see
http://thrift.apache.org/) as a mechanism to enable request-response service. Thrift
provides an interface definition language (IDL) that enables you to define APIs. These
IDL files (with .thrift as the file extension) are compiled using the Thrift compiler to
generate source code to be used for the server and client applications. The Thrift server
is part of the JET service process (jsd), which runs on Junos OS.
For event notification, JET uses the Message Queue Telemetry Transport (MQTT) protocol
(see http://mqtt.org/). Event notification is implemented through the mosquitto
notification broker (see http://mosquitto.org/).
Figure 1 on page 16 illustrates the request-response and notification services.
Figure 1: JET Request-Response and Notification Services
JET Application Development
JET includes a virtual machine (VM) package as a vagrant file that includes its own Eclipse
integrated development environment (IDE), plug-ins, and other tools and libraries. There
is also a Python client package.
This developer guide covers a few JET application development scenarios using the
supplied packages; however, JET APIs function within any framework (for example,
Twisted). You can use any programming framework that you prefer to develop
applications. You can use any IDE (such as PyCharm IDE or Eclipse) while developing
against the Python library JET supplies, or you can use your preferred editor. You can use
a text editor (such as vi) to directly write a Python file.
16
Copyright © 2016, Juniper Networks, Inc.
Chapter 1: JET Overview
This guide covers the following JET application development scenarios:
•
Application development workflow using the JET VM and the IDE
•
Application development workflow using the JET VM with manual workflow
•
Application development workflow using the Python client package
•
Application development workflow using the interface definition language (IDL) and
the MQTT library
JET Application Deployment
The following deployments for Python applications on Junos OS are supported:
•
Regular Junos OS (veriexec-enabled Junos OS) with the python configuration enabled
at the [edit system scripts language] hierarchy level. In this scenario, the system will
not perform veriexec checks for a Python application as long as the application is
located under the /var/db/scripts/jet directory and configured at the [edit system
extensions] hierarchy level. In this scenario, an unsigned package for a Python-only
application (a Python script with no dependencies on unsigned shared libraries) will
work. Any application in a signed package will also work.
•
Regular Junos OS (veriexec-enabled Junos OS) with the python configuration disabled
at the [edit system scripts language] hierarchy level. In this environment, only those
Python scripts that are part of a signed package can be executed. Therefore, only a
signed package will work for this scenario.
NOTE: Junos OS supports using symbolic links for files in the
/var/db/scripts/jet directory, but the device will only execute the script at the
target location if it is signed.
Junos OS Automation Tools
JET is one of the Junos OS automation tools. Other automation tools for Junos OS include
the following:
•
Junos PyEZ — A microframework for Python that enables you to remotely manage and
automate devices running Junos OS.
•
Automation scripts (see the Automation Scripting Feature Guide).
•
Commit scripts—Manage the configuration process.
•
Operational scripts—Perform operational tasks and network troubleshooting.
•
Event scripts and event policy—Instruct the operating system to perform actions in
response to system events.
•
SNMP scripts—Support custom MIBs until they are implemented in Junos OS.
Copyright © 2016, Juniper Networks, Inc.
17
Juniper Extension Toolkit Developer Guide
JET Developer Tasks
This guide describes the developer tasks necessary to produce third-party applications.
See Table 3 on page 18 for a list of the JET developer tasks and where to find details
about them in this guide.
Table 3: JET Developer Tasks
JET Developer Task
Find Details Here
Workflows for developing a JET
application
•
Overview of Developing a JET Application Using a
VM on page 21
•
Overview of Developing a JET Application Using
Python on page 47
•
Overview of Developing a JET Application Using IDL
on page 53
•
Debugging Tips on page 55
•
debugging“Debugging JET Applications on a Device
Running Junos OS” on page 56
Debugging JET applications
For more information on developing applications, see Building Your First JET Application
and the following example applications in the Juniper Extension Toolkit Getting Started
Guide:
Related
Documentation
•
JET Interfaces Application
•
JET Firewall and Policer Application
•
JET Notification Application
•
http://thrift.apache.org/
•
Junos PyEZ
•
Automation Scripting Feature Guide
•
JET Packages on page 18
JET Packages
Juniper Extension Toolkit (JET) packages support JET applications on the device and
provide the framework for application development.
There is a difference in packaging of client APIs between development for on-device
applications and development for off-box applications. By default, a set of JET client
package modules is installed on-device. These modules provide a set of wrapper Python
APIs for developing JET applications. To develop applications to run off-box, developers
need to download and install the JET client API package.
18
Copyright © 2016, Juniper Networks, Inc.
Chapter 1: JET Overview
On-device packages:
•
Junos PyEZ—A microframework for Python that comes installed on the device. The
PyEZ microframework enables you to remotely manage and automate devices running
Junos OS. Junos PyEZ is designed to provide the capabilities that a user would have
on the Junos OS command-line interface (CLI) in an environment built for automation
tasks. For more information, see Junos PyEZ.
•
jsd package—The JET service process (jsd) runs on Junos OS. On the TCP port (default
port 9090), jsd listens for and receives requests from JET applications to execute APIs.
Off-box packages:
Related
Documentation
•
JET client API package—For every release of the jsd image, a corresponding API bundle
image is also released. The API bundle package naming is independent of Junos OS
so that one API bundle can be used across multiple jsd releases.
•
Junos PyEZ
•
Automation Scripting Feature Guide
MIB Support for JET Applications
In Junos OS, the SNMP functionality is implemented as a distributed agent using RFC
2741, Agent Extensibility (AgentX) Protocol Version 1. The AgentX protocol allows a master
agent to be extended by independent subagents, so you can have many subagents, and
the communication between master agent and subagents is through the AgentX protocol.
In Junos OS, the master agent process (snmpd) listens for external requests on a standard
port.
An SNMP MIB is a collection of information organized hierarchically. MIBs define the
managed objects that an SNMP manager monitors on SNMP agent or subagents. When
an SNMP manager requests information from an SNMP agent, the SNMP agent retrieves
the current value of the requested information from the MIB.
Object identifiers (OIDs) uniquely identify manged objects in a MIB hierarchy.
Whenever a request for a given OID is received, the master agent forwards the request
to the connected subagent that is responsible for the given OID. For example, if a get or
get-next is received for an OID (let us say, bgpPeerLocalAddr, for example), on receiving
the request, snmpd forwards the request to the Routing process (rpd) subagent to get
the value for the OID. After receiving the value, snmpd sends the response with the
standard response protocol data unit (PDU) to the network management system.
SNMP agent functionality is supported for JET applications as well, by extension. The
JET agent application can run as a SNMP subagent, and it can register its own MIB OIDs
with snmpd. Whenever there is a request for the application-hosted OID, the request will
be forwarded to the application through the AgentX protocol, and the application then
has to respond back with the value requested.
You can also create a JET subagent as an offbox agent application.
Copyright © 2016, Juniper Networks, Inc.
19
Juniper Extension Toolkit Developer Guide
NOTE:
To implement MIB handlers, you must follow open source net-snmp subagent
guidelines.
To implement a JET subagent as an offbox agent application:
1.
Download the open source net-snmp from http://www.net-snmp.org/download.html.
2. Build the open source net-snmp to the required native machine.
3. Write the MIB and the subagent method handlers as per the net-snmp specification.
4. Build the application.
5. Add the configuration on the device running Junos OS to allow external SNMP subagent
connections.
usser@host# set snmp subagent tcp routing-instance default
6. Run the application to register the OIDs being served.
After the application registration is successful, the application’s registered OIDs can be
polled similar to how other Junos OS supported OIDs are polled.
Related
Documentation
20
•
Juniper Extension Toolkit Overview on page 15
Copyright © 2016, Juniper Networks, Inc.
CHAPTER 2
Developing JET Applications Using the JET
VM and IDE
•
Overview of Developing a JET Application Using a VM on page 21
•
Setting Up the JET Virtual Machine on page 23
•
Juniper Extension Toolkit Menu on page 25
•
Developing an Application Using the JET IDE on page 27
•
Requesting the Certificate Using the JET IDE on page 29
•
Building and Creating a Package by Using the JET IDE on page 31
•
JSON File Format for JET Application Packaging on page 32
Overview of Developing a JET Application Using a VM
If an application that you want to develop has a dependency on C or C++ modules or the
application needs to be signed, then you must use the Juniper Extension Toolkit (JET)
virtual machine (VM) for application development.
The JET VM is a 64-bit Ubuntu 12.04 long-term support release. Application developers
can use the JET IDE provided with the VM to develop applications. To set up the developer
environment, you must download the JET bundle and client package from the Juniper
Networks download site, and then, once the VM is up, install the JET toolchain, Eclipse
integrated development environment (IDE), plug-ins, and other tools and libraries that
are required for developing on-device or off-box applications. For more details on the
installing the VM, see “Setting Up the JET Virtual Machine” on page 23.
For a diagram of the JET workflow using the JET VM, see Figure 2 on page 22.
Table 4 on page 22 provides topics relating to the workflow steps in Figure 2 on page 22.
Copyright © 2016, Juniper Networks, Inc.
21
Juniper Extension Toolkit Developer Guide
Figure 2: Developing an Application Using a VM
A
Download
and set up JET VM
Linux (Ubuntu)
Develop app
using PvDEV project
Python apps
NO
WIll
application
run on a device
running
Junos OS?
B
Develop app
using JET project
YES
C
Use Python
packaging tool
to create unsigned
package
Set up signing
cert keys
D
Deploy application
package on external
server or run the app
directly from VM
Create the signed
package using
JET sandbox
E
Veriexec Junos
g043325
Deploy application
package on a device
running Junos OS
External server
Table 4: Steps Involved in Developing a JET Application Using a VM
Related
Documentation
22
Workflow Step
Link to Workflow Step
A
“Setting Up the JET Virtual Machine” on page 23
B
“Developing an Application Using the JET IDE” on page 27
C
“Requesting the Certificate Using the JET IDE” on page 29
D
“Building and Creating a Package by Using the JET IDE” on page 31
E
Deploying an Application Package on a Device Running Junos OS
•
Setting Up the JET Virtual Machine on page 23
•
Overview of Developing a JET Application Using Python on page 47
•
Overview of Developing a JET Application Using IDL on page 53
Copyright © 2016, Juniper Networks, Inc.
Chapter 2: Developing JET Applications Using the JET VM and IDE
Setting Up the JET Virtual Machine
Three packages are used from the Juniper Networks download site to set up the JET
virtual machine (VM): a vagrant zip file, a JET bundle containing a backing sandbox and
toolchain, and the Python library client.
To be ready to use the JET VM and integrated development environment (IDE) to create
applications, complete the following tasks:
•
Downloading the Packages You Need on page 23
•
Launching the JET VM on page 24
•
Updating the Build Environment on page 25
•
Stopping the JET VM on page 25
Downloading the Packages You Need
Installing the JET VM on your development machine provides a complete development
environment with tools for building and packaging applications. It also provides the JET
IDE.
Download and install the following packages:
•
Downloading Vagrant on page 23
•
Downloading VirtualBox on page 23
•
Downloading the JET Files from the Juniper Networks Download Site on page 24
Downloading Vagrant
Vagrant (https://www.vagrantup.com/) is a software that creates and configures virtual
development environments. You can think of it as a higher-level wrapper around
virtualization software such as VirtualBox (https://www.virtualbox.org/wiki/Downloads).
You can use Vagrant to manage the JET development virtual machine (VM).
To download Vagrant:
•
Go to https://www.vagrantup.com/ and download Vagrant for your system’s platform
(Windows, Mac, or Linux).
Downloading VirtualBox
NOTE: For the JET VM, Juniper Networks supports only the VirtualBox
hypervisor.
Copyright © 2016, Juniper Networks, Inc.
23
Juniper Extension Toolkit Developer Guide
To download and install VirtualBox:
1.
Go to https://www.virtualbox.org/wiki/Downloads.
2. Download and install the VirtualBox package for your platform and the VirtualBox
extension package.
3. Enable hardware virtualization support on your machine BIOS if it is not already
enabled.
Downloading the JET Files from the Juniper Networks Download Site
The JET VM is downloaded from the Juniper Networks download website at
http://www.juniper.net/support/downloads/?p=jet#sw in the form of three packages:
•
JET sandbox and toolchain file
•
Python client library file
•
JET-vagrant.zip file
Launching the JET VM
The vagrant zip file is started first.
To launch the JET VM:
1.
Create a jet-vagrant directory and extract the JET-vagrant.zip file you downloaded
from the Juniper Networks download site to that directory.
2. Change to the jet-vagrant directory where you have extracted the JET-vagrant.zip file.
3. Issue the vagrant up command.
If needed, use the following default login credentials:
username: vagrant
password: vagrant
Wait for the Ubuntu desktop screen to come up in Oracle VM VirtualBox. You will see
the Eclipse icon. This is the icon you use for the JET IDE.
4. Double-click the Eclipse icon to start the JET IDE.
Next, before starting to use the JET IDE, you must install the JET bundle containing backing
sandbox and toolchain and the Python client library.
24
Copyright © 2016, Juniper Networks, Inc.
Chapter 2: Developing JET Applications Using the JET VM and IDE
Updating the Build Environment
To download and install the Python client library, you can either use the following
procedure or extract and run install.sh script.
To update the build environment:
1.
Start the JET IDE.
See the procedure “Launching the JET VM” on page 24 for details.
2. Change the perspective by selecting Juniper Extension Toolkit from the Window > Open
perspective -> Other menu.
3. Once the perspective is change, select Juniper Extension Toolkit > Update build
environment.
4. Point the input fields to downloaded JET bundle and client library and install them.
Stopping the JET VM
When you are done using the VM, stop and exit Vagrant.
To stop and exit Vagrant and the IDE:
1.
Go to the command-line prompt for your system.
2. In the jet-vagrant directory, issue the vagrant halt command.
Related
Documentation
•
Juniper Extension Toolkit Overview on page 15
•
Juniper Extension Toolkit Menu on page 25
Juniper Extension Toolkit Menu
The Juniper Extension Toolkit menu is the integrated development environment (IDE)
menu that provides the options you need to create projects and sandboxes for developing
and testing your applications.
To get directions on how to open the JET IDE, see “Setting Up the JET Virtual Machine”
on page 23.
To view the Juniper Extension Toolkit options (Table 5 on page 26), open the JET IDE and
click the Juniper Extension Toolkit menu.
The default perspective of the Juniper Extension Toolkit (JET) IDE has four panes: two
top panes and two bottom panes. The top left-side pane has two windows controlled
by tabs: the Sandbox Explorer (Sandbox) tab and the Remote Systems (Remote) tab.
By default, the Sandbox Explorer window is active.
Copyright © 2016, Juniper Networks, Inc.
25
Juniper Extension Toolkit Developer Guide
Table 5: Juniper Extension Toolkit Menu Options
Menu
Description
JET Project
Create a new project and sandbox for developing
applications or select an existing project.
Build Sandbox
Launch a build of the application based on the configuration
that was provided in Build Configuration.
Build Directory
Compile and build the application by running the make
command in the directory that was selected in the Sandbox
Explorer window.
Build Configuration
Configure your build settings and launch a build for the
current sandbox. In the Build Configuration window, you can
configure the following settings:
•
Select the packages that will be included in the build.
•
Select the targeted architecture.
•
Select the packaging type (operating system).
Export Application
Launch and export a build based on the configuration you
provide in Export Configuration.
Export Configuration
Configure your build and export settings, build your
application, and export your application.
In the Export Configuration window, you can configure the
following settings:
Run JET Workflow
26
•
Select the directory location for the application once it
has been built.
•
Select the packages to include in the build.
•
Select the targeted architecture.
•
Select the packaging type (operating system).
Build, install, and test the application based on the settings
configured in Run JET Configuration.
Copyright © 2016, Juniper Networks, Inc.
Chapter 2: Developing JET Applications Using the JET VM and IDE
Table 5: Juniper Extension Toolkit Menu Options (continued)
Menu
Description
Run JET Configuration
Configure your build settings, configure the router setting,
launch a build, and execute operational commands needed
to install and test the application.
In the JET Configuration window, you can configure the
following:
•
In the Export Configuration tab, select the packages to
include in the build, select the targeted architecture, and
select packaging type.
•
In the Device Details tab, specify the router on which you
want to test your application by entering in the router
name, login ID, password, and pathname where you want
to install the application.
•
In the Operational Commands tab, enter operational
commands to run on the router prior to and after installing
the application.
•
In the Device Configuration window, enter a configuration
in curly bracket ({}) format to run on the router prior to
and after installing the application.
Update Build Environment
Update your JET development environment by installing JET
bundle packages and JET Python Client packages that you
have downloaded.
Certificate
Install a certificate, request the signing of a certificate, and
generate a certificate request. See “Requesting the Certificate
Using the JET IDE” on page 29.
Generate Build Files
Generate makefiles based on input entered in a JSON file.
For more information on JSON files, see “JSON File Format
for JET Application Packaging” on page 32.
“Developing an Application Using the JET IDE” on page 27 provides more information
and shows you how and when to use some of these Juniper Extension Toolkit menu
options.
Related
Documentation
•
JSON File Format for JET Application Packaging on page 32
•
Requesting the Certificate Using the JET IDE on page 29
•
Developing an Application Using the JET IDE on page 27
Developing an Application Using the JET IDE
Application developers can use the integrated development environment (IDE) provided
with the Juniper Extension Toolkit (JET) virtual machine (VM) to develop applications.
Copyright © 2016, Juniper Networks, Inc.
27
Juniper Extension Toolkit Developer Guide
To develop an application by using the JET IDE:
1.
Start the JET IDE and select Juniper Extension Toolkit > JET Project.
2. Type in a project name, select an item from the Applications List, and click Finish.
The new project name appears in the Sandbox Explorer window (top left pane). You
can expand the new project name and see several directories, including the src
directory. Expand the src directory to see several more directories, among them the
python, lib, and bin directories. These are the directories you use to create new
application components.
3. Highlight the appropriate directory for your applications files (choose from among
the python, lib, and bin directories), either select File > New > Folder or right-click and
select New > Folder, type a folder name, and click Finish.
•
To develop applications in Python, create a new application directory in the python
directory and develop the application inside the newly created directory.
•
To create a C/C++ library, create a new library directory in the lib directory and
develop the library inside the newly created directory.
•
To create a C/C++ executable, create a new application directory in the bin directory
and develop the application inside the newly created directory.
For example, for a C/C++ application, you can put some libraries in the lib directory
and other application components in the bin directory.
4. Create files for your application code.
Highlight the appropriate subdirectory, either select File > New > File or right-click and
select New > File, type a filename, and click Finish.
5. Create the code in the application files and do one of the following to save: select File
> Save, press Ctrl+s, or click the diskette icon.
Makefiles and the manifest file are created automatically once you have created the
JSON file.
Related
Documentation
28
•
Juniper Extension Toolkit Menu on page 25
•
Requesting the Certificate Using the JET IDE on page 29
•
Building and Creating a Package by Using the JET IDE on page 31
Copyright © 2016, Juniper Networks, Inc.
Chapter 2: Developing JET Applications Using the JET VM and IDE
Requesting the Certificate Using the JET IDE
In order to develop and distribute JET applications, you must install a package signing
certificate onto the virtual machine (VM). You do this by creating a certificate request
and sending it to Juniper Networks. When you receive the certificate, you install it in the
VM.
CAUTION: Never send your signing key to anyone, including Juniper Networks.
The key enables anyone to sign applications that your router will trust.
Therefore, it should be treated with the same level of security as the root
password for the routers. Once you obtain your signing key, save it in a file
outside of the VM.
Before you can create a certificate request, you must have the provider prefix—a uniquely
identifying prefix that represents the name of your organization. This prefix should have
been provided to a contact at your organization. If you do not know this prefix, you must
request it before running the jet-certificate-request command. Contact JET Certificate
Processing at [email protected].
To create a signed application, request certificates and copy them as explained in the
following procedure. This procedure is optional if you want to create an unsigned
application.
To create a certificate request using the IDE:
1.
Select Juniper Extension Toolkit > Certificate > Generate Certificate.
2. Complete the fields in the Generate Certificate Request pane.
The script prompts for the following data:
•
ISO Code
•
State
•
Municipality
•
Organization Name
•
Organization Provider Prefix
•
User String
This is an additional specification of your choosing. It could be a string specifying
the development team or project name. The user string can consist of a lowercase
letter followed by one or more lowercase letters or numbers.
•
Deployment Scope
Copyright © 2016, Juniper Networks, Inc.
29
Juniper Extension Toolkit Developer Guide
•
Index number
This number is known as a certificate generations number. It is 1 for your initial
certificate. When a certificate expires and a new one is requested, you must
increment the number.
•
E-mail address
We recommend against using a personal e-mail address for the certificate contact.
3. Click Browse to select a directory in which to create the cert files.
This is usually the /usr/local/junos-jet/certs directory.
4. Click Finish.
To send a certificate request to Juniper Networks:
NOTE: Alternatively, you can use an existing e-mail server to send e-mail to
[email protected] with the certificate request file attached.
1.
Select Juniper Extension Toolkit > Certificate > Request Signing.
2. Set up local e-mail SMTP server details and your e-mail details.
3. Fill in the subject of the e-mail.
4. Attach the certificate request file to the e-mail.
5. Send the e-mail.
To install a certificate on the VM:
1.
Select Juniper Extension Toolkit > Certificate > Install Certificate.
2. Navigate to the location where the certificate resides and click Finish.
3. Check that the certificates foo_key.pem and foo.pem are both in the directory.
Related
Documentation
30
•
Juniper Extension Toolkit Menu on page 25
•
Developing an Application by Using the JET Python Client Package on page 49
Copyright © 2016, Juniper Networks, Inc.
Chapter 2: Developing JET Applications Using the JET VM and IDE
Building and Creating a Package by Using the JET IDE
After writing your application, write the JSON file by providing details about your
application, which the system uses to autogenerate the makefiles and manifest file.
NOTE: If you are not using the JET IDE, write the application JSON file inside
your sandbox. For more details, see “JSON File Format for JET Application
Packaging” on page 32.
To create the JSON file and the JET package using the JET IDE:
1.
Highlight the src directory in the Sandbox Explorer pane, either select File > New > File
or right-click and select New > File, type the filename (use the .json extension), and
click Finish.
The JSON file is placed under the python directory in the Sandbox Explorer pane, and
the JSON Editor is opened and ready for you to create the JSON file. If the JSON Editor
does not open, right-click the .json file and select Open With > JSON Editor.
2. Provide the necessary information about the application and save the file.
•
Application Name—Specify the path to the application's implementation directory.
If the application is a binary, the application name is treated as a binary name. The
package name created is based on the value in this field.
•
Application Path—Specify the path to the application directory.
•
Language—Select the language used for developing the application.
•
Main scripts—This is a list attribute and is generally applicable for Python
applications. For binary applications, this item is optional. Main scripts are searched
under the application path.
Specify the filename or filenames of the main script or scripts that run on the device.
Click Add to add a filename and path. Select a file and click Remove to remove a
file.
•
Application type—Select whether an application is to be a standalone program or
a daemon.
•
Signed application—Select yes or no.
•
Target OS—Select BSD 6 for legacy Junos OS or BSD 10 for Junos OS with updated
FreeBSD.
•
Target architecture—Specify the target architecture on which the application is to
be deployed.
•
Application description—Specify a brief (one-line) description about the application.
This description will be displayed in the CLI show version operational command.
•
Specify the list of C compiler flags, the list of C++ compiler flags, and the list of
linker flags, if any.
Copyright © 2016, Juniper Networks, Inc.
31
Juniper Extension Toolkit Developer Guide
Use linker flags to specify additional libraries to link with or additional link-specific
flags that are required during linking,
•
Source files and modules—Select a category and click Add to add a filename and
path.
Click Preview at any point to see the JSON file format in code.
3. Do one of the following to save the JSON file: select File > Save, press Ctrl+s, or click
the diskette icon.
4. Select the JSON file and click Juniper Extension Toolkit > Generate Build Files from the
menu bar.
The makefiles and manifest file are generated automatically..
5. Select the project directory in the left pane and then select one of the following:
•
Juniper Extension Toolkit > Build Sandbox—Build the applications using the
configuration provided in Build Configuration.
•
Juniper Extension Toolkit > Build Configuration—Select which applications to build,
which targets to build for, and build once you click Finish.
•
Juniper Extension Toolkit > Run JET Configuration—Specify which device to load the
application on and what commands and configurations to include.
Once the build is successful, the package is created in the project ship directory. The
ship directory is in the project directory under the junos-jet-sb-obj directory. You can
see the ship directory in the left pane once the package has been built.
Related
Documentation
•
Juniper Extension Toolkit Menu on page 25
•
JSON File Format for JET Application Packaging on page 32
•
Juniper Extension Toolkit Overview on page 15
•
JET Packages on page 18
JSON File Format for JET Application Packaging
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy
for humans to read and write, and also easy for machines to parse and generate. For
more details, see http://www.json.org.
After application development is complete, write the JSON file describing the content
to be built and packaged for deployment on the device. JSON files consist of a collection
of attributes. Attributes use two structures:
•
A collection of key-value pairs
•
An ordered list of values
These attributes are included inside a set of curly braces.
32
Copyright © 2016, Juniper Networks, Inc.
Chapter 2: Developing JET Applications Using the JET VM and IDE
The following subtopics describe each of the attributes contained in the JSON format
for application packaging:
•
Main Section Attributes on page 33
•
Source Attributes on page 35
•
Dependent Libraries on page 35
•
Dependent Python Modules on page 36
•
JSON File with All Attributes on page 37
Main Section Attributes
The top block of the JSON file is the main section of the file. It consists of mandatory and
optional attributes.
•
Mandatory Attributes on page 33
•
Optional Attributes on page 34
Mandatory Attributes
Table 6 on page 33 describes the mandatory attributes that all JSON files for application
packaging must have in the main section.
Table 6: Mandatory Attributes in the JSON File Main Section
Attribute
Description
Example Values
"app-name"
Specify the name of the application.
"sample_pyapp"
"app-path"
Specify the path to the application’s implementation directory. All
paths should be relative to sandbox src.
"python/sample_pyapp"
"language"
Specify the language used for developing the application.
"python", "c", "c++"
"main-scripts"
This is a list attributes. Specify the filename or filenames of the main
script or scripts that run on the device (do not specify the module
here). The main script files will be deployed under the
/var/db/scripts/jet path on the device.
["foo.py", "bar.py"]
"app-type"
Specify whether an application is to be a standalone program or a
daemon.
"standalone" or "daemon"
"sign"
Indicate whether the application is to be signed or unsigned.
"yes" or "no"
"os-type"
Specify whether the application is to be deployed on legacy Junos
OS (bsd6) or Junos OS with upgraded FreeBSD (bsd10).
"bsd6" or "bsd10"
"target-arch"
Specify the target architecture on which the application is to be
deployed.
"i386", "powerpc", "octeon",
"xlr", or "arm"
"description"
Write a brief (one-line) description about the application. This will
be displayed in the show version operational command output.
"Simple Python test app"
Copyright © 2016, Juniper Networks, Inc.
33
Juniper Extension Toolkit Developer Guide
The following is an example of a simple application JSON file containing only the
mandatory attributes:
{
"app-name": "sample_pyapp",
"app-path": "python/sample_pyapp",
"language": "python",
"main-scripts": ["foo.py", "bar.py"],
"app-type": "standalone",
"sign": "no",
"os-type": "bsd6",
"target-arch": "i386",
"description": "Simple Python test app"
}
Optional Attributes
Table 7 on page 34 describes the optional attributes you can include in the main section
of the JSON file for application packaging.
Table 7: Optional Attributes in the JSON File Main Section
Attribute
Description
Example Values
"c-compiler-flags"
Specify the list of C compiler flags, if any. Compilation
flags can be defined for the main section, dependent
libraries (dep-libs), or dependent Python modules
(dep-py-modules).
"flag1 flag2 flag3"
"c++-compiler-flags"
Specify the list of C++ compiler flags, if any.
Compilation flags can be defined for the main section,
dependent libraries (dep-libs), or dependent Python
modules (dep-py-modules).
"flag1 flag2 flag3"
"linker-flags"
Specify the list of linker flags, if any. Use these flags to
specify additional libraries to link to or additional
link-specific flags that are required during linking, You
can define linker-specific flags either in the main
section or in the dep-py-modules section.
"flag1 flag2 flag3"
The following is an example main section with mandatory and optional attributes:
{
"app-name": "sample_pyapp",
"app-path": "python/sample_pyapp",
"language": "python",
"main-scripts": ["foo.py", "bar.py"],
"app-type": "standalone",
"sign": "no",
"os-type": "bsd6",
"target-arch": "i386",
"description": "Simple Python test app",
"c-compiler-flags": "-DFOO -DBAR",
"c++-compiler-flags": "-DAPP_CHECK –DSOMETHING_ON",
"linker-flags": "-lstdc++ -lfoo" }
34
Copyright © 2016, Juniper Networks, Inc.
Chapter 2: Developing JET Applications Using the JET VM and IDE
Source Attributes
Table 8 on page 35 shows two source attributes you can use to specify source files for
the application package.
Table 8: Source Attributes You Can Use in a JSON File
Attribute
Description
Example Values
"srcs"
Specify the list of additional source files. For Python
applications, these source files are the additional
module files. For C or C++ applications, these source
files are the source files to be compiled to generate
lib/binary. Each entry should be a key-value pair,
where the key is the path of the source files and the
value is an array of source filenames.
"srcs": {
"python/sample_pyapp": ["a.py", "b.py"],
"python/sample_pyapp/temp": ["temp1.py",
"temp2.py"]
}
"extn-srcs"
This section is applicable only for Python. Specify
the list of C or C++ module files to be compiled. Each
entry should be a key-value pair, where the key is the
path of the source files and the value is an array of
source filenames.
"extn-srcs": {
"python/sample_pyapp": ["foo.c", "bar.c"],
"python/sample_pyapp/temp": ["1.cpp", "2.cpp"]
}
The following is an example Python application with additional module files to be
deployed, along with the main script file:
{
"app-name": "sample_pyapp",
"app-path": "python/sample_pyapp",
"language": "python",
"main-scripts": ["foo.py", "bar.py"],
"app-type": "standalone",
"sign": "no",
"os-type": "bsd6",
"target-arch": "i386",
"description": "Simple Python test app",
"srcs": {
"python/sample_pyapp": ["a.py", "b.py"],
"python/sample_pyapp/temp": ["temp1.py", "temp2.py"]
},
"extn-srcs": {
"python/sample_pyapp": ["foo.c", "bar.c"],
"python/sample_pyapp/temp": ["1.cpp", "2.cpp"]
}
}
Dependent Libraries
The dependent libraries (dep-libs) section contains any dependent libraries that must
be compiled. The library generated from this JSON code is packaged with the application.
The dep-libs section is an array of multiple library dependencies, each composed of the
following key-name pairs:
Copyright © 2016, Juniper Networks, Inc.
35
Juniper Extension Toolkit Developer Guide
•
"lib-name" is the name of the library.
•
"lib-path" is the path of the library source code in the development sandbox.
•
"srcs" is a key-value pair in which the path is the key and its value is a list of source
files.
The following is an example of a dep-libs attribute:
"dep-libs": [
{
"lib-name": "xyz",
"lib-path": "lib/xyz",
"srcs": {
"lib/xyz": ["foo.c", "bar.c"]
}
}
]
Dependent Python Modules
The dependent Python modules (dep-py-modules) attribute is used only for Python
applications. This attribute contains any dependent Python modules that need to be
compiled and packaged with the application. The dep-py-modules attribute is an array
in which you can specify multiple Python module dependencies. Each dependency is
composed of the following objects:
•
"py-module-name" is the name of the Python module.
•
"py-module-path" is the path of the Python module source code in the development
sandbox.
•
"srcs" is a key-value pair in which the path is the key and its value is a list of source
files.
•
"extn-srcs" is a key-value pair in which the path is the key and its value is a list of Python
extension source files.
The following is an example of a dep-py-modules attribute:
"dep-py-modules": [
{
"py-module-name": "module_a",
"py-module-path": "python/module_a",
"srcs": {
"python/module_a": ["foo.py", "bar.py"]
},
"extn-srcs": {
"python/module_a": ["foo.c", "bar.c"],
"python/module_a/sub_mod": ["lmn.cpp"]
}
}
]
36
Copyright © 2016, Juniper Networks, Inc.
Chapter 2: Developing JET Applications Using the JET VM and IDE
JSON File with All Attributes
The following is an example of a JSON file containing all possible attributes:
{
"app-name": "sample_pyapp",
"app-path": "python/sample_pyapp",
"language": "python",
"main-scripts": ["foo.py", "bar.py"],
"app-type": "standalone",
"sign": "no",
"os-type": "bsd6",
"target-arch": "i386",
"description": "Simple Python test app",
"c-compiler-flags": "-DFOO -DBAR",
"c++-compiler-flags": "-DAPP_CHECK –DSOMETHING_ON",
"linker-flags": "-lstdc++ -lfoo",
"srcs": {
"python/sample_pyapp": ["a.py", "b.py"],
"python/sample_pyapp/temp": ["temp1.py", "temp2.py"]
},
"extn-srcs": {
"python/sample_pyapp": ["foo.c", "bar.c"],
"python/sample_pyapp/temp": ["1.cpp", "2.cpp"]
},
"dep-libs": [
{
"lib-name": "xyz",
"lib-path": "lib/xyz",
"srcs": {
"lib/xyz": ["foo.c", "bar.c"]
}
},
{
"lib-name": "bar",
"lib-path": "lib/bar",
"srcs": {
"lib/bar": ["zoo.c", "zoom.c"],
"lib/bar/temp": ["test1.c", "test2.c"]
}
}
],
"dep-py-modules": [
{
"py-module-name": "module_a",
"py-module-path": "python/module_a",
"srcs": {
"python/module_a": ["foo.py", "bar.py"]
},
"extn-srcs": {
"python/module_a": ["foo.c", "bar.c"],
"python/module_a/sub_mod": ["lmn.cpp"]
}
},
{
"py-module-name": "module_b",
Copyright © 2016, Juniper Networks, Inc.
37
Juniper Extension Toolkit Developer Guide
"py-module-path": "python/module_b",
"c-compiler-flags": "-DSOMEMACRO",
"c++-compiler-flags": "-DSOMEMACRO",
"linker-flags": "-lfoo",
"srcs": {
"python/module_b": ["yyy.py", "zoo.py"],
"python/module_b/sub_mod": ["1.py", "2.py"]
},
"extn-srcs": {
"python/module_b": ["xyz.c", "temp.c"],
"python/module_b/sub_mod": ["y.cpp", "z.cpp"]
}
}
]
}
Related
Documentation
38
•
Building and Creating a Package by Using the JET IDE on page 31
Copyright © 2016, Juniper Networks, Inc.
CHAPTER 3
Developing JET Applications Manually
Using the JET VM
•
Working Manually in the Virtual Machine on page 39
•
Setting the PATH Environment Variable on page 40
•
Executing the Certificate Request Script on page 41
•
Creating a Development Sandbox on page 42
•
Developing an Application by Manual Workflow on page 43
•
Building and Creating a JET Application Package Without Using an IDE on page 44
Working Manually in the Virtual Machine
For those developers who prefer to work outside of the integrated design environment
(IDE), this chapter covers how to do certain developer tasks in the terminal part of the
virtual machine (VM).
To work manually on developing JET applications, you still need to download the JET
VM. See Downloading the Packages You Need.
To access a terminal in the VM:
1.
Start the JET VM.
See “Setting Up the JET Virtual Machine” on page 23.
2. On the Ubuntu Desktop, click the Dash Home icon.
Copyright © 2016, Juniper Networks, Inc.
39
Juniper Extension Toolkit Developer Guide
The Dash Home icon is in the upper left corner of the Ubuntu Desktop and appears
as a circle with three dots arranged around it.
3. Click the Terminal icon.
The terminal window appears with the prompt vagrant@jet-vm:~$.
Related
Documentation
•
Setting the PATH Environment Variable on page 40
•
Downloading the Packages You Need
•
Setting Up the JET Virtual Machine on page 23
Setting the PATH Environment Variable
Before setting the PATH environment variable, download the virtual machine (VM)
environment for developing applications. For details on this download, see Downloading
the Packages You Need.
PATH is the system variable that your operating system uses to locate needed executables
from the command line or terminal window. Using this procedure eliminates the need to
specify the entire path to executables located in your sandbox.
To set the PATH variable:
1.
Open a terminal in the VM.
2. Locate the .bashrc file in the /home/vagrant directory.
vagrant@jet-vm:~$ pwd
/home/vagrant
vagrant@jet-vm:~$ ls -a
3. Add the path from /root to the /junos-jet-sb/bin directory to the PATH variable in
.bashrc.
For example:
vagrant@jet-vm:~$ echo
'PATH=$PATH:/usr/local/junos-jet/16.1R1.3/junos-jet-sb/bin'>>~/.bashrc
40
Copyright © 2016, Juniper Networks, Inc.
Chapter 3: Developing JET Applications Manually Using the JET VM
4. Issue the env command to ensure the PATH variable contains the directory path you
just added.
vagrant@jet-vm:~$ env
PATH=/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:
/bin:/usr/games:/usr/local/junos-jet/16.1R1.3/junos-jet-sb/bin
Related
Documentation
•
Downloading the Packages You Need
•
Executing the Certificate Request Script on page 41
Executing the Certificate Request Script
In order to develop and distribute JET applications, you must install a package signing
certificate onto the virtual machine (VM). You do this by executing the certificate request
script. This script assists you in creating a signing key and a certificate request for use
with JET.
CAUTION: Never send your signing key to anyone, including Juniper Networks.
The key enables anyone to sign applications that your router will trust.
Therefore, it should be treated with the same level of security as the root
password for the routers. Once you obtain your signing key, save it in a file
outside of the VM.
Before you can run the certificate request script, you must have the provider prefix, which
is a uniquely identifying prefix that represents the name of your organization. This prefix
should have been provided to a contact at your organization. If you do not know this
prefix, request it before running the jet-certificate-request command. Contact JET
Certificate Processing at [email protected].
Information the script asks for includes the following data:
•
City, state, and country
•
Your organization and unit
•
Provider prefix
Obtain from JET Certificate Processing at [email protected].
•
User string
This is an additional specification of your choosing. It could be a string specifying the
development team or project name. The user string can consist of a lowercase letter
followed by one or more lowercase letters or numbers.
•
Deployment scope
This the string assigned by Juniper to differentiate multiple certificates for the same
partner. Leave empty if none was assigned to you.
•
Index number
Copyright © 2016, Juniper Networks, Inc.
41
Juniper Extension Toolkit Developer Guide
This number is known as a certificate generations number. It will be 1 for your initial
certificate. When a certificate expires and a new one is requested, this number will be
incremented.
•
E-mail address
We recommend against using a personal e-mail address for the certificate contact.
To create a signed application, request certificates and copy them as explained in the
following procedure. This procedure is optional if you want to create an unsigned
application.
To create a certificate request manually:
1.
In a VM terminal, issue the jet-certificate-request command.
The script leads you through a series of questions.
2. Answer the questions, and press Enter after each answer.
A certificate name is synthesized from this information. The certificate name appears
as the stem of the filenames for two files the script creates in the
/usr/local/junos-jet/certs directory: filename_key.pem and filename_req.pem.
3. Save the filename_key.pem file outside the VM.
Ensure that no one outside of your development organization has access to it. Do not
send this file to Juniper Networks.
4. Send the filename_req.pem file to JET Certificate Processing at [email protected].
JET Certificate Processing immediately sends your certificate to you.
To copy your certificate:
•
Related
Documentation
Copy the certificate file to the /usr/local/junos-jet/certs directory.
•
Setting the PATH Environment Variable on page 40
•
Creating a Development Sandbox on page 42
Creating a Development Sandbox
The two example applications you can include in your sandbox are echoclient and
echoserver.
First, set up the virtual machine (VM) on your system. See Downloading the Packages
You Need. Once the VM is set up, the following tools are pre-installed and available for
use:
42
•
Supporting files and libraries
•
Toolchain
•
JET client package
Copyright © 2016, Juniper Networks, Inc.
Chapter 3: Developing JET Applications Manually Using the JET VM
Now you are ready to create the development sandbox in the VM and start developing
applications.
To create a development sandbox:
1.
In the VM, go to the /home/vagrant directory.
2. If you have not already done so, set your PATH variable.
For details, see “Setting the PATH Environment Variable” on page 40.
3. Create a sandbox by using the mksb command, for example:
vagrant@jet-vm:~$ mksb -n mysandbox
% mksb -n mysandbox
where mysandbox is the name of the sandbox.
NOTE: You can also check out an example application, for example,
vagrant@jet-vm:~$ mksb -n mysandbox echoclient
where echoclient is an example application. The source code and makefiles
of echoclient are also checked out.
You are now ready to start developing an application for a specific language.
Related
Documentation
•
Downloading the Packages You Need
•
Executing the Certificate Request Script on page 41
•
Developing an Application by Manual Workflow on page 43
Developing an Application by Manual Workflow
To develop your application, create subdirectories in your sandbox for components of
your application. Then develop the code. Lastly, autogenerate the application makefile.
To develop an application:
NOTE: In this procedure, the sandbox directory might be referred to as $SB
for short. That is, $SB is equivalent to /home/vagrant/sandbox-name.
1.
Go to the directory in which you keep your sandboxes.
vagrant@jet-vm:~$ cd /home/vagrant
2. Create subdirectories in the sandbox.
a. Use the workon command to go into your sandbox.
vagrant@jet-vm$ workon sandbox-name
Copyright © 2016, Juniper Networks, Inc.
43
Juniper Extension Toolkit Developer Guide
The workon command takes you directly to the $SB/src directory and sets the
sandbox correctly.
Alternatively, you can cd to the src directory of your sandbox.
b. Create subdirectories for application code in $SB/src/python or $SB/src/lib or
$SB/src/bin, based on whether you need Python, library, or bin (executable) files.
3. Develop the code.
4. Write an application JSON file.
For details, see “JSON File Format for JET Application Packaging” on page 32.
5. Autogenerate the appropriate makefiles by running the jet-pkg-gen.py command.
The jet-pkg-gen.py command takes two options:
•
The -i option is followed by the path and filename of the JSON file.
•
The -p option is followed by the path to the src directory of the sandbox.
For example, if you had a sandbox named demo:
vagrant@jet-vm:~/demo/src$ jet-pkg-gen.py -i /home/vagrant/demo/src/demo.json
-p /home/vagrant/demo/src
This command assumes that you have added the path to jet-pkg-gen.py to your .bashrc
file. If not, you need to include the path to jet-pkg-gen.py:
vagrant@jet-vm:~/demo/src$
/usr/local/junos-jet/16.1R1.3/junos-jet-sb/src/junos/host-utils/scripts/jet-pkg-gen.py
-i /home/vagrant/demo/src/demo.json -p /home/vagrant/demo/src
NOTE: The autogenerated application makefile will be correct for most
cases; if there are any external library dependencies, the makefile must
be adjusted accordingly.
Related
Documentation
•
Creating a Development Sandbox on page 42
•
Building and Creating a JET Application Package Without Using an IDE on page 44
Building and Creating a JET Application Package Without Using an IDE
After development of the application is complete and all the makefiles and manifest file
are ready, the application can be built and packaged.
To build the JET application package:
1.
In the directory in which you keep your sandboxes, use the workon command to go
into your sandbox.
vagrant@jet-vm:~$ workon sandbox-name
44
Copyright © 2016, Juniper Networks, Inc.
Chapter 3: Developing JET Applications Manually Using the JET VM
2. (Optional) Test individual pieces of the application by going to subdirectories and
running mk-i386.
3. Build the entire package.
a. Return to the src directory ($SB/src).
b. Run the mk-i386 package-name command, where package-name is the "app-name"
from the JSON file.
For more on the JSON file, see “JSON File Format for JET Application Packaging”
on page 32.
4. Verify the package is in the $SB/junos-jet-sb-obj/ship/ directory.
vagrant@jet-vm:~/sandbox-name/src$cd
/home/vagrant/sandbox-name/junos-jet-sb-obj/ship
vagrant@jet-vm:~/sandbox-name/junos-jet-sb-obj/ship$ ls
For example, if your application is called demo, you would see the following files:
demo-16.1.R1.1.tgz
demo-16.1.R1.1.tgz.sha1
Related
Documentation
•
Developing an Application by Manual Workflow on page 43
Copyright © 2016, Juniper Networks, Inc.
45
Juniper Extension Toolkit Developer Guide
46
Copyright © 2016, Juniper Networks, Inc.
CHAPTER 4
Developing JET Applications Using Python
•
Overview of Developing a JET Application Using Python on page 47
•
Downloading and Installing the JET Python Client Package on page 48
•
Developing an Application by Using the JET Python Client Package on page 49
•
Creating an Unsigned Package by Using the Python Packaging Tool on page 51
•
Deploying a JET Python Application on page 51
Overview of Developing a JET Application Using Python
You can use Python to develop an application in either of the following circumstances:
•
If the application has no dependency on C or C++ modules
•
If the application is not required to be signed
The Juniper Extension Toolkit (JET) Python client package provides easy-to-use Python
classes and methods that implement the JET APIs and simplifies the process of using
the Message Queue Telemetry Transport (MQTT) protocol to receive JET notifications.
We recommend that you use the Python client package for Python application
development, but it is not mandatory. You can still directly interact with the interface
definition language (IDL) APIs and use any MQTT library to develop a JET application
using Python.
Figure 3 on page 47 shows the workflow for using JET to develop Python applications.
Table 9 on page 48 links each part of the workflow in Figure 3 on page 47 to a topic in
this chapter.
Figure 3: Developing a JET Application Using Python
A
B
Download
and install the
JET API package
from juniper.net
C
Develop
an application
by using an IDE
D
Use the Python
packaging tool
to create an
unsigned package
Deploy an
application package
on the external server
Any OS
External
server
Copyright © 2016, Juniper Networks, Inc.
g043243
Linux, FreeBSD, etc.
47
Juniper Extension Toolkit Developer Guide
Table 9: Steps Involved in Developing a JET Application Using Python
Related
Documentation
Workflow Step
Link to Workflow Step
A
“Downloading and Installing the JET Python Client Package” on page 48
B
“Developing an Application by Using the JET Python Client Package” on
page 49
C
“Creating an Unsigned Package by Using the Python Packaging Tool” on
page 51
D
“Deploying a JET Python Application” on page 51
•
Downloading and Installing the JET Python Client Package on page 48
•
Overview of Developing a JET Application Using a VM on page 21
•
Overview of Developing a JET Application Using IDL on page 53
Downloading and Installing the JET Python Client Package
Python version 2.7 should be available in the development environment.
To download and install the JET Python client package:
1.
Download the JET Python client package from the Juniper Networks website at
http://www.juniper.net/support/downloads/?p=jet#sw to your development machine.
2. Go to the directory where you want to install the JET Python client package.
This is the python-install-path.
3. Install the JET Python client package on the development machine.
You can install the JET Python client package in one of the following ways:
•
Use the pip install command—This is the recommended way to install the JET
Python client package. For example, where jet-1.0.1.dev.tgz is the JET Python client
package name:
pip install jet-1.0.1.dev.tgz
•
Use the python setup.py install command—Use this command when the pip install
command is not available.
a. Extract files from the JET Python client package.
For example, where jet-1.0.1.dev.tgz is the JET Python client package name:
% tar –xvzf jet-1.0.1.dev.tgz
b. Go to the JET Python client package directory.
% cd jet-1.0.1.dev
c. Issue the python setup.py install command.
48
Copyright © 2016, Juniper Networks, Inc.
Chapter 4: Developing JET Applications Using Python
% python setup.py install
After installing the client package, you should see the following directory structure in
the python-install-path/site-packages/jnpr/jet/ directory:
Related
Documentation
•
Developing an Application by Using the JET Python Client Package on page 49
Developing an Application by Using the JET Python Client Package
You can choose any editor for developing the JET application. For example, you can use
the PyCharm IDE or Eclipse to develop and debug Python applications, or use a text editor
(such as vi) to write a Python file. Also, you can use any programming framework that
you prefer.
For a tutorial on building a JET application that has no dependency on C or C++ modules
and does not have to be signed, see the Juniper Extension Toolkit Getting Started Guide.
For more information on JET notification APIs, see the Juniper Extension Toolkit API Guide.
The JET Python client package provides wrapper APIs to simplify using Thrift and the
Message Queue Telemetry Transport (MQTT) protocol. With the JET client package, you
can interact with Python classes and methods provided by the JET Python package.
JetHandler is the main class that you will use to interact with a device running a JET
application. The JetHandler class contains methods to establish connections with a
device running Junos OS, execute APIs, and subscribe to notifications.
When you write a JET application for request-response interactions using the JET Python
client package, the application typically creates one instance of the JetHandler class for
each device. The application then uses one of the following methods to connect to the
device:
•
OpenRequestResponseSession() to establish a request-response connection
•
OpenNotificationSession() to establish a notifications connection
Once connected in request-response service, an application can use a method such as
OpenRequestResponseSession() to obtain objects that allow the application to make
API calls.
Copyright © 2016, Juniper Networks, Inc.
49
Juniper Extension Toolkit Developer Guide
Once connected in notification service, an application can use a method such as
OpenNotificationSession() to create topics to which the application subscribes.
When the application has completed its communications with the device, it will call the
CloseRequestResponseSession() or CloseNotificationSession() method to close its
connection to the device.
For JET applications that support notification subscription, you can choose the appropriate
create method and subscribe to it.
For running JET Python applications on a device running Junos OS, you can configure
command-line arguments for the file. For example, if you had the following script, you
can supply the arguments from the Junos CLI using the arguments configuration statement
at the [edit system extensions extension-service application file filename hierarchy level:
import argparse
def main():
parser = argparse.ArgumentParser(description='This is a demo script.')
parser.add_argument('-arg1', required=True)
parser.add_argument('-arg2', required=True)
args = parser.parse_args()
print args.arg1
print args.arg2
if __name__ == '__main__':
main()
To configure the arguments in the CLI:
1.
Enter configuration mode.
user@device> configure
Entering configuration mode
[edit]
user@device#
2. Configure the command-line arguments.
user@device# set system extensions extension-service application file cmdline_args.py
argument “-arg1 foo -arg2 goo”
3. Commit.
user@device# commit
4. Start the application.
user@device# exit
user@device> request extension-service start cmdline_args.py
Extension-service application 'cmdline_args.py' started with pid: 99418
foo
goo
50
Copyright © 2016, Juniper Networks, Inc.
Chapter 4: Developing JET Applications Using Python
Related
Documentation
•
Building Your First JET Application
•
Creating an Unsigned Package by Using the Python Packaging Tool on page 51
Creating an Unsigned Package by Using the Python Packaging Tool
If you do not include the language python statement, you cannot execute unsigned Python
scripts on a device running Junos OS.
To create an unsigned JET Python application package:
1.
Write the script setup.py.
The setup.py file is a Python file that usually tells you that the module or package you
are about to install has been packaged and distributed with distutils, which is the
standard way to distribute Python modules.
2. Use the sdist command to create a source distribution and to create a tar gzip package
file.
% python setup.py sdist –formats=gztar
Related
Documentation
•
Building Your First JET Application
•
Developing an Application by Using the JET Python Client Package on page 49
•
Deploying a JET Python Application on page 51
•
Overview of Developing a JET Application Using a VM on page 21
Deploying a JET Python Application
You can deploy Python applications on an external server or on a device running Junos
OS.
To deploy a Python JET application on an external server, we recommend that you install
the JET Client package on the server. To verify the installation, you should run the sample
applications provided in the JET Client package.
The following deployments of Python applications on devices running Junos OS are
supported:
•
Regular Junos OS (veriexec-enabled Junos OS) with the python configuration enabled
at the [edit system scripts language] hierarchy level. In this scenario, the system will
not perform veriexec checks for a Python application as long as the application is
located under the /var/db/scripts/jet directory and configured at the [edit system
extensions] hierarchy level. In this scenario, an unsigned package for a Python-only
application (a Python script with no dependencies on unsigned shared libraries) will
work. Any application in a signed package will also work.
•
Regular Junos OS (veriexec-enabled Junos OS) with the python configuration disabled
at the [edit system scripts language] hierarchy level. In this environment, only those
Copyright © 2016, Juniper Networks, Inc.
51
Juniper Extension Toolkit Developer Guide
Python scripts that are part of a signed package can be executed. Therefore, only a
signed package will work for this scenario.
NOTE: Junos OS supports using symbolic links for files in the
/var/db/scripts/jet directory, but the device will only execute the script at the
target location if it is signed.
Related
Documentation
52
•
Overview of Developing a JET Application Using Python on page 47
•
Overview of Developing a JET Application Using a VM on page 21
•
Overview of Developing a JET Application Using IDL on page 53
Copyright © 2016, Juniper Networks, Inc.
CHAPTER 5
Developing Applications Using Other
Languages
•
Overview of Developing a JET Application Using IDL on page 53
•
Downloading and Compiling the IDL File on page 54
Overview of Developing a JET Application Using IDL
To develop JET applications in languages other than Python, you need the interface
definition language (IDL) APIs and a Message Queue Telemetry Transport (MQTT) library.
IDL is a language-agnostic way of defining APIs.
The MQTT protocol is used to notify clients about Junos OS events. MQTT is a
publish-subscribe based messaging protocol for use on top of the TCP/IP protocol. The
publish-subscribe messaging pattern requires a message broker. The message broker is
responsible for distributing messages to the interested clients based on the topic of a
message. Clients register with the message broker and inform the message broker about
the topics for which they are interested in receiving messages. For more details, see
http://mqtt.org/.
Figure 4: Developing a JET Application Using IDL
Table 10: Steps Involved in Developing a JET Application Using IDL
Workflow Step
Link to Workflow Step
A and B
“Downloading and Compiling the IDL File” on page 54
C
“Developing an Application by Using the JET Python Client Package” on
page 49
Copyright © 2016, Juniper Networks, Inc.
53
Juniper Extension Toolkit Developer Guide
Table 10: Steps Involved in Developing a JET Application Using
IDL (continued)
Related
Documentation
Workflow Step
Link to Workflow Step
D
“Creating an Unsigned Package by Using the Python Packaging Tool”
on page 51
•
Juniper Extension Toolkit Overview on page 15
•
JET Packages on page 18
•
Overview of Developing a JET Application Using Python on page 47
•
Overview of Developing a JET Application Using a VM on page 21
Downloading and Compiling the IDL File
For developing applications in languages other than Python, you need the interface
definition language (IDL) APIs and a Message Queue Telemetry Transport (MQTT) library.
The application developer can use any operating system (OS), for example, Linux or
Windows, for the development environment.
Before you begin, install the Thrift compiler and dependent libraries.
NOTE: For information about installing the Thrift complier and dependent
libraries, see https://thrift.apache.org/docs/BuildingFromSource.
For the application to receive notifications, install an MQTT library for the
specific language. For more details, see http://mqtt.org/.
To download and compile the IDL file:
1.
Download the IDL file from the Juniper Networks website at
www.juniper.net/support/downloads/.
2. Compile the IDL file by using the Thrift compiler.
The following is an example command that is specific for generating Java code, but
the thrift -r -gen command can be used for other languages as well:
% thrift –r –gen java RouteService.thrift
For the application to receive notifications, install an MQTT library for the specific
language. For more information, see the Juniper Extension Toolkit API Guide.
Related
Documentation
54
•
Overview of Developing a JET Application Using IDL on page 53
Copyright © 2016, Juniper Networks, Inc.
CHAPTER 6
Debugging JET Applications
•
Debugging Tips on page 55
•
Debugging JET Applications on a Device Running Junos OS on page 56
Debugging Tips
You must enable the extension-service traceoptions on the Junos OS device before writing
the sample applications.
In case your application is not able to connect to the Junos service process (jsd):
1.
Check whether jsd is up and running on the Junos OS device using the following
command:
ps aux | grep jsd
If not, then restart jsd.
2. If jsd is up, verify the configuration is present on the device using the following CLI
command in configuration mode:
user@device# show system services extension-service
3. If the configuration is present, verify if jsd is listening on configured port 9090:
nestat -a | grep ‘9090’
You should see a matching entry. If you do not, then restart jsd.
To eliminate any firewall issues, use an on-device application to test.
In case of notification applications, verify that your client IP source address (the address
from which the connect is happening) is added to the list of allowed clients in the jsd
notification configuration.
Ensure that dual Routing Engines on devices running Junos OS have master mode running.
We do not support jsd on backup Routing Engines.
Ensure that the maximum number of notification connections as configured on the device
are not exceeded. Use the following command to see the clients:
netstat -a | grep 1883
Copyright © 2016, Juniper Networks, Inc.
55
Juniper Extension Toolkit Developer Guide
Debugging JET Applications on a Device Running Junos OS
For debugging applications on a device running Junos OS, you can configure the trace
file and trace option with the system extension-service statement.
For non-daemonized applications that run on the router, you can invoke the debugger at
the same time that you install the application.
To load your application along with the debugger:
1.
Use the request extension-service start invoke-debugger cli command.
user@device> request extension-service start invoke-debugger cli application-name.py
Extension-service application 'application-name.py' started with pid: 71246
2. Enter help to display a list of the supported commands.
(Pdb) help
Documented commands (type help <topic>):
========================================
EOF
bt
cont
enable jump
a
c
continue exit
l
alias cl
d
h
list
args
clear
debug
help
n
b
commands
disable
ignore next
break condition down
j
p
Miscellaneous help topics:
==========================
exec pdb
Undocumented commands:
======================
retval rv
56
pp
q
quit
r
restart
return
run
s
step
tbreak
u
unalias
unt
until
up
w
whatis
where
Copyright © 2016, Juniper Networks, Inc.
© Copyright 2026 Paperzz