Request Identifier Indicators for Configuration Elements Using the Junos XML Protocol
In a Junos XML protocol session with a device running
Junos OS, to request that the server indicate whether a child configuration
element is an identifier for its parent element, a client application
includes the junos:key="key"
attribute
in the opening <junoscript>
tag for
the Junos XML protocol session or includes the junos:key="key"
or key="key"
attribute in the <get-configuration>
request tag:
<junoscript version="version" hostname="hostname" junos:key="key" release="release-code"> <!-- OR --> <rpc> <get-configuration (junos:key | key)="key"> <!-- tag elements for the configuration elements to return --> </get-configuration> </rpc>
For more information about the <junoscript>
tag, see Starting Junos XML Protocol
Sessions.
When the identifier indicator is requested, the Junos
XML protocol server includes the junos:key="key"
attribute in the opening tag for each identifier. As always, the
Junos XML protocol server encloses its response in <rpc-reply>
and <configuration>
tag elements.
In the following example, the identifier tag element is called <name>
:
<rpc-reply xmlns:junos="URL"> <configuration attributes> <!-- opening tag for each parent of the object --> <!-- For each configuration object with an identifier --> <object> <name junos:key="key">identifier</name> <!-- additional children of object --> </object> <!-- closing tag for each parent of the object --> </configuration> </rpc-reply>
If the requested output format is JSON, the Junos XML
protocol server adds a metadata object that includes "junos:key" : "key"
to indicate the identifier.
If the Junos OS object uses name
for the
identifier, a metadata object with name "@" is added as a new member
of the object. If the Junos OS object uses an identifier other than name
, the metadata object is added as a sibling name/value
pair that uses the name "@" concatenated with the identifier name.
The response is enclosed in <configuration-json>
and <rpc-reply>
tag elements.
<rpc-reply xmlns:junos="URL"> <configuration-json> { "configuration" : { /* JSON objects for parent levels of the element */ "object" : [ { "@" : { "junos:key" : "key" }, "name" : "identifier", "identifier-name" : "identifier-value", "@identifier-name" : { "junos:key" : "key" }, /* additional data and child objects */ # if any } ] /* closing braces for parent levels of the element */ } } </configuration-json> </rpc-reply>
In the following output, the combination of name
and next-hop
uniquely
identify the static route:
{ "configuration" : { "routing-options" : { "static" : { "route" : [ { "@" : { "junos:key" : "key" }, "name" : "172.16.0.0/12", "next-hop" : ["198.51.100.1"], "@next-hop" : { "junos:key" : "key" }, "retain" : [null], "no-readvertise" : [null] } ] } } } }
Starting in Junos OS Release 16.1, devices running Junos OS emit JSON-formatted configuration data using a new default implementation for serialization. The new default uses the "@" symbol instead of the field name "attribute" to indicate an attribute.
The client application can include one or more of the following
other attributes in the <get-configuration/>
tag or opening <get-configuration>
tag when the junos:key
attribute is included
in the opening <junoscript>
or <get-configuration>
tags:
changed
, which is described in Requesting Change Indicators for Configuration Elements Using the Junos XML Protocolcommit-scripts
, which is described in Requesting Commit-Script-Style XML Configuration Data Using the Junos XML Protocoldatabase
, which is described in Specifying the Source for Configuration Information Requests in a Junos XML Protocol Sessioninherit
and optionallygroups
andinterface-ranges
, which are described in Specifying the Output Format for Configuration Groups and Interface Ranges Using the Junos XML Protocol
When requesting an indicator for identifiers, it does not make
sense to include the format="text"
attribute
in the <get-configuration>
tag element
(as described in Specifying the Output
Format for Configuration Data in a Junos XML Protocol Session). The junos:key="key"
attribute appears
only in Junos XML-tagged output, which is the default output format,
and in JSON output. The compare
attribute
produces only text output, so when the compare
attribute is included in the <get-configuration>
tag, the junos:key="key"
attribute does
not appear in the output.
The following example shows how indicators for identifiers appear
on configuration elements at the [edit interfaces]
hierarchy level in the candidate configuration when the junos:key="key"
attribute is included in the opening <junoscript>
tag emitted by the client application
for the session. The two opening <junoscript>
tags appear on multiple lines for legibility only. Neither client
applications nor the Junos XML protocol server insert newline characters
within tags. Also, for brevity the output includes just one interface,
the loopback interface lo0.
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.