Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Manage YANG Packages, Modules, and Scripts on Junos Devices

SUMMARY Load custom YANG packages on Junos devices to add your own remote procedure calls (RPCs) and data models to the device.

You can load custom YANG modules on Junos devices to add RPCs and data models that are not natively supported by the OS but can be supported by translation. When you load nonnative YANG data models onto the device, you must also load any translation scripts, action scripts, and deviation modules required by those data models.

Note:

Starting in Junos OS Release 17.3R1, when you load custom YANG data models onto the device, you do not need to explicitly load any required Junos OS extension modules. In earlier releases, you must load the Junos OS extension modules for any packages that use the modules.

Junos devices use packages to identify a collection of related YANG modules, translation scripts, and action scripts. Each package has a unique identifier. When you add YANG modules and scripts to the device, you must associate them with a new or existing package. This topic discusses how to create, update, and delete YANG packages and add or update their associated modules and scripts.

Note:

To prevent CLI-related or configuration database errors, we recommend that you do not perform any CLI operations, change the configuration, or terminate the operation while a device is in the process of adding, updating, or deleting a YANG package and modifying the schema.

Creating a YANG Package and Adding Modules and Scripts

To validate YANG modules and scripts and add them to a new package:

  1. Download the YANG modules and any necessary scripts to any directory on the device.
  2. Ensure that any unsigned Python action scripts are owned by either root or a user in the Junos OS super-user login class and that only the file owner has write permission for the file.
    Note:

    Users can only execute unsigned Python scripts on Junos devices when the script's file permissions include read permission for the first class that the user falls within, in the order of user, group, or others.

  3. (Optional) Validate the syntax of the modules and scripts.
  4. Create a YANG package with a unique identifier, and specify the file paths for the modules and scripts that are part of that package, as well as for any deviation modules that identify deviations for the modules in that package.
    Note:

    You can specify the absolute or relative path to a single file, or you can add multiple files by specifying a space-delimited list of file paths enclosed in brackets.

    Note:

    To install OpenConfig modules that are packaged as a compressed tar file, use the request system software add command. OpenConfig modules and scripts that are installed by issuing the request system software add command are always associated with the package identifier openconfig.

    Note:

    Starting in Junos OS Release 18.3R1, adding, deleting, or updating YANG packages in configuration mode with the run command is not supported.

  5. When the system prompts you to restart the Junos OS CLI, press Enter to accept the default value of yes.
  6. Verify that the package was created and contains the correct modules and scripts.
  7. If the package includes translation scripts or action scripts that are written in Python, enable the device to execute unsigned Python scripts by configuring the language python or language python3 statement, as appropriate for the Junos OS release.
    Note:

    Starting in Junos OS Release 20.2R1 and Junos OS Evolved Release 22.3R1, the device uses Python 3 to execute YANG action and translation scripts. In earlier releases, Junos OS only uses Python 2.7 to execute these scripts, and Junos OS Evolved uses Python 2.7 by default to execute the scripts.

  8. On multichassis systems, repeat steps 1 through 7 on each node in the system.

When you create a new package, the device stores copies of the module and script files in a new location. The device also stores copies of the action script and translation script files under the /var/db/scripts/action and /var/db/scripts/translation directories, respectively. After the modules and scripts are validated and added to the device, Junos OS rebuilds its schema to include the new data models and then validates the active configuration against this schema. Newly added RPCs and configuration hierarchies are immediately available for use.

Note:

Devices that use the ephemeral configuration database will delete all ephemeral configuration data in the process of rebuilding the schema.

Note:

Junos OS does not support using configure private mode to configure statements corresponding to third-party YANG data models, for example, OpenConfig or custom YANG data models.

Updating a YANG Package with New or Modified Modules and Scripts

You create a new YANG package by executing the request system yang add command. To update an existing package to either add new modules and scripts to the package or update existing modules and scripts in the package, you must use the request system yang update command.

