Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Develop Off-Device JET Applications

Overview

You can use JET to develop applications that run off-device. This allows you to leverage the benefits of JET on all devices on your network. For ease of development, you can write off-device JET applications in the language of your choice. To develop an off-device application:

  1. Download and compile the IDL file.

  2. Develop the application using the language of your choice.

  3. Package the application.

  4. Deploy the application package on an external server or run the application directly from the JET VM.

Figure 1 shows the off-device application development workflow.

Figure 1: Off-Device JET Application WorkflowOff-Device JET Application Workflow

Develop and Package Your Application

Before devloping your application, make sure you have already followed the instructions in Set Up the JET VM to set up the JET VM and download the IDL file.

  1. Compile the proto definition files that you plan to use in the language of your choice.

    In this example, we are using Python. We compile the files for the management, authentication, and common base types APIs.

    You have compiled Python and gRPC modules for each specified API.

  2. Develop the application using the language of your choice.

    If you are developing an application with a dependency on C or C++ modules or developing a signed application, you must use the JET VM for JET application development.

    Note:

    Starting in Junos OS Release 21.1R1 and Junos OS Evolved Release 22.3R1, Python 2.7 is no longer supported. Use Python 3 instead.

    You can write the application using a stub after a client side stub is generated. For more information on generating the gRPC client side stubs, writing the application using the stub, and generating code from an IDL file in the language of your choice, see https://www.grpc.io/docs/.

  3. Package the application using JSON. See Package JET Applications for more information.

Prepare to Deploy Your Application

Run your application on an external server or directly from the JET VM. Before you deploy your application on an external server, you need to configure JET interaction with Junos OS.

Configure JET Interaction with Junos OS

To run an off-device application, you need to enable the request-response configuration on Junos OS or Junos OS Evolved. When using the request-response service, the client application issues a request and synchronously waits for the response from the Junos server. Use this section to configure the JET service process (jsd) for the request-response service to run in Secure Sockets Layer (SSL) mode. This provides increased security and enables SSL-based API connections.

Note:

Currently, JET supports Transport Layer Security (TLS) version 1.2 for certificate exchange and supports multiple encryption algorithms, but does not support mutual authentication. This means that clients can authenticate the server, but the server can not authenticate clients using SSL/TLS certificates. For client authentication, use the LoginCheck() procedure from the authentication service API.

  1. Enable jsd to use SSL by adding and configuring the certificate name locally. The certificate must be an RSA certificate. ECDSA and DSA SSL certificates are not supported.

    This method is same as other SSL-based services in Junos OS like xnm-ssl. Keep track of the certificate name entry you specify during certificate generation. You will use it for the HOST_OVERRIDE option in the example Python application in the next section. In this example, the certificate name is router.

    Note:

    If a certificate is updated with the same identifier, the changes will not be reflected for jsd. You need to either configure the certificate with a new identifier in the jsd hierarchy or perform a jsd restart to reflect the changes made.

  2. Copy the SSL certificate .pem file to the Junos device.

    For example:

  3. Load the certificate into the keychain on the Junos device. For example, if the local name of the SSL certificate is sslcert:

  4. Enable support for SSL for the loaded certificate.

    For example:

  5. (Optional) Specify the specific IP address or port that will use SSL. SSL makes that address or port a secure channel.

    If you set the address to 0.0.0.0, the device uses SSL on all ports. For example, to enable support for SSL on the gRPC endpoint on all ports and the default TCP port 51051:

  6. Specify the maximum number of simultaneous connections for request-response that can be attached to jsd. The higher the number, the higher the impact on the client’s performance.

    You have configured jsd for request-response service to run in SSL mode. You are ready to deploy your JET off-device application.

  7. Specify the scripts to use.

    Note:

    Starting in Junos OS Release 21.1R1 and Junos OS Evolved Release 22.3R1, Python 2.7 is no longer supported and the set system scripts language python statement is deprecated. Use the set system scripts language python3 statement instead.

Example: Python JET Application

Use this example to develop an off-device JET application written in Python. You can follow the same guidance for other languages that are supported by gRPC. This Python JET application runs the command get-system-uptime-information in XML format.

In this example, the HOST_OVERRIDE option uses the certificate name that you specified during the certificate generation. See Prepare to Deploy Your Application.

Note:

Juniper Networks supports both of the following forms for denoting XML opening and closing tags: <xml-tag/> and <xml-tag></xml-tag>.

Junos OS Release 18.4R1 and Later

Use the example Python application shown in this section as a guide if you are using Junos OS Release 18.4R1 or later.

If you are writing your application using Python 3, include the PASS keyword in the Exception block of the script.

Before Junos OS Release 18.4R1

Use the example Python application in this section as a guide if you are using Junos OS releases prior to 18.4R1.