Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Understanding the YANG Modules for Junos Operational Commands

Juniper Networks publishes YANG modules that define the remote procedure calls (RPCs) for Junos operational mode commands. Due to the large number of operational commands, there are multiple YANG modules for each device family. There is a module for each top-level operational command group (clear, file, monitor, and so on) where there is at least one command within that hierarchy with an RPC equivalent. There is also a separate module for each area within the show command hierarchy.

Note:

Starting in Junos OS Release 17.2, Junos YANG modules are specific to a device family and use a new convention for the module namespace. In addition, each individual operational command module defines its namespace prefix using the command hierarchy area of the RPCs included in that module. Prior to Junos OS Release 17.2, the prefix for all operational command modules was jrpc.

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 YANG Modules.

The operational command modules define the RPCs corresponding to the operational commands in the command hierarchy area indicated in the filename. The following example shows a portion of the module containing the RPCs for commands in the clear command hierarchy:

YANG defines operations using the rpc statement. The RPC definition can include input and output substatements that describe the operation's input and output parameters. Starting in Junos OS Release 23.1R1 and Junos OS Evolved Release 23.2R1, the RPC's output statement includes an accurate output schema, and Junos devices emit the new schemas by default.

In earlier releases, the RPC's output schema includes the anyxml statement to represent an unkown chunk of XML in the RPC reply. To generate the RPC schemas containing the anyxml statement on a Junos device, configure the device-specific and emit-anyxml-in-rpc-output statements at the [edit system services netconf yang-modules] hierarchy level. After you configure the statements, the show system schema command generates the schemas that use anyxml.

You can download the Junos native YANG modules from the Juniper Networks download site or the Juniper/yang GitHub repository, or you can generate the modules on the local device. To generate the operational command YANG 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 juniper-command module to generate all of the operational command modules.

    Note:

    Starting in Junos OS Release 17.1, when you generate the juniper-command module, the output files are placed in the current working directory, which defaults to the user’s home directory. In Junos OS Release 16.2 and earlier, the output files are placed in the /var/tmp directory.

  • In Junos OS Release 17.4R1 and later, specify an individual module name to return a single operational command module, or specify all-rpc to return all operational command modules.

If you specify module juniper-command or module all-rpc, the output files include both native Junos operational command modules as well as any standard or custom operational command modules that have been added to the device. To use an RPC in your custom YANG module, you must import the module that contains the desired RPC into your custom module.

Starting in Junos OS Release 19.1R2 and 19.2R1, the show system schema command must include the output-directory command option and specify the directory in which to generate the file or files. In earlier releases, you can omit the output-directory option when requesting a single module to display the module in standard output.

Note:

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

You can configure the emit-extensions statement at the [edit system services netconf yang-modules] hierarchy level to emit the YANG schemas with additional Junos extension statements. The Junos extensions are defined in Understanding the Junos DDL Extensions YANG Module. The device emits the junos:command extension statement starting in Junos OS Release 22.4R1 and Junos OS Evolved Release 22.4R1.

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
23.4R1-EVO
Starting in Junos OS Evolved Release 23.4R1, native YANG modules for QFX Series devices use the junos device family identifier instead of junos-qfx.
23.2R1-EVO
Starting in Junos OS Evolved Release 23.2R1, the YANG modules that define Junos RPCs include accurate output schemas.
23.1R1
Starting in Junos OS Release 23.1R1, the YANG modules that define Junos RPCs include accurate output schemas.
22.4R1 and 22.4R1-EVO
Starting in Junos OS Release 22.4R1 and Junos OS Evolved Release 22.4R1, YANG modules that define RPCs include the junos:command extension statement in schemas emitted with extensions.
19.2R1
Starting in Junos OS Release 19.1R2 and 19.2R1, the show system schema command must include the output-directory command option and specify the directory in which to generate the file or files.
17.4R1
Starting in Junos OS Release 17.4R1, Junos YANG modules use a new naming convention for the module’s name, filename, and namespace.
17.2R1
Starting in Junos OS Release 17.2, Junos YANG modules are specific to a device family and use a new convention for the module namespace. In addition, each of the individual operational command modules uses the command hierarchy area of the RPCs included in that module as its namespace prefix.
17.1R1
Starting in Junos OS Release 17.1, when you generate the juniper-command module, the output files are placed in the current working directory, which defaults to the user’s home directory