Professional Documents
Culture Documents
Release
1.0
Modified: 2016-07-28
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.
The information in this document is current as of the date on the title page.
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.
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.
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
Caution Indicates a situation that might result in loss of data or hardware damage.
Laser warning Alerts you to the risk of personal injury from a laser.
Table 2 on page x defines the text and syntax conventions used in this guide.
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
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>;
# (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 ]
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
• 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/.
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 hours of operation—The JTAC centers have resources available 24 hours a day,
7 days a week, 365 days a year.
• Find solutions and answer questions using our Knowledge Base: http://kb.juniper.net/
To verify service entitlement by product serial number, use our Serial Number Entitlement
(SNE) Tool: https://tools.juniper.net/SerialNumberEntitlementSearch/
JET 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.
• Applications written in C to run on devices that do not use the JET APIs
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.
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.
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/).
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.
• Application development workflow using the interface definition language (IDL) and
the MQTT library
• 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.
• Junos PyEZ — A microframework for Python that enables you to remotely manage and
automate devices running Junos OS.
• 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.
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 • http://thrift.apache.org/
Documentation
• Junos PyEZ
JET Packages
Juniper Extension Toolkit (JET) packages support JET applications on the device and
provide the framework for application development.
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:
• 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.
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.
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.
NOTE:
To implement MIB handlers, you must follow open source net-snmp subagent
guidelines.
3. Write the MIB and the subagent method handlers as per the net-snmp specification.
5. Add the configuration on the device running Junos OS to allow external SNMP subagent
connections.
After the application registration is successful, the application’s registered OIDs can be
polled similar to how other Junos OS supported OIDs are polled.
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.
A
Download
and set up JET VM
Linux (Ubuntu)
WIll B
Develop app application
using PvDEV project NO run on a device YES Develop app
Python apps running using JET project
Junos OS?
C
Use Python
packaging tool
Set up signing
to create unsigned
cert keys
package
D
Deploy application
package on external Create the signed
server or run the app package using
directly from VM JET sandbox
E
Deploy application
package on a device
External server running Junos OS
g043325
Veriexec Junos
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 Vagrant
To download Vagrant:
Downloading VirtualBox
NOTE: For the JET VM, Juniper Networks supports only the VirtualBox
hypervisor.
1. Go to https://www.virtualbox.org/wiki/Downloads.
2. Download and install the VirtualBox package for your platform and the VirtualBox
extension package.
Downloading the JET Files from the Juniper Networks Download Site
• JET-vagrant.zip file
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.
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.
Next, before starting to use the JET IDE, you must install the JET bundle containing backing
sandbox and toolchain and the Python client library.
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.
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.
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:
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.
Run JET Workflow Build, install, and test the application based on the settings
configured in Run JET Configuration.
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.
Update Build Environment Update your JET development environment by installing JET
bundle packages and JET Python Client packages that you
have downloaded.
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.
Application developers can use the integrated development environment (IDE) provided
with the Juniper Extension Toolkit (JET) virtual machine (VM) to develop applications.
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 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.
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.
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 jet-cert@juniper.net.
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.
• ISO Code
• State
• Municipality
• Organization Name
• User String
• Deployment Scope
• Index number
• E-mail address
We recommend against using a personal e-mail address for the certificate contact.
4. Click Finish.
NOTE: Alternatively, you can use an existing e-mail server to send e-mail to
jet-cert@juniper.net with the certificate request file attached.
2. Set up local e-mail SMTP server details and your e-mail details.
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.
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.
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.
• Target OS—Select BSD 6 for legacy Junos OS or BSD 10 for Junos OS with updated
FreeBSD.
• Specify the list of C compiler flags, the list of C++ compiler flags, and the list of
linker flags, if any.
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.
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 > 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.
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:
The following subtopics describe each of the attributes contained in the JSON format
for application packaging:
Mandatory Attributes
Table 6 on page 33 describes the mandatory attributes that all JSON files for application
packaging must have in the main section.
"app-path" Specify the path to the application’s implementation directory. All "python/sample_pyapp"
paths should be relative to sandbox src.
"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 ["foo.py", "bar.py"]
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.
"os-type" Specify whether the application is to be deployed on legacy Junos "bsd6" or "bsd10"
OS (bsd6) or Junos OS with upgraded FreeBSD (bsd10).
"target-arch" Specify the target architecture on which the application is to be "i386", "powerpc", "octeon",
deployed. "xlr", or "arm"
"description" Write a brief (one-line) description about the application. This will "Simple Python test app"
be displayed in the show version operational command output.
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.
"c-compiler-flags" Specify the list of C compiler flags, if any. Compilation "flag1 flag2 flag3"
flags can be defined for the main section, dependent
libraries (dep-libs), or dependent Python modules
(dep-py-modules).
"c++-compiler-flags" Specify the list of C++ compiler flags, if any. "flag1 flag2 flag3"
Compilation flags can be defined for the main section,
dependent libraries (dep-libs), or dependent Python
modules (dep-py-modules).
"linker-flags" Specify the list of linker flags, if any. Use these flags to "flag1 flag2 flag3"
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.
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" }
Source Attributes
Table 8 on page 35 shows two source attributes you can use to specify source files for
the application package.
"srcs" Specify the list of additional source files. For Python "srcs": {
applications, these source files are the additional "python/sample_pyapp": ["a.py", "b.py"],
module files. For C or C++ applications, these source "python/sample_pyapp/temp": ["temp1.py",
files are the source files to be compiled to generate "temp2.py"]
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": {
"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:
• "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.
"dep-libs": [
{
"lib-name": "xyz",
"lib-path": "lib/xyz",
"srcs": {
"lib/xyz": ["foo.c", "bar.c"]
}
}
]
• "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.
"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"]
}
}
]
{
"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",
"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 • Building and Creating a Package by Using the JET IDE on page 31
Documentation
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.
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.
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.
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
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
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 jet-cert@juniper.net.
• Provider prefix
• User string
• 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
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.
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.
Ensure that no one outside of your development organization has access to it. Do not
send this file to Juniper Networks.
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:
• Toolchain
Now you are ready to create the development sandbox in the VM and start developing
applications.
2. If you have not already done so, set your PATH variable.
For details, see “Setting the PATH Environment Variable” on page 40.
% mksb -n mysandbox
NOTE: You can also check out an example application, for example,
You are now ready to start developing an application for a specific language.
To develop an application:
vagrant@jet-vm:~$ cd /home/vagrant
The workon command takes you directly to the $SB/src directory and sets the
sandbox correctly.
For details, see “JSON File Format for JET Application Packaging” on page 32.
• 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.
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
After development of the application is complete and all the makefiles and manifest file
are ready, the application can be built and packaged.
1. In the directory in which you keep your sandboxes, use the workon command to go
into your sandbox.
For more on the JSON file, see “JSON File Format for JET Application Packaging”
on page 32.
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
You can use Python to develop an application in either of the following circumstances:
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.
A B C D
Download Use the Python Deploy an
Develop
and install the packaging tool application package
an application
JET API package to create an on the external server
by using an IDE
from juniper.net unsigned package
Any OS
Linux, FreeBSD, etc.
g043243
External
server
Related • Downloading and Installing the JET Python Client Package on page 48
Documentation
• Overview of Developing a JET Application Using a VM on page 21
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.
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:
• Use the python setup.py install command—Use this command when the pip install
command is not available.
For example, where jet-1.0.1.dev.tgz is the JET Python client package name:
% cd jet-1.0.1.dev
After installing the client package, you should see the following directory structure in
the python-install-path/site-packages/jnpr/jet/ directory:
Related • Developing an Application by Using the JET Python Client Package on page 49
Documentation
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:
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()
user@device> configure
Entering configuration mode
[edit]
user@device#
3. Commit.
user@device# commit
user@device# exit
user@device> request extension-service start cmdline_args.py
Extension-service application 'cmdline_args.py' started with pid: 99418
foo
goo
If you do not include the language python statement, you cannot execute unsigned Python
scripts on a device running Junos OS.
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.
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.
• 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.
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.
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/.
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/.
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:
For the application to receive notifications, install an MQTT library for the specific
language. For more information, see the Juniper Extension Toolkit API Guide.
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:
2. If jsd is up, verify the configuration is present on the device using the following CLI
command in configuration mode:
You should see a matching entry. If you do not, then restart jsd.
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:
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.
(Pdb) help
Documented commands (type help <topic>):
========================================
EOF bt cont enable jump pp run unt
a c continue exit l q s until
alias cl d h list quit step up
args clear debug help n r tbreak w
b commands disable ignore next restart u whatis
break condition down j p return unalias where
Miscellaneous help topics:
==========================
exec pdb
Undocumented commands:
======================
retval rv