Understanding the YANG Modules That Define the Junos OS Configuration
Juniper Networks publishes the Junos OS configuration schema using YANG models. In Junos OS Release 17.3 and earlier, the Junos OS configuration schema is published in a single YANG module. Starting in Junos OS Release 17.4R1, the Junos OS configuration schema is published using a root configuration module that is augmented by multiple, smaller modules. This enables consumers of the schema to only import the modules required for their tasks.
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 root configuration module comprises the top level configuration node and any nodes that are not emitted as separate modules. Separate, smaller modules augment the root configuration module for the different configuration statement hierarchies. The configuration modules that augment the root module contain the schema for the configuration statement hierarchy level that is indicated in the module’s name, filename, and namespace.
The following example shows a portion of the module containing the YANG model for the
[edit interfaces]
hierarchy:
/* * Copyright (c) 2017 Juniper Networks, Inc. * All rights reserved. */ module junos-conf-interfaces { namespace "http://yang.juniper.net/junos/conf/interfaces"; prefix jc-interfaces; import junos-common-types { prefix jt; } import junos-conf-root { prefix jc; } organization "Juniper Networks, Inc."; contact "yang-support@juniper.net"; description "Junos interfaces configuration module"; revision 2017-01-01 { description "Junos: 17.4R1.17"; } augment /jc:configuration { uses interfaces-group; } augment /jc:configuration/jc:groups { uses interfaces-group; } ...
YANG utilities need to import only those modules required for the specific configuration task at hand. As a result, tools that consume the configuration modules require less time to compile, validate, or perform other functions on the modules than when importing a single, large module.
To determine the configuration YANG module corresponding to a specific area of the
configuration, issue the show | display detail
configuration mode command. In
the following example, the schema for the [edit protocols ospf]
hierarchy
level is included in the junos-conf-protocols@2017-01-01.yang module.
user@host# show protocols ospf | display detail ## ## ospf: OSPF configuration ## YANG module: junos-conf-protocols@2017-01-01.yang ## lsa-refresh-interval: LSA refresh interval (minutes) ## range: 25 .. 50 ## ## default: 50 ## ...
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 configuration 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
configuration
module.user@host> show system schema format yang module configuration
-
In Junos OS Release 17.4 and later, specify an individual module name to return a single configuration module, or specify
all-conf
to return all configuration modules.user@host> show system schema format yang module all-conf output-directory /var/tmp/yang
If you specify module configuration
or module all-conf
, the
output files include both native Junos OS configuration modules as well as any standard or
custom configuration modules that have been added to the device.
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>
Network Configuration Protocol (NETCONF) operation
with the appropriate options.
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
.show system
schema
command must include the output-directory
command
option and specify the directory in which to generate the file or files.