Replace Only Updated Elements in Configuration Data Using the Junos XML Protocol
A Junos XML protocol client application can use the
<load-configuration> operation with the update
action to load a complete configuration but replace only the updated configuration
elements.
A Junos XML protocol client application can load a complete configuration but replace
just the updated configuration elements (hierarchy levels and configuration objects)
on devices running Junos or devices running Junos OS Evolved. To replace
configuration elements only if the elements differ between the loaded configuration
and the existing configuration, the application emits the <rpc>
element and encloses the <load-configuration> operation with
the action="update" attribute.
<rpc>
<!-- For a file -->
<load-configuration action="update" url="file" [format="format"]/>
<!-- For a data stream -->
<load-configuration action="update" [format="format"]>
<!-- configuration data -->
</load-configuration>
</rpc>For more information about the url and format
attributes, see Upload and Format Configuration Data in a Junos XML Protocol Session.
Starting in Junos OS Release 21.1R1, the ephemeral configuration database
supports the action="update" attribute on supported
platforms.
The action="update" operation is equivalent to the load
update configuration mode command in the Junos OS CLI. When you use a
load update operation, you provide a complete configuration, and the device compares
the two configurations. Each configuration element that is different in the loaded
configuration replaces its corresponding element in the existing configuration.
Elements that are the same in both configurations remain unchanged. When you commit
the configuration, only system processes that are affected by the changed
configuration elements parse the new configuration.
To define the replacement elements, the application uses the same syntax as for new elements. For more information, see Create New Elements in Configuration Data Using the Junos XML Protocol. The following sections outline how to update the configuration using the specified format.
Junos XML
To use Junos XML elements to represent the replacement elements, an application
includes each of the element’s identifier tags (if it has them) and all child
tag elements that it is defining for the element. In the following Junos XML
example, the object's identifier is called name.
<configuration>
<!-- opening tag for each parent of the element -->
<container-tag>
<name>identifier</name>
<!-- tag elements for other children, if any -->
</container-tag>
<!-- closing tag for each parent of the element -->
</configuration>The following example updates the candidate configuration with the contents of the
local file /tmp/conf.xml. The file contains a complete
configuration represented as Junos XML elements (the default), so the request omits
the format attribute.
<rpc>
<load-configuration action="update" url="/tmp/conf.xml"/>
</rpc>Formatted ASCII Text
To use formatted ASCII text to represent the data, an application includes each
of the element’s identifiers (if it has them) and all child statements (with
values if appropriate) that it is defining for the element. To provide the
configuration data as a data stream, enclose the data in a
<configuration-text> element.
<configuration-text>
/* statements for parent levels of the element */
element identifier {
/* child statements if any */
}
/* closing braces for parent levels of the element */
</configuration-text>
JSON
To use Junos XML elements to represent the replacement objects, an application
includes the object’s identifiers (if it has them) and all data and child
objects that it is defining for the object. To provide the configuration data as
a data stream, enclose the data in a <configuration-json>
element.
<configuration-json>
{
"configuration" : {
/* JSON objects for parent levels of the element */
"container-tag" : {
"object" : [
{
"name" : "identifier",
"statement-name" : "statement-value", # if any
/* additional data and child objects */ # if any
}
],
/* data and child objects */ # if any
}
/* closing braces for parent levels of the element */
}
}
</configuration-json>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.
action="update" attribute on supported
platforms.