Manage YANG Packages, Modules, and Scripts on Junos Devices
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 the device does not support natively but can support through 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.
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, or delete YANG packages and add or update their associated modules and scripts.
Before you add, update, or delete YANG packages on a device, you should understand the following points for working with YANG packages:
-
To prevent CLI-related errors 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.
-
You cannot use the
runcommand in configuration mode to add, delete, or update YANG packages. -
When you load custom YANG data models onto the device, you do not need to explicitly load any required Junos OS extension modules.
-
After you add, update, or delete YANG packages, the device rebuilds the schema. Devices that use the ephemeral configuration database will delete all ephemeral configuration data in the process of rebuilding the schema.
-
Junos OS does not support using
configure privatemode to configure statements corresponding to third-party YANG data models, for example, OpenConfig or custom YANG data models.
Create a YANG Package and Add Modules and Scripts
To validate YANG modules and scripts and add them to a new package:
When you create a 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. The device then validates the active configuration against this schema. Newly added RPCs and configuration hierarchies are immediately available for use.
Update a YANG Package with New or Modified Modules and Scripts
You create a 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:
When you update a package, the device stores copies of the new and modified module and script files. Junos OS rebuilds its schema to include any changes to the data models associated with that package. The device then validates the active configuration against this schema.
Delete a YANG Package
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:
When you delete a package, Junos OS rebuilds its schema to remove the data models associated with that package. The device then validates the active configuration against this schema. The device removes the copies of the module and script files that it generated when you created the package. The device also removes the copies of the package’s action script and translation script files that reside 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.
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.
run command is not
supported.