Replace Elements in Configuration Data Using the Junos XML Protocol
In a Junos XML protocol session with a device running
Junos OS, to replace individual configuration elements (hierarchy
levels or configuration objects), a client application emits the <load-configuration>
tag element with the action="replace"
attribute in an <rpc>
tag element.
<rpc> <!-- For a file --> <load-configuration action="replace" url="file" [format="text"]/> <!-- For a data stream --> <load-configuration action="replace" [format="text"]> <!-- configuration data --> </load-configuration> </rpc>
Starting in Junos OS
Release 18.1R1, the ephemeral configuration database supports loading
configuration data using the <load-configuration>
action
attribute values of override
and replace
in
addition to the previously supported values of merge
and set
.
For more information about the url
and format
attributes, see Uploading and Formatting Configuration Data in a
Junos XML Protocol Session.
To use Junos XML tag elements to define the replacement,
the application includes the basic tag elements described in Creating, Modifying, or Deleting Configuration Elements
Using the Junos XML Protocol. Within the container tag,
it includes the same child tag elements as for a new element: each
of the replacement’s identifier tag elements (if it has them)
and all child tag elements being defined for the replacement element.
In the following, the identifier tag element is called <name>
. The application also includes the replace="replace"
attribute in the opening container tag:
<configuration> <!-- opening tag for each parent of the element --> <container-tag replace="replace"> <name>identifier</name> <!-- tag elements for other children, if any --> </container-tag> <!-- closing tag for each parent of the element --> </configuration>
To use formatted ASCII text to represent the element,
the application includes the complete statement path described in Creating, Modifying, or Deleting Configuration Elements
Using the Junos XML Protocol. As for a new element, it
includes each of the replacement’s identifiers (if it has them)
and all child statements (with values if appropriate) that it is defining
for the replacement. It places the replace:
statement above the element’s container statement.
<configuration-text> /* statements for parent levels of the element */ replace: element identifier { /* child statements if any */ } /* closing braces for parent levels of the element */ </configuration-text>
Junos OS does not support using the replace operation when loading JSON-formatted configuration data. To replace configuration elements when using JSON, you must delete the existing element and then add the replacement element.
The following example shows how to grant new permissions for
the object named operator
at the [edit system login class]
hierarchy level. The information is provided in Junos XML-tagged
format (the default).
The following example shows how to use formatted ASCII text to make the same change.
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.
<load-configuration>
action
attribute values of override
and replace
in
addition to the previously supported values of merge
and set
.