Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Junos Genstate YANG Data Models

The Juniper Networks genstate YANG schema defines YANG data models for operational state on Junos devices. gRPC Network Management Interface (gNMI) clients can subscribe to the resource paths defined in the models to request state data.

Genstate YANG Data Models Overview

Starting in Junos OS Evolved Release 24.2R1, Juniper Networks publishes the genstate YANG data models. The genstate models are subscribable YANG models for operational state data on Junos devices. They are a YANG representation of the operational command output. The genstate models comprise a top-level module augmented by modules for each of the different operational state areas as they are published and made available.

Junos devices have a rich set of native state data. You can retrieve operational state information from Junos devices by executing operational commands or Junos XML RPCs on the device. However, you must still parse the command output to extract specific data. Juniper also provides the curated junos-state YANG data models that telemetry collectors can consume, but the models include only a subset of operational areas and states.

The genstate YANG models expose state data available in operational show commands through the gNMI subscribe RPC. The modules describe the resource paths that correspond to specific state data on the target network device. gNMI telemetry collectors can subscribe to a resource path in the published YANG models to query for the state data for that instance.

gNMI clients in gRPC dial-in environments can subscribe to the genstate published paths. A client can use STREAM subscriptions in SAMPLE mode to request the data. ON_CHANGE mode is not supported. For information about using gNMI to subscribe to telemetry data, see the Junos Telemetry Interface User Guide.

The genstate YANG data models are published and updated in different releases. You can check the available models and supported paths for a given release in the following ways:

Benefits of the Genstate YANG State Models

  • Increase the surface area of operational state available through gNMI and thus enable you to make more informed usage decisions about the device and network when you use gNMI to monitor state.

  • Simplify how you monitor device state by enabling you to move toward a single northbound interface.

Genstate Modules Overview

The genstate YANG data models comprise a top-level root module augmented by modules for each of the available operational state areas. The genstate schema uses origin 'genstate'.

The top-level module is as follows:

The top-level genstate module is augmented by the modules published for each operational state area. When you issue operational commands or RPCs on a Junos device, the device returns the XML output enclosed in a top-level element. The root-level tag name describes the enclosed data. For example, show interfaces commands return XML output that is enclosed in an <interface-information> tag. The genstate modules include this root tag name in the module name and filename to easily identify the data described in the module. The module prefix is based on the root tag name and so varies for each module.

For example, the junos-genstate-interface-information module describes the data that would normally be included in the <interface-information> element in Junos command and RPC output. Thus, the model defines the resource paths that are available for subscription by telemetry collectors for interface state data.

How to Construct genstate Resource Paths

A telemetry collector can subscribe to the different resource paths as defined in the genstate models to query for state data on devices that support this feature. The genstate model uses the following syntax:

The path uses the origin genstate, a root tag named genstate, and a top-level tag name for the operational state area. For example, to subscribe to genstate resource paths for all interface-information state data, you would use the following path:

You can include supported child tags to retrieve state data for a specific resource. For example, a gNMI client can use the following path to retrieve the operational state for all interfaces:

The genstate resource paths can use simple path expressions to query data. You can use path-based and key-based filters. Table 1 outlines the supported expressions and provides some sample resource paths. Other query patterns are not supported. The path expressions support container, leaf, and key-based filtering and align with gNMI conventions, as outlined in Schema path encoding conventions for gNMI.

Table 1: Path Expressions Supported in genstate Resource Paths
Filter Type Example Paths

Container

  • genstate:/genstate/interface-information

  • genstate:/genstate/snmp-statistics/snmp-input-statistics

Leaf

  • genstate:/genstate/commit-revision-information/revision

  • genstate:/genstate/lldp/lldp-global-status

List key

  • genstate:/genstate/interface-information/physical-interface[name=re0:mgmt-0]

  • genstate:/genstate/interface-information/physical-interface[name=re0:mgmt-0]/oper-status

  • genstate:/genstate/interface-information/physical-interface[name=et-1/0/1]/speed

Multiple list keys

  • genstate:/genstate/interface-information/physical-interface[name=et-1/0/1]/logical-interface[name=et-1/0/1.16386]/local-index

  • genstate:/genstate/interface-information/physical-interface[name=lo0]/logical-interface[name=lo0.0]/address-family[address-family-name=inet]/address-family-name

Wildcard list key

  • genstate:/genstate/interface-information/physical-interface[name=*]/oper-status

  • genstate:/genstate/interface-information/physical-interface/oper-status

Path-based filters can select containers, lists, or leaf nodes. Key-based filters select a subset of list elements and support using precise values, specifying wildcards, or omitting the value. Specifying a wildcard or omitting a list key value matches all entries within a particular list.

We recommend that you always enclose the path in quotation marks. This approach prevents parsing errors in most environments and handles paths with spaces or other special characters.

For example, the following command uses quotation marks around the entire path:

Map Genstate Model Resource Paths to CLI Commands

You can verify the CLI command that generates the output corresponding to a specific genstate resource path. To retrieve the command, use the show system data-models genstate operational command. Include the xpath-cli-command-mapping option and provide the path to the desired resource.

The following example retrieves the command that generates the state data corresponding to the genstate:/genstate/system-information/os-version resource path.

Similarly, the following example maps the given resource path to the CLI command that includes that information in the output.

You can include list key values in the genstate path. When you issue the command or corresponding RPC and specify a list key in the path, enclose the list key value in single quotation marks and enclose the path in double quotation marks. The following examples request the command for genstate paths that specify a key.

Similarly, you can use the <get-genstate-xpath-cli-command-mapping> RPC to retrieve the same information.

If a device does not support a particular genstate path, the command returns the following message:

Note:

If you do not have permission to execute a CLI command, you cannot access the corresponding genstate subscription path. You can only subscribe to genstate paths of commands for which you have valid permissions.

How to Obtain the genstate YANG Modules

You can download 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. For instructions on downloading the modules, see Use Juniper Networks YANG Modules.

To emit the genstate YANG module files on the local device issue the show system schema format yang module module command. Specify an individual module name to return a single genstate module, or specify all-genstate to return all genstate modules. You must also specify an output directory for the files.

For example, the following commands create a directory, write all the genstate modules to that directory, and view the directory listing.

Note:

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

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
25.4R1 & 25.4R1-EVO
Starting in Junos OS Release 25.4R1 and Junos OS Evolved Release 25.4R1, you can use the show system schema operational command or equivalent RPC to view the genstate YANG data models on a device.