Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All
     

    Related Documentation

     

    Using Juniper Networks YANG Modules

    Juniper Networks provides YANG modules that define the configuration hierarchies and operational commands, as well as YANG extensions, for devices running Junos OS. The following sections detail how to obtain Juniper Networks YANG modules and how to import them into another module:

    Obtaining Juniper Networks YANG Modules

    You can download the Juniper Networks YANG modules from the Juniper website, or you can generate the modules on a device running Junos OS. When generated on the local device, the YANG modules define the schema specific to that device, including hierarchies both from native modules and from any standard or custom modules that have been added to the device.

    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. The YANG modules download file includes a separate directory for each device family as well as a common directory. Each family-specific directory contains the configuration and juniper-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 OS YANG Modules.

    To download the Juniper Networks YANG modules:

    1. Access the downloads page at https://www.juniper.net/support/downloads/junos.html.
    2. Select your product.
    3. In the drop-down menus, select the appropriate release type and version.
    4. Select the Software tab.
    5. In the Tools section, click the YANG module link.

    To generate device-specific YANG modules:

    1. Log in to the device running Junos OS.
    2. Execute the show system schema operational mode command and specify the module name, the YANG format, and optionally, include any desired command options.

      The show system schema command options for the output file depend on the Junos OS release running on the device.

      • In Junos OS Release 15.1 and earlier, to save the output to a specific file, include the output-file-name option, and specify an absolute or relative path for the output file.

        user@host> show system schema module module-name format yang output-file-name path
      • In Junos OS Release 16.1 and later, you can save the module to a specific directory by including the output-directory option, and you can specify an alternate name for the module and the filename by including the module-name option.

        user@host> show system schema module module-name format yang output-directory path module-name module-name

        Note: You can filter for specific sections of the configuration module by including the filter option in the command.

    For example, the following command generates the YANG module that defines the device-specific configuration hierarchy and saves it to a file named configuration.yang in the /var/tmp directory:

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

    If you omit the output-file-name or output-directory option, the device directs the output to standard output, except in the case of the juniper-command module, which always generates output files. If you include the output-directory option but omit the module-name option, the device writes the schema to an output file that uses the existing module name as the filename’s base and the format as the file’s extension. If you include both the output-directory and module-name options, the specified module name is used for both the name of the generated module and for the base name of the output file.

    The juniper-command module represents the operational command hierarchy on devices running Junos OS. Due to the large number of operational commands, when you generate the juniper-command module, the device actually generates multiple files. Each file contains a module that defines the RPCs for commands grouped under the same hierarchy area as indicated by the filename. For more information about the juniper-command module, see Understanding the juniper-command YANG Modules for Operational Commands.

    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.

      module test-system {
         namespace "http://test.example.com/system";
         prefix "test";
      
         import configuration {
            prefix "jc";
         }
         import junos-extension {
            prefix "junos";
         }
      …
      }
      
    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.

     

    Related Documentation

     

    Release History Table

    Release
    Description
    Starting in Junos OS Release 17.2, Junos OS YANG modules are specific to a device family.
    The show system schema command options for the output file depend on the Junos OS release running on the device.

    Modified: 2017-07-26