关于 netconf xml 文件的 yang 模型
Regarding the yang model for netconf xml file
团队
我有以下 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<rpc message-id="${TIMESTAMP}" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<get-config>
<source>
<running></running>
</source>
<filter>
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg"/>
</filter>
</get-config>
</rpc>
Q1:这个 netconf xml 文件会有阳模型吗?
问题 2:如何访问此 xml 文件的底层 yang 模型(文件)?
Q1: Will this netconf xml file have a yang model?
您可以轻松确定设备是否使用 YANG 从其 <hello>
消息中对其内容进行建模。合规设备宣传它们支持的 YANG 模块。 YANG 1 和 YANG 1.1 的广告功能会有所不同。
对于 YANG 1 (RFC6020),规范是这样说的 (5.6.4.1):
Servers indicate the names of supported modules via the <hello>
message. Module namespaces are encoded as the base URI in the
capability string, and the module name is encoded as the "module"
parameter to the base URI.
A server MUST advertise all revisions of all modules it implements.
For example, this <hello>
message advertises one module "syslog".
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<capability>
http://example.com/syslog?module=syslog&revision=2008-04-01
</capability>
</hello>
对于 YANG 1.1 (RFC7950),在 5.6.4:
A NETCONF server MUST announce the modules it implements (see
Section 5.6.5) by implementing the YANG module "ietf-yang-library"
defined in [RFC7895] and listing all implemented modules in the
"/modules-state/module" list.
The server also MUST advertise the following capability in the
<hello>
message (line breaks and whitespaces are used for formatting
reasons only):
urn:ietf:params:netconf:capability:yang-library:1.0?
revision=<date>&module-set-id=<id>
The parameter "revision" has the same value as the revision date of
the "ietf-yang-library" module implemented by the server. This
parameter MUST be present.
The parameter "module-set-id" has the same value as the leaf
"/modules-state/module-set-id" from "ietf-yang-library". This
parameter MUST be present.
With this mechanism, a client can cache the supported modules for a
server and only update the cache if the "module-set-id" value in the
<hello>
message changes.
似乎找不到停止上述块引用的方法,因此
Q2: How can i access the underlying yang model(file) for this xml file?
设备制造商通常会在他们的网站上提供下载页面,您可以从中获取他们的 YANG 文件。请注意,并非所有设备都支持 YANG。 NETCONF 没有 specify 用什么内容建模;可能是一堆 XSD 模式、YANG、RelaxNG 等,尽管 YANG 是为这个目的而设计的(最初)。
还定义了一个可选的标准操作,称为 <get-schema>
,它是 ietf-netconf-monitoring YANG 模块的一部分。您首先发现可用的模式,然后获取它们。由于它是可选的,因此并非所有设备都支持它。
<?xml version="1.0" encoding="utf-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<get>
<filter type="subtree">
<ncm:netconf-state xmlns:ncm="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<ncm:schemas/>
</ncm:netconf-state>
</filter>
</get>
</rpc>
<?xml version="1.0" encoding="utf-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<data>
<netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<schemas>
<schema>
<identifier>ietf-inet-types</identifier>
<version>2013-07-15</version>
<format>yang</format>
<namespace>urn:ietf:params:xml:ns:yang:ietf-inet-types</namespace>
<location>NETCONF</location>
</schema>
<!-- ... -->
</schemas>
</netconf-state>
</data>
</rpc-reply>
<?xml version="1.0" encoding="utf-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="8">
<get-schema xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<identifier>ietf-interfaces</identifier>
<version>2014-05-08</version>
<format>yang</format>
</get-schema>
</rpc>
<?xml version="1.0" encoding="utf-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="8">
<data xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">module ietf-interfaces {
namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
prefix if;
// ...
}
</data>
</rpc-reply>
团队 我有以下 xml 文件:
<?xml version="1.0" encoding="utf-8"?>
<rpc message-id="${TIMESTAMP}" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<get-config>
<source>
<running></running>
</source>
<filter>
<interface-configurations xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ifmgr-cfg"/>
</filter>
</get-config>
</rpc>
Q1:这个 netconf xml 文件会有阳模型吗?
问题 2:如何访问此 xml 文件的底层 yang 模型(文件)?
Q1: Will this netconf xml file have a yang model?
您可以轻松确定设备是否使用 YANG 从其 <hello>
消息中对其内容进行建模。合规设备宣传它们支持的 YANG 模块。 YANG 1 和 YANG 1.1 的广告功能会有所不同。
对于 YANG 1 (RFC6020),规范是这样说的 (5.6.4.1):
Servers indicate the names of supported modules via the
<hello>
message. Module namespaces are encoded as the base URI in the capability string, and the module name is encoded as the "module" parameter to the base URI.
A server MUST advertise all revisions of all modules it implements.
For example, this
<hello>
message advertises one module "syslog".
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <capability> http://example.com/syslog?module=syslog&revision=2008-04-01 </capability> </hello>
对于 YANG 1.1 (RFC7950),在 5.6.4:
A NETCONF server MUST announce the modules it implements (see Section 5.6.5) by implementing the YANG module "ietf-yang-library" defined in [RFC7895] and listing all implemented modules in the "/modules-state/module" list.
The server also MUST advertise the following capability in the
<hello>
message (line breaks and whitespaces are used for formatting reasons only):
urn:ietf:params:netconf:capability:yang-library:1.0?
revision=<date>&module-set-id=<id>
The parameter "revision" has the same value as the revision date of the "ietf-yang-library" module implemented by the server. This parameter MUST be present.
The parameter "module-set-id" has the same value as the leaf "/modules-state/module-set-id" from "ietf-yang-library". This parameter MUST be present.
With this mechanism, a client can cache the supported modules for a server and only update the cache if the "module-set-id" value in the
<hello>
message changes.
似乎找不到停止上述块引用的方法,因此
Q2: How can i access the underlying yang model(file) for this xml file?
设备制造商通常会在他们的网站上提供下载页面,您可以从中获取他们的 YANG 文件。请注意,并非所有设备都支持 YANG。 NETCONF 没有 specify 用什么内容建模;可能是一堆 XSD 模式、YANG、RelaxNG 等,尽管 YANG 是为这个目的而设计的(最初)。
还定义了一个可选的标准操作,称为 <get-schema>
,它是 ietf-netconf-monitoring YANG 模块的一部分。您首先发现可用的模式,然后获取它们。由于它是可选的,因此并非所有设备都支持它。
<?xml version="1.0" encoding="utf-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<get>
<filter type="subtree">
<ncm:netconf-state xmlns:ncm="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<ncm:schemas/>
</ncm:netconf-state>
</filter>
</get>
</rpc>
<?xml version="1.0" encoding="utf-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
<data>
<netconf-state xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<schemas>
<schema>
<identifier>ietf-inet-types</identifier>
<version>2013-07-15</version>
<format>yang</format>
<namespace>urn:ietf:params:xml:ns:yang:ietf-inet-types</namespace>
<location>NETCONF</location>
</schema>
<!-- ... -->
</schemas>
</netconf-state>
</data>
</rpc-reply>
<?xml version="1.0" encoding="utf-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="8">
<get-schema xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">
<identifier>ietf-interfaces</identifier>
<version>2014-05-08</version>
<format>yang</format>
</get-schema>
</rpc>
<?xml version="1.0" encoding="utf-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="8">
<data xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring">module ietf-interfaces {
namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
prefix if;
// ...
}
</data>
</rpc-reply>