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.
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
.
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:
user@host> file show /var/tmp/yang/junos-rpc-clear@2017-01-01.yang /* * Copyright (c) 2017 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; } organization "Juniper Networks, Inc."; contact "yang-support@juniper.net"; description "Junos RPC YANG module for clear command(s)"; revision 2017-01-01 { description "Junos: 17.4R1.17"; } rpc clear-cli-logical-system { description "Clear logical system association"; output { leaf output { type string; } } } rpc clear-cli-satellite { description "Clear satellite association"; output { leaf output { type string; } } } ...
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.user@host> show system schema format yang module juniper-command
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.user@host> show system schema format yang module all-rpc output-directory /var/tmp/yang
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.
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.
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.
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.juniper-command
module, the output files are placed in the current
working directory, which defaults to the user’s home directory