To update a YANG package with new or modified modules and scripts:

  1. Download the modules and scripts to any directory on the device.
  2. Ensure that any unsigned Python action scripts are owned by either root or a user in the Junos OS super-user login class and that only the file owner has write permission for the file.
    Note:

    Users can only execute unsigned Python scripts on Junos devices when the script's file permissions include read permission for the first class that the user falls within, in the order of user, group, or others.

  3. (Optional) Validate the syntax of the modules and scripts.
  4. Update the YANG package by issuing the request system yang update command, and specify the file paths for the new and modified modules and scripts.
    Note:

    You can specify the absolute or relative path to a single file, or you can update multiple files by specifying a space-delimited list of file paths enclosed in brackets.

    Note:

    Starting in Junos OS Release 18.3R1, adding, deleting, or updating YANG packages in configuration mode with the run command is not supported.

  5. When the system prompts you to restart the Junos OS CLI, press Enter to accept the default value of yes.
  6. If the package includes translation scripts or action scripts that are written in Python, enable the device to execute unsigned Python scripts by configuring the language python or language python3 statement, as appropriate for the Junos OS release, if it is not already configured.
    Note:

    Starting in Junos OS Release 20.2R1 and Junos OS Evolved Release 22.3R1, the device uses Python 3 to execute YANG action and translation scripts. In earlier releases, Junos OS only uses Python 2.7 to execute these scripts, and Junos OS Evolved uses Python 2.7 by default to execute the scripts.

  7. On multichassis systems, repeat steps 1 through 6 on each node in the system.

When you update a package, the device stores copies of the new and modified module and script files. Junos OS then rebuilds its schema to include any changes to the data models associated with that package and validates the active configuration against this schema.

Note:

Devices that use the ephemeral configuration database will delete all ephemeral configuration data in the process of rebuilding the schema.

Deleting a YANG Package

CAUTION:

Before you delete a YANG package from a Junos device, ensure that the active configuration does not contain configuration data that has dependencies on the data models added by that package.

To delete a YANG package and all modules and scripts associated with that package from a Junos device:

  1. Review the active configuration to determine if there are any dependencies on the YANG modules that will be deleted.
  2. If the configuration contains dependencies on the modules, update the configuration to remove the dependencies.
  3. Delete the package and associated modules and scripts by issuing the request system yang delete command with the appropriate package identifier.
    Note:

    You must use the request system software delete command to remove OpenConfig packages that were installed from a compressed tar file by issuing the request system software add command.

    Note:

    Starting in Junos OS Release 18.3R1, adding, deleting, or updating YANG packages in configuration mode with the run command is not supported.

  4. If the system prompts you to restart the Junos OS CLI, press Enter to accept the default value of yes.

When you delete a package, Junos OS rebuilds its schema to remove the data models associated with that package and then validates the active configuration against this schema. The device removes the copies of the module and script files that were generated when the package was created. The device also removes the copies of the package’s action script and translation script files that are stored under the /var/db/scripts/action and /var/db/scripts/translation directories. If you downloaded the original module and script files to a different location, the original files remain unchanged.

Note:

Devices that use the ephemeral configuration database will delete all ephemeral configuration data in the process of rebuilding the schema.

Change History Table

Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.

Release
Description
22.3R1-EVO
Starting in Junos OS Evolved Release 22.3R1, Junos OS Evolved uses Python 3 to execute YANG action and translation scripts.
20.2R1
Starting in Junos OS Release 20.2R1, Junos OS uses Python 3 to execute YANG action and translation scripts. In earlier releases, Junos OS uses Python 2.7 to execute these scripts.
18.3R1
Starting in Junos OS Release 18.3R1, adding, deleting, or updating YANG packages in configuration mode with the run command is not supported.
17.3R1
Starting in Junos OS Release 17.3R1, when you load custom YANG data models onto the device, you do not need to explicitly load any required Junos OS extension modules.