Requesting Operational Information Using NETCONF
Within a NETCONF session, a client application can request information
about the current status of a device running Junos OS. To request
operational information, a client application emits the specific request
tag element from the Junos XML API that returns the desired information.
For example, the
<get-interface-information> tag element corresponds to the show interfaces command,
<get-chassis-inventory> tag element
requests the same information as the show chassis hardware command, and the
<get-system-inventory> tag element requests the same information as the show software
For complete information about the operational request tag elements available in the current Junos OS release, see “Mapping Between Operational Tag Elements, Perl Methods, and CLI Commands” and “Summary of Operational Request Tag Elements” in the Junos XML API Operational Developer Reference.
The application encloses the request tag in an
<rpc> element. The syntax depends on whether the
corresponding CLI command has any options included.
The client application can specify the formatting of the information
returned by the NETCONF server. By setting the optional
format attribute in the opening operational request
tag, a client application can specify the format of the response as
either XML-tagged format, which is the default, formatted ASCII text,
the format, see Specifying the Output Format for Operational Information Requests in a NETCONF Session.
When displaying operational or configuration data that contains characters outside the 7-bit ASCII character set, Junos OS escapes and encodes these character using the equivalent UTF-8 decimal character reference. For more information see Understanding Character Encoding on Devices Running Junos OS.
If the client application requests the output in XML-tagged
format, the NETCONF server encloses its response in the specific response
tag element that corresponds to the request tag element, which is
then enclosed in an
For XML-tagged format, the opening tag for each operational
response includes the
xmlns attribute to
define the XML namespace for the enclosed tag elements that do not
have a prefix (such as
junos:) in their
names. The namespace indicates which Junos XML document type definition
(DTD) defines the set of tag elements in the response. The Junos XML
API defines separate DTDs for operational responses from different
software modules. For instance, the DTD for interface information
the DTD for chassis information is called
junos-chassis.dtd. The division into separate DTDs and XML namespaces means that a
tag element with the same name can have distinct functions depending
on which DTD it is defined in.
The namespace is a URL of the following form:
release-code is the standard string that represents the Junos OS release that is running on the NETCONF server device.
category specifies the DTD.
The Junos XML API Operational Developer Reference includes the text of the Junos XML DTDs for operational responses.
If the client application requests the output in formatted
ASCII text, the NETCONF server encloses its response in an
<output> tag element, which is enclosed in an
If the client application requests the output in JSON
format, the NETCONF server encloses the JSON data in the
<rpc-reply> tag element.