Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

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:

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.

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.

When the client includes the inherit="defaults" attribute, the output includes the same information as the output from the following CLI configuration mode command:

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.

The inherit attribute can be combined with one or more of the following attributes in the <get-configuration/> tag or opening <get-configuration> tag:

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:

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.

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.

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.

Note:

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:

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:

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:

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:

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.

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.

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.

Note:

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:

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:

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:

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.

Release History Table
Release
Description
16.1
Starting in Junos OS Release 16.1, devices running Junos OS emit JSON-formatted configuration data using a new default implementation for serialization.