Understanding the YANG Modules That Define the Junos OS Configuration

 

Juniper Networks publishes the Junos OS configuration schema using YANG models. In Junos OS Release 17.3 and earlier, the Junos OS configuration schema is published in a single YANG module. Starting in Junos OS Release 17.4R1, the Junos OS configuration schema is published using a root configuration module that is augmented by multiple, smaller modules. This enables consumers of the schema to only import the modules required for their tasks.

Note

Starting in Junos OS Release 17.4R1, Junos OS YANG modules use a new naming convention for the module’s name, filename, and namespace. For more information, see Understanding Junos OS YANG Modules.

The root configuration module comprises the top level configuration node and any nodes that are not emitted as separate modules. Separate, smaller modules augment the root configuration module for the different configuration statement hierarchies. The configuration modules that augment the root module contain the schema for the configuration statement hierarchy level that is indicated in the module’s name, filename, and namespace.

The following example shows a portion of the module containing the YANG model for the [edit interfaces] hierarchy:

YANG utilities need to import only those modules required for the specific configuration task at hand. As a result, tools that consume the configuration modules require less time to compile, validate, or perform other functions on the modules than when importing a single, large module.

To determine the configuration YANG module corresponding to a specific area of the configuration, issue the show | display detail configuration mode command. In the following example, the schema for the [edit protocols ospf] hierarchy level is included in the junos-conf-protocols@2017-01-01.yang module.

user@host# show protocols ospf | display detail

You can download the Junos OS YANG modules from the Juniper Networks download site, or you can generate them on the local device. To generate the configuration modules on the local device, issue the show system schema format yang module module command. The Junos OS release determines the available command options.

  • In Junos OS Release 17.3 and earlier, specify the configuration module.

    user@host> show system schema format yang module configuration
  • In Junos OS Release 17.4 and later, specify an individual module name to display a single configuration module, or specify all-conf to display all configuration modules. By default, a single module is displayed in standard output. When you request multiple modules, you must include the output-directory command option and specify the directory in which to generate the files.

    user@host> show system schema format yang module all-conf output-directory /var/tmp/yang
Note

To generate the modules from a remote session, execute the <get-yang-schema> Junos OS RPC or the <get-schema> Network Configuration Protocol (NETCONF) operation with the appropriate options.

If you specify module configuration or module all-conf, the output files include both native Junos OS configuration modules as well as any standard or custom configuration modules that have been added to the device.

Note

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 earlier releases, the generated modules contain device-specific schemas. To generate device-specific modules in Junos OS Release 17.4R1 and later, configure the device-specific configuration statement at the [edit system services netconf yang-modules] hierarchy level.

Release History Table
Release
Description
Starting in Junos OS Release 17.4R1, the Junos OS configuration schema is published using a root configuration module that is augmented by multiple, smaller modules.
Starting in Junos OS Release 17.4R1, Junos OS YANG modules use a new naming convention for the module’s name, filename, and namespace.