Specify the Output Format for Configuration Groups and Interface Ranges Using the Junos XML Protocol
The <groups>
tag element
corresponds to the [edit groups]
configuration hierarchy.
It encloses tag elements representing configuration groups, each of which contains a set of configuration statements that are
appropriate at multiple locations in the hierarchy. You use the apply-groups
configuration statement or <apply-groups>
tag element to insert a configuration group at the appropriate location,
achieving the same effect as directly inserting the statements defined
in the group. The section of configuration hierarchy to which a configuration
group is applied is said to inherit the group’s
statements.
In addition to the groups defined at the [edit groups]
hierarchy level, Junos OS predefines a group called junos-defaults
. This group includes configuration statements judged appropriate
for basic operations on any routing, switching, or security platform.
By default, the statements in this group do not appear in the output
of CLI commands that display the configuration, nor in the output
returned by the Junos XML protocol server for the <get-configuration>
tag element. For more information about user-defined configuration
groups and the junos-defaults
group, see the CLI User Guide.
The <interface-range>
tag element
corresponds to the [edit interfaces interface-range]
configuration hierarchy. An interface range is a set of interfaces
to which you can apply a common configuration profile. If an interface
is a member of an interface range, it inherits the configuration statements
set for that range.
The following sections explain how to display groups and interface range configurations within their inheriting elements in configuration data that is requested through a Junos XML protocol session. The sections also discuss how to view the source group or interface range for configuration elements that are inherited from a group or interface range.
Specifying Whether Configuration Groups and Interface Ranges Are Inherited or Displayed Separately
By default, the Junos XML protocol server displays the tag element
for each user-defined configuration group as a child of the <groups>
tag element, instead of displaying them
as children of the elements to which they are applied. Similarly,
the server displays the tag elements for each user-defined interface
range as a child of the <interface-range>
tag element, instead of displaying them as children of the elements
that are members of the interface range. This display mode parallels
the default behavior of the CLI configuration mode show
command, which displays [edit groups]
and [edit interfaces
interface-range]
as separate hierarchies in the configuration.
To request that the Junos XML protocol server not display
the <groups>
, <apply-groups>
, or <interface-range>
elements separately,
but instead enclose tag elements inherited from user-defined groups
or interface ranges within the inheriting tag elements, a client application
includes the inherit="inherit"
attribute
in the <get-configuration>
tag. It encloses
the request in an <rpc>
tag element:
<rpc> <get-configuration inherit="inherit"/> <!-- OR --> <get-configuration inherit="inherit"> <!-- tag elements for the configuration elements to return --> </get-configuration> </rpc>
To request that the Junos XML protocol server include
tag elements that are inherited from the junos-defaults
group as well as user-defined configuration groups and interface-ranges,
the client application includes the inherit="defaults"
attribute in the <get-configuration>
tag.
<rpc> <get-configuration inherit="defaults"/> <!-- OR --> <get-configuration inherit="defaults"> <!-- tag elements for the configuration elements to return --> </get-configuration> </rpc>
For information about the tag elements to enclose in the <get-configuration>
tag element, see Specifying the Scope of Configuration Data to Return
in a Junos XML Protocol Session.
When the client includes the inherit="inherit"
attribute, the output includes the same information as the output
from the following CLI configuration mode command. The output does
not include configuration elements inherited from the junos-defaults
group.
user@host# show | display inheritance | except ##
When the client includes the inherit="defaults"
attribute,
the output includes the same information as the output from the following
CLI configuration mode command:
user@host# show | display inheritance defaults | except ##
In both cases, the Junos XML protocol server encloses
its output in the <rpc-reply>
tag element
and one of the following tag elements depending on the requested format:
the <configuration>
tag element (for
Junos XML-tagged output), the <configuration-text>
tag element (for formatted ASCII output), the <configuration-set>
tag element (for configuration mode set commands), or the <configuration-json>
tag element (for JSON-formatted
data). For information about the attributes in the opening <configuration>
tag, see Specifying the Source for Configuration Information Requests in a
Junos XML Protocol Session.
<rpc-reply xmlns:junos="URL"> <configuration attributes> <!-- Junos XML tag elements representing configuration elements --> </configuration> <!-- OR --> <configuration-text> <!-- formatted ASCII configuration statements --> </configuration-text> <!-- OR --> <configuration-set> <!-- configuration mode commands --> </configuration-set> <!-- OR --> <configuration-json> <!-- JSON-formatted configuration data --> </configuration-json> </rpc-reply>
The inherit
attribute can
be combined with one or more of the following attributes in the <get-configuration/>
tag or opening <get-configuration>
tag:
changed
, which is described in Requesting Change Indicators for Configuration Elements Using the Junos XML Protocoldatabase
, which is described in Specifying the Source for Configuration Information Requests in a Junos XML Protocol Sessionformat
, which is described in Specifying the Output Format for Configuration Data in a Junos XML Protocol Sessiongroups
, which is described in Specifying the Output Format for Configuration Groups and Interface Ranges Using the Junos XML Protocolinterface-ranges
, which is described in Specifying the Output Format for Configuration Groups and Interface Ranges Using the Junos XML Protocoljunos:key
, which is described in Requesting Identifier Indicators for Configuration Elements Using the Junos XML Protocol.
The application can also include the inherit
attribute after requesting an indicator for identifiers (as described
in Requesting Identifier Indicators for
Configuration Elements Using the Junos XML Protocol).
Displaying the Source Group for Inherited Configuration Group Elements
To request that the Junos XML protocol server indicate
the configuration group from which each configuration element is inherited,
a client application combines the inherit
attribute with the groups="groups"
attribute
in the <get-configuration>
tag. It encloses
the request in an <rpc>
tag element:
<rpc> <get-configuration inherit="(defaults | inherit)" groups="groups"/> <!-- OR --> <get-configuration inherit="(defaults | inherit)" groups="groups"> <!-- tag elements indicating the configuration elements to return --> </get-configuration> </rpc>
For information about the tag elements to enclose in the <get-configuration>
tag element, see Specifying the Scope of Configuration Data to Return
in a Junos XML Protocol Session.
When you include both the inherit
and groups="groups"
attributes in the
request, the Junos XML protocol server displays each configuration
group element within its inheriting element, and the inherited element
then includes information that indicates the source group. The format
for the output determines how the source group information is displayed
in the resulting configuration.
If the output is tagged with Junos XML tag elements (the format="xml"
attribute is included or the format
attribute is omitted), the Junos XML protocol
server includes the junos:group="source-group"
attribute in the opening tags of configuration elements
that are inherited from configuration groups. The response is enclosed
in <configuration>
and <rpc-reply>
tag elements.
<rpc-reply xmlns:junos="URL"> <configuration attributes> <!-- For each inherited element --> <!-- opening-tags-for-parents-of-the-element --> <inherited-element junos:group="source-group"> <inherited-child-of-inherited-element junos:group="source-group"> <!-- inherited-children-of-child junos:group="source-group" --> </inherited-child-of-inherited-element> </inherited-element> <!-- closing-tags-for-parents-of-the-element --> </configuration> </rpc-reply>
If the output is formatted ASCII text (the format="text"
attribute is included), the Junos XML
protocol server inserts three commented lines with the information
about the source group immediately above each inherited element. The
response is enclosed in <configuration-text>
and <rpc-reply>
tag elements.
<rpc-reply xmlns:junos="URL"> <configuration-text> */ For each inherited element */ /* parent levels for the element */ ## ## 'inherited-element' was inherited from group 'source-group' ## inherited-element { ## ## 'inherited-child' was inherited from group 'source-group' ## inherited-child { ... child statements of inherited-child ... } } /* closing braces for parent levels of the element */ </configuration-text> </rpc-reply>
If the output is in JSON format (the format="json"
attribute is included), the Junos XML protocol server includes the "junos:group" : "source-group"
attribute in the attribute list for the inherited element. 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 */ "inherited-child" : { "@" : { "junos:group" : "source-group" }, "inherited-object" : [ { "@" : { "junos:group" : "source-group" }, "name" : "identifier" } ], "@inherited-statement" : { "junos:group" : "source-group" } } /* closing braces for parent levels of the element */ } } </configuration-json> </rpc-reply>
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.
When the groups="groups"
attribute
is combined with the inherit="inherit"
attribute,
the XML output includes the same information as the output from the
following CLI configuration mode command. The output does not include
configuration elements inherited from the junos-defaults
group:
user@host# show | display inheritance | display xml groups
When the groups="groups"
attribute
is combined with the inherit="defaults"
attribute, the XML output includes the same information as the output
from the following CLI configuration mode command:
user@host# show | display inheritance defaults | display xml groups
The inherit
and groups
attributes can be combined with one or more
of the following other attributes in the <get-configuration/>
tag or opening <get-configuration>
tag:
changed
, which is described in Requesting Change Indicators for Configuration Elements Using the Junos XML Protocol.database
, which is described in Specifying the Source for Configuration Information Requests in a Junos XML Protocol Session.format
, which is described in Specifying the Output Format for Configuration Data in a Junos XML Protocol Session. The application can request either Junos XML-tagged, formatted ASCII, or JSON output.interface-ranges
, which is described in Specifying the Output Format for Configuration Groups and Interface Ranges Using the Junos XML Protocol.junos:key
, which is described in Requesting Identifier Indicators for Configuration Elements Using the Junos XML Protocol.
The application can also include the inherit
and groups
attributes after requesting
an indicator for identifiers (as described in Requesting Identifier Indicators for Configuration
Elements Using the Junos XML Protocol).
Displaying the Source Interface Range for Inherited Configuration Elements
To request that the Junos XML protocol server indicate
the interface range from which each configuration element is inherited,
a client application combines the inherit
attribute with the interface-ranges="interface-ranges"
attribute in the <get-configuration>
tag. It encloses the request in an <rpc>
tag element:
<rpc> <get-configuration inherit="inherit" interface-ranges="interface-ranges"/> <!-- OR --> <get-configuration inherit="inherit" interface-ranges="interface-ranges"> <!-- tag elements for the configuration elements to return --> </get-configuration> </rpc>
For information about the tag elements to enclose in the <get-configuration>
tag element, see Specifying the Scope of Configuration Data to Return
in a Junos XML Protocol Session.
When you include both the inherit
and interface-ranges="interface-ranges"
attributes in the request, the Junos XML protocol server displays
each interface range configuration element within its inheriting element,
and the inherited element then includes information that indicates
the source interface range. The format for the output determines how
the source interface range information is displayed in the resulting
configuration.
If the output is tagged with Junos XML tag elements (the format="xml"
attribute is included or the format
attribute is omitted), the Junos XML protocol
server includes the junos:interface-range="source-interface-range"
attribute in the
opening tags of configuration elements that are inherited from an
interface range. The response is enclosed in <configuration>
and <rpc-reply>
tag elements.
<rpc-reply xmlns:junos="URL"> <configuration attributes> <interfaces> <!-- For each inherited element --> <interface junos:interface-range="source-interface-range"> <inherited-element junos:interface-range="source-interface-range"> <inherited-child-of-inherited-element junos:interface-range="source-interface-range"> <!-- inherited-children-of-child junos:interface-range="source-interface-range" --> </inherited-child-of-inherited-element> </inherited-element> </interface> </interfaces> </configuration> </rpc-reply>
If the output is formatted ASCII text (the format="text"
attribute is included), the Junos XML
protocol server inserts three commented lines with the information
about the source interface range immediately above each inherited
element. The response is enclosed in <configuration-text>
and <rpc-reply>
tag elements.
<rpc-reply xmlns:junos="URL"> <configuration-text> interfaces { <!-- For each inherited element --> ## ## 'interface-name' was expanded from interface-range 'source-interface-range' ## interface-name { ## ## 'inherited-element' was expanded from interface-range 'source-interface-range' ## inherited-element { inherited-child { ... child statements of inherited-child ... } } } } </configuration-text> </rpc-reply>
If the output is in JSON format (the format="json"
attribute is included), the Junos XML protocol server includes
the "junos:interface-range" : "source-interface-range"
attribute in the attribute list for the inherited
element. 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 */ "inherited-child" : { "@" : { "junos:interface-range" : "source-interface-range" }, "inherited-object" : [ { "@" : { "junos:interface-range" : "source-interface-range" }, "name" : "identifier" } ], "@inherited-statement" : { "junos:interface-range" : "source-interface-range" } } /* closing braces for parent levels of the element */ } } </configuration-json> </rpc-reply>
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.
When the interface-ranges="interface-ranges"
attribute is combined with the inherit="inherit"
attribute, the XML output includes the same information as the output
from the following CLI configuration mode command:
user@host# show | display inheritance | display xml interface-ranges
The inherit
and interface-ranges
attributes can be combined with one
or more of the following other attributes in the <get-configuration/>
tag or opening <get-configuration>
tag:
changed
, which is described in Requesting Change Indicators for Configuration Elements Using the Junos XML Protocol.database
, which is described in Specifying the Source for Configuration Information Requests in a Junos XML Protocol Session.format
, which is described in Specifying the Output Format for Configuration Data in a Junos XML Protocol Session. The application can request Junos XML-tagged, formatted ASCII, or JSON output.groups
, which is described in Specifying the Output Format for Configuration Groups and Interface Ranges Using the Junos XML Protocol.junos:key
, which is described in Requesting Identifier Indicators for Configuration Elements Using the Junos XML Protocol.
The application can also include the inherit
and interface-ranges
attributes after
requesting an indicator for identifiers (as described in Requesting Identifier Indicators for Configuration
Elements Using the Junos XML Protocol).
Examples: Specifying Output Format for Configuration Groups
The following sample configuration hierarchy defines
a configuration group called interface-group
. The apply-groups
statement applies the statements in
the group at the [edit interfaces]
hierarchy level:
[edit] groups { interface-group { interfaces { so-1/1/1 { encapsulation ppp; } } } } apply-groups interface-group; interfaces { fxp0 { unit 0 { family inet { address 192.168.4.207/24; } } } }
When the inherit
attribute is not
included in the <get-configuration/>
tag, the output includes the <groups>
and <apply-groups>
tag elements as
separate items. The <groups>
tag element
encloses the tag elements defined in the interface-group
configuration group. The placement of the <apply-groups>
tag element directly above the <interfaces>
tag element indicates that the [edit interfaces]
hierarchy inherits the statements defined in the interface-group
configuration group.
When the inherit
attribute is included
in the <get-configuration/>
tag, the <interfaces>
tag element encloses the tag elements
defined in the interface-group
configuration group. The <groups>
and <apply-groups>
tag elements are not displayed.
When the groups="groups"
attribute
is combined with the inherit
attribute
in the <get-configuration/>
tag, the <interfaces>
tag element encloses the tag elements
defined in the interface-group
configuration group, which
are marked with the junos:group="interface-group"
attribute.
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.