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

Overview of the Operational Command YANG Modules

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, each device family has multiple YANG modules. Each top-level operational command group (clear, file, monitor, and so on) has a module when that hierarchy has at least one command with an RPC equivalent. Additionally, the show command hierarchy has a separate module for each area within that hierarchy.

The operational command modules define the RPCs corresponding to the operational commands in the area indicated by the module's filename. The following example shows a portion of the junos-rpc-clear@2024-01-01.yang module, which contains the RPCs for commands in the clear command hierarchy:

How to Obtain the Operational Command YANG Modules

You can download the Junos native YANG modules from the Juniper Networks download site or the Juniper/yang GitHub repository. You can also 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. 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 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 RPC into your custom module.

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

Note:

The native YANG modules generated on a local device contain family-specific schemas, which are identical across all devices in the given device family. To generate device-specific modules, configure the device-specific configuration statement at the [edit system services netconf yang-modules] hierarchy level.

Note:

To generate YANG 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 emit the YANG schemas with additional Junos extension statements. The Junos extensions are defined in Understanding the Junos DDL Extensions YANG Module. To include extensions, configure the emit-extensions statement at the [edit system services netconf yang-modules] hierarchy level. The device emits the junos:command extension statement starting in Junos OS Release 22.4R1 and Junos OS Evolved Release 22.4R1.

Understanding the RPC Output Schema

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 unknown chunk of XML in the RPC reply. To generate the earlier 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.

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