Junos Genstate YANG 数据模型
瞻博网络 genstate YANG 模式定义了 Junos 设备上作状态的 YANG 数据模型。 gRPC 网络管理接口 (gNMI) 客户端可以订阅模型中定义的资源路径来请求状态数据。
Genstate YANG 数据模型概述
从 Junos OS 演化版 24.2R1 版开始,瞻博网络会发布 生成态 YANG 数据模型。这些 genstate 模型是用于 Junos 设备上作状态数据的可订阅 YANG 模型。它们是 Junos 设备上作命令输出的 YANG 表示。这些 genstate 模型由一个顶级模块组成,该模块在发布和提供时由每个不同作状态域的模块进行增强。该 genstate 架构使用源 'genstate'。
Junos 设备拥有丰富的原生状态数据集。通过在设备上执行作命令或 Junos XML RPC,可以从 Junos 设备检索作状态信息。但是,您仍必须分析命令输出才能提取特定数据。瞻博网络还提供遥测收集者可以使用的精选 junos-state 原生 YANG 状态模型,但这些模型目前仅包含一部分作区域和状态。
genstate YANG 模型通过 gNMI 订阅 RPC 公开作 show 命令中可用的状态数据。这些模块描述与目标网络设备上的特定状态数据实例相关的资源路径。gNMI 遥测采集器可以订阅已发布的 YANG 模型中对应的资源路径,查询该实例的状态数据。
在 Junos 设备上执行作命令或 RPC 时,设备将返回包含在顶级元素中的 XML 输出。根级标记名称描述封闭的数据。例如, show interfaces 命令返回包含在标记中的 <interface-information> XML 输出。这些 genstate 模块在 YANG 模块名称和文件名中包含顶级 XML 标记名称,以便轻松识别模块中描述的数据。
gRPC 拨入环境中的 gNMI 客户端可以订阅 genstate 已发布的路径。客户端只能在 SAMPLE 模式下使用 STREAM 订阅来请求数据。不支持ON_CHANGE模式。有关使用 gNMI 订阅遥测数据的信息,请参阅 Junos 遥测接口用户指南。
genstate YANG 数据模型在不同的版本中发布和更新。您可以通过以下方式检查给定版本的可用型号和支持的路径:
-
从 Juniper/yang GitHub 存储库查看或下载模块。
-
从 瞻博网络 网站下载模块,网址 为 https://www.juniper.net/support/downloads。
Genstate YANG 状态模型的优势
-
增加通过 gNMI 提供的作状态的表应用,从而使您在使用 gNMI 监控状态时能够对设备和网络做出更明智的使用决策。
-
通过使您能够转向单个北向接口来简化您监控设备状态的方式。
Genstate 模块概述
genstate YANG 数据模型包括一个顶层根模块,该模块由每个可用作状态区域的模块增强。该genstate架构使用源 'genstate'。
顶级模块如下:
module junos-genstate {
namespace "http://yang.juniper.net/junos/genstate/";
prefix jgs;
organization
"Juniper Networks, Inc.";
contact
"Juniper Networks, Inc.
1133 Innovation Way
Sunnyvale, CA
+1 888 314-5822
E-mail: yang-support@juniper.net";
description
"This module contains a collection of top level nodes for JUNOS genstate data.
Copyright (c) 2023 Juniper Networks, Inc.
All rights reserved.";
revision 2023-01-01 {
description "Junos: ";
}
grouping genstate-top {
description "Top-level grouping for JUNOS genstate data";
container genstate {
description "Encapsulating top-level state container for all JUNOS genstate data";
config false;
}
}
uses genstate-top;
}
顶级 genstate 模块通过为每个作状态区域发布的模块进行扩充。发出作命令或 RPC 时,生成的 XML 输出定义描述作区域的根标记。这些 genstate 模块将此根标记名称作为模块名称和文件名的一部分,以便轻松识别作状态区域。模块前缀基于根标记名称,因此因每个模块而异。
例如,该 junos-genstate-interface-information 模块描述通常包含在 Junos 命令和 RPC 输出的 <interface-information> 元素中的数据。因此,该模型定义了可供遥测收集器订阅接口状态数据的资源路径。
module junos-genstate-interface-information {
namespace "http://yang.juniper.net/junos/genstate/interface-information";
prefix jgii;
import junos-genstate {
prefix jgs;
revision-date 2023-01-01;
}
import junos-common-types {
prefix jt;
revision-date 2023-01-01;
}
organization
"Juniper Networks, Inc.";
contact
"Juniper Networks, Inc.
1133 Innovation Way
Sunnyvale, CA
+1 888 314-5822
E-mail: yang-support@juniper.net";
description "Junos genstate data model for interface-information";
revision 2023-01-01 {
description "Junos: ";
}
grouping interface-information-top {
description "Top-level grouping";
container interface-information {
config false;
description "Top-level container";
list physical-interface {
leaf name {
type string;
description "Name of this item";
}
leaf oper-status {
type string;
description "Current operational state of the interface";
}
leaf local-index {
type int32;
description "Local kernel index for this interface";
}
leaf snmp-index {
type int32;
description "SNMP ifIndex for this interface";
}
container if-config-flags {
leaf iff-none {
type empty;
}
leaf iff-hardware-down {
type empty;
}
leaf iff-down {
type empty;
}
leaf iff-up {
type empty;
}
leaf iff-admin-down {
type empty;
}
leaf iff-admin-up {
type empty;
}
leaf iff-link-down {
type empty;
}
leaf iff-device-down {
type empty;
}
leaf iff-point-to-point {
type empty;
}
leaf iff-point-to-multipoint {
type empty;
}
leaf plp-to-clp {
type empty;
}
leaf iff-multiaccess {
type empty;
}
leaf iff-snmp-traps {
type empty;
}
leaf iff-looped {
type empty;
}
leaf iff-framing-conflict {
type empty;
}
leaf internal-flags {
type string;
description "Hexadecimal value of internal flag bits";
}
}
list logical-interface {
leaf name {
type string;
description "Name of this item";
}
leaf local-index {
type int32;
description "Local kernel index for this interface";
}
leaf snmp-index {
type int32;
description "SNMP ifIndex for this interface";
}
leaf generation {
type string;
description "Generation number used to distinguish between successive instances of this interface";
}
leaf description {
type string;
description "Description of this interface";
}
leaf link-address {
type string;
description "Link address on this logical interface";
}
leaf encapsulation {
type string;
description "Encapsulation on the logical interface";
}
leaf subunit {
type int32;
description "Subunit for this interface";
}
container if-config-flags {
leaf iff-none {
type empty;
}
leaf iff-hardware-down {
type empty;
}
leaf iff-down {
type empty;
}
leaf iff-up {
type empty;
}
leaf iff-admin-down {
type empty;
}
leaf iff-admin-up {
type empty;
}
leaf iff-link-down {
type empty;
}
leaf iff-device-down {
type empty;
}
leaf iff-point-to-point {
type empty;
}
leaf iff-point-to-multipoint {
type empty;
}
leaf plp-to-clp {
type empty;
}
leaf iff-multiaccess {
type empty;
}
leaf iff-snmp-traps {
type empty;
}
leaf iff-looped {
type empty;
}
leaf iff-framing-conflict {
type empty;
}
leaf internal-flags {
type string;
description "Hexadecimal value of internal flag bits";
}
}
leaf admin-status {
type string;
description "Desired state of the interface";
}
leaf oper-status {
type string;
description "Current operational state of the interface";
}
}
}
}
}
augment "/jgs:genstate" {
description "Adds interface-information to top-level genstate";
uses interface-information-top;
}
}
遥测收集器可以订阅模型中定义的不同 genstate 资源路径,以查询状态数据。 genstate 模型路径语法使用原点 genstate,包括一个名为 genstate的根标记,后跟作状态区域的顶级标记名称,例如 interface-information。
genstate:/genstate/interface-information/
例如,gNMI 客户端可以使用以下路径检索 et-1/0/1 接口的管理状态:
genstate:/genstate/interface-information/physical-interface[name=et-1/0/1]/admin-status
将 Genstate 模型资源路径映射到 CLI 命令
您可以使用 show system data-models genstate 作命令验证 CLI 命令,该命令生成与特定 genstate 模型资源路径(Xpath 表达式)对应的输出。要检索命令,请包含该 xpath-cli-command-mapping 选项并提供所需资源的路径。
以下示例检索生成与 /genstate/system-information/os-version 资源路径对应的状态数据的命令。
user@host> show system data-models genstate xpath-cli-command-mapping /genstate/system-information/os-version Genstate xpath to CLI command mapping information (sometimes multiple commands might be mapped): > show system information
同样,以下示例将 /genstate/interface-information/physical-interface[name=et-1/0/1]/admin-status 路径映射到输出中包含该信息的 CLI 命令。
user@host> show system data-models genstate xpath-cli-command-mapping /genstate/interface-information/physical-interface[name=et-1/0/1]/admin-status Genstate xpath to CLI command mapping information (sometimes multiple commands might be mapped): > show interfaces extensive
如果您没有执行 CLI 命令的权限,则无法访问相应的 genstate 订阅路径。您只能订阅您拥有有效权限的命令 的属态 路径。