Request Commit-Script-Style XML Configuration Data Using the Junos XML Protocol
A Junos XML protocol client application can use the
<get-configuration> operation with the
commit-scripts attribute to view the configuration in
commit-script-style XML.
When you perform a commit operation, each active commit script receives and inspects
the post-inheritance candidate configuration in Extensible Markup Language (XML)
format. The post-inheritance candidate configuration displays the elements inherited
from user-defined groups or interface ranges within the inheriting elements.
However, when you view the configuration in the Junos OS CLI using the show
configuration | display xml command, the device displays the
pre-inheritance candidate configuration. In the CLI, you can include additional
filters to view the post-inheritance configuration that would be input to a commit
script. Additionally, you can view the configuration with commit script changes
applied.
Similarly, when a Junos XML protocol client application uses the
<get-configuration> operation, the server returns the
pre-inheritance candidate configuration by default. A client application can also
request the configuration as commit-script-style XML data by including the
commit-scripts
attribute.
The value of the attribute determines which view the server returns. Table 1 outlines the attribute values, the equivalent CLI command, and a description of
the returned data.
commit-scripts Attribute Value |
CLI Command | Description |
|---|---|---|
|
|
|
View the post-inheritance configuration that would be input to a commit script. |
|
|
|
View the configuration with commit script changes applied, including both non-transient and transient changes. |
|
|
|
View the configuration with commit script changes applied, but include only non-transient changes and exclude transient changes. |
The following sections detail how a Junos XML protocol client application requests the configuration in commit-script style XML.
- Display the Configuration As Commit Script Input
- Display the Configuration with Commit Script Changes Applies
- Combine the
commit-scriptsAttribute with Other Attributes
Display the Configuration As Commit Script Input
A Junos XML protocol client application can request the configuration as commit-script-style XML
data. To return the post-inheritance configuration that would be input to a commit
script, a client application emits the <rpc> and
<get-configuration> elements and includes the
commit-scripts="view" attribute.
<rpc>
<get-configuration commit-scripts="view"/>
<!-- OR -->
<get-configuration commit-scripts="view">
<!-- tag elements for the configuration elements to return -->
</get-configuration>
</rpc>Display the Configuration with Commit Script Changes Applies
In the Junos OS CLI, you can view the configuration with commit script changes
applied to verify that the active commit scripts apply your expected changes.
Similarly, a Junos XML protocol client can use the
<get-configuration> operation to request the
configuration with commit script changes applied.
To view the configuration with both non-transient and transient commit script
changes applied, a client application includes the
commit-scripts="apply" attribute in the
<get-configuration> tag.
<rpc>
<get-configuration commit-scripts="apply"/>
<!-- OR -->
<get-configuration commit-scripts="apply">
<!-- tag elements for the configuration elements to return -->
</get-configuration>
</rpc>To view the configuration with only non-transient commit script changes applied,
excluding transient changes, a client application includes the
commit-scripts="apply-no-transients" attribute in the
<get-configuration> tag.
<rpc>
<get-configuration commit-scripts="apply-no-transients"/>
<!-- OR -->
<get-configuration commit-scripts="apply-no-transients">
<!-- tag elements for the configuration elements to return -->
</get-configuration>
</rpc>Combine the commit-scripts Attribute with Other Attributes
You can combine the commit-scripts attribute with one or more of
the following attributes in the <get-configuration>
tag:
-
changed -
database -
format -
groups -
inherit -
interface-ranges -
junos:key
You do not need to include the changed, groups,
or inherit attributes with the
commit-scripts="view" attribute. The commit-scripts-style
XML view includes the junos:changed="changed" attribute in the
XML tags, and it displays the output with inheritance applied. Thus, it displays
the tag elements inherited from user-defined groups or interface ranges within
the inheriting tag elements, and the XML tags already include the
junos:group attribute. To explicitly display the
junos:interface-range attribute in the commit-scripts-style
view, you must include the interface-ranges="interface-ranges"
attribute in the <get-configuration> tag.
When a client application includes the commit-scripts="apply" or
commit-scripts="apply-no-transients" attribute, it can
request the output as formatted ASCII text, configuration mode commands, or
JSON. To specify the format, a client application includes the
format attribute and sets it to the required format.