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:
/*
* Copyright (c) 2025 Juniper Networks, Inc.
* All rights reserved.
*/
module junos-rpc-clear {
namespace "http://yang.juniper.net/junos/rpc/clear";
prefix clear;
import junos-common-types {
prefix jt;
revision-date 2024-01-01;
}
organization "Juniper Networks, Inc.";
contact "yang-support@juniper.net";
description "Junos RPC YANG module for clear command(s)";
revision 2024-01-01 {
description "Junos: 24.4R1.11";
}
rpc clear-cli-logical-system {
description "Clear logical system association";
output {
choice output_c {
case output-tag {
leaf output {
type string;
}
}
case multichassis-tag {
anyxml multi-routing-engine-results;
}
}
}
}
rpc clear-cli-tenant {
description "Clear teannt association";
output {
choice output_c {
case output-tag {
leaf output {
type string;
}
}
case multichassis-tag {
anyxml multi-routing-engine-results;
}
}
}
}
...
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.
user@host> show system schema format yang module all-rpc output-directory /var/tmp/yang
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.
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.
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.
[edit system services netconf yang-modules] user@host# set device-specific user@host# set emit-anyxml-in-rpc-output user@host# commit
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.
junos device family identifier instead of
junos-qfx.junos:command extension
statement in schemas emitted with extensions.show system
schema command must include the output-directory command
option and specify the directory in which to generate the file or files.