Team I have the below xml file:
<?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: Will this netconf xml file have a yang model?
Q2: How can i access the underlying yang model(file) for this xml file?
Q1: Will this netconf xml file have a yang model?
You can easily determine if a device is using YANG to model its content from its <hello>
message. Compliant devices advertise the YANG modules they support. The advertised capabilities will differ for YANG 1 and YANG 1.1.
For YANG 1 (RFC6020), this is what the specification says (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>
For YANG 1.1 (RFC7950), in 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.
can't seem to find a way to stop the above blockquote, hence this
Q2: How can i access the underlying yang model(file) for this xml file?
Device manufacturers usually provide a download page on their website, where you obtain their YANG files. Note that not all devices support YANG. NETCONF does not specify what content is modeled with; could be a bunch of XSD schemas, YANG, RelaxNG, etc., though YANG was designed with this purpose in mind (initially).
There is also an optional standard operation defined, called <get-schema>
, which is part of ietf-netconf-monitoring YANG module. You first discover available schema, then obtain them. Since it is optional, not all devices support it.
<?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>