Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Use Juniper Networks YANG Modules

Juniper Networks publishes YANG modules that define the configuration hierarchies, RPCs, state data, and YANG extensions for Junos devices. This topic details how to obtain Juniper Networks YANG modules and how to import them into another module.

Obtain Juniper Networks YANG Data Models

You can retrieve the Juniper Networks YANG data models by:

In Junos OS Release 17.1 and earlier, the YANG modules for the Junos OS configuration and command hierarchies that are posted on the Juniper Networks website define the schema for all devices running that Junos OS release.

Starting in Junos OS Release 17.2, Junos OS YANG modules are specific to a device family. For a given OS and release, the YANG modules download file and GitHub repository include a separate directory for each device family as well as a common directory. Each family-specific directory contains the configuration and operational command modules that are supported on the platforms in that family, and the common directory contains the modules that are common to all device families. For more information about the device families, see Understanding Junos YANG Modules.

When you generate YANG modules on a local device, the modules include both native Junos modules as well as any standard or custom modules that have been added to the device. Starting in Junos OS Release 17.4R1, the native YANG modules generated on a local device contain family-specific schemas, which are identical across all devices in the given device family. In Junos OS Release 17.3 and earlier, the native YANG modules generated on the local device contain device-specific schemas.

Starting in Junos OS Evolved Release 23.4R1, we publish the Junos OS Evolved native YANG modules on the Juniper Networks download site and on GitHub. In earlier releases, you must generate the YANG modules on the device.

Additionally, starting in Junos OS Release 23.4R1 and Junos OS Evolved Release 23.4R1, we provide all YANG data models for a given OS and release in a single download package and GitHub repository folder. The package and repository include:

  • Native configuration, state, and RPC data models

  • OpenConfig configuration and state models supported by that OS

  • IETF models supported by that OS

Download YANG Modules from Juniper Networks

To download the YANG modules from the Juniper Networks site:

  1. Access the downloads page at https://support.juniper.net/support/downloads.
  2. Select your product.
  3. In the drop-down menus, select the appropriate OS and version.
  4. Expand the Tools section to display the available downloads.
  5. In the Downloads column, click the link for the YANG modules package you want to download.
  6. Review and accept the End User License Agreement.
  7. Follow the instructions on the download page to download the file.
Note:

If your particular product page does not have the YANG modules available for download, you can download the modules from the Juniper/yang GitHub repository or generate the modules on the Junos device.

Generate YANG Modules on Junos Devices

To generate the YANG modules from the Junos CLI:

  1. Log in to the Junos device.
  2. (Optional) By default, Junos devices emit YANG modules with family-specific schemas. To generate modules with device-specific schemas instead, configure the device-specific statement.
  3. Create the directory where the output files will be stored, if it does not already exist.
  4. (Optional) To see a list of available YANG modules, invoke the context-sensitive help.
  5. Execute the show system schema operational mode command and specify which modules to generate and the directory for storing the output files.

    For example:

The device generates the YANG modules in the specified output directory.

Note:

Starting in Junos OS Evolved Release 23.4R2, native YANG modules for QFX Series devices use the junos device family identifier instead of junos-qfx. To emit device-specific schemas that use the junos-qfx family identifier instead, configure the device-specific and emit-family-ns-and-module-name statements at the [edit system services netconf yang-modules] hierarchy level.

Generate YANG Modules from a Remote Session

To generate the YANG modules from a remote session:

  1. Connect to the Junos device. For example:
  2. Execute the <get-yang-schema> RPC, and specify the module or collection name and the output directory.

The device generates the YANG modules in the specified output directory.

Tip:

You can also use the <get-schema> Network Configuration Protocol (NETCONF) operation to retrieve a YANG module from the device. For additional information, see Retrieve Schemas.

Importing Juniper Networks YANG Modules

You can use YANG-based tools to leverage the Juniper Networks YANG modules. If you are developing custom YANG modules, you can reference definitions in the Juniper Networks YANG modules by importing the modules into your custom module.

To import a Juniper Networks YANG module into an existing module:

  1. Include the import statement, specify the module name, and assign the prefix to use with the definitions from the imported module.
    Note:

    The naming convention for the module names, filenames, namespaces, and prefixes of the native Junos OS YANG modules depends on the Junos OS release.

  2. Reference definitions in the module by using the locally defined prefix, a colon, and the node identifier or keyword.

    For example, to reference the interface node defined in the configuration module, use jc:interface.

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
23.4R2-EVO
Starting in Junos OS Evolved Release 23.4R2, native YANG modules for QFX Series devices use the junos device family identifier instead of junos-qfx.
23.4R1 and 23.4R1-EVO
Starting in Junos OS Release 23.4R1 and Junos OS Evolved Release 23.4R1, we provide all YANG data models for a given OS and release in a single download package and GitHub repository folder.
23.4R1-EVO
Starting in Junos OS Evolved Release 23.4R1, we publish the Junos OS Evolved native YANG modules on the Juniper Networks download site and on GitHub. In earlier releases, you must generate the modules on the device.
19.1R2 and 19.2R1
Starting in Junos OS Release 19.1R2 and 19.2R1, the show system schema command and get-yang-schema RPC must include the output-directory option to specify the directory in which to generate the output files. In earlier releases, you can omit the output-directory option when requesting a single module to display the module in standard output.
17.4R1
Starting in Junos OS Release 17.4R1, the YANG modules generated on a local device, by default, contain family-specific schemas, which are identical across all devices in the given device family.
17.2R1
Starting in Junos OS Release 17.2, Junos OS YANG modules are specific to a device family and each module’s namespace reflects the device family to which the schema in the module belongs.