Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Merge Elements in Configuration Data Using the Junos XML Protocol

By default, the Junos XML protocol server merges loaded configuration data into the candidate configuration according to the following rules. (The rules also apply to a private copy of the configuration or an open instance of the ephemeral configuration database, but for simplicity the following discussion refers to the candidate configuration only.)

  • A configuration element (hierarchy level or configuration object) that exists in the candidate but not in the loaded configuration remains unchanged.

  • A configuration element that exists in the loaded configuration but not in the candidate is added to the candidate.

  • If a configuration element exists in both configurations, the semantics are as follows:

    • If a child statement of the configuration element (represented by a child tag element) exists in the candidate but not in the loaded configuration, it remains unchanged.

    • If a child statement exists in the loaded configuration but not in the candidate, it is added to the candidate.

    • If a child statement exists in both configurations, the value in the loaded configuration replaces the value in the candidate.

Merge mode is the default mode for new configuration elements, so the application simply emits the <load-configuration> tag element in an <rpc> tag element:

For more information about the url and format attributes, see Uploading and Formatting Configuration Data in a Junos XML Protocol Session.

To explicitly specify merge mode for configuration data that uses Junos XML elements, formatted ASCII text, or JSON format, the application can include the action="merge" attribute in the <load-configuration> tag, as shown in the examples at the end of this section.

When using Junos XML tag elements to represent the element to merge into the configuration, the application includes the basic tag elements described in Creating, Modifying, or Deleting Configuration Elements Using the Junos XML Protocol. It does not include any attributes in the element’s container tag. If adding or changing the value of a child element, the application includes the tag elements for it. If a child remains unchanged, it does not need to be included in the loaded configuration. In the following, the identifier tag element is called <name>:

When using formatted ASCII text, the application includes the statement path described in Creating, Modifying, or Deleting Configuration Elements Using the Junos XML Protocol. It does not include a preceding operator, but does include the element’s identifier if it has one. If adding or changing the value of a child element, the application includes the tag elements for it. If a child remains unchanged, it does not need to be included in the loaded configuration.

Starting in Junos OS Release 16.1, you can load configuration data formatted using JavaScript Object Notation (JSON) on the device. When using JSON to represent the elements to merge into the configuration, the application includes the basic JSON data described in Creating, Modifying, or Deleting Configuration Elements Using the Junos XML Protocol. It does not need to include any specific operation attributes in the JSON configuration data in order to merge the new or changed element. If adding or changing the value of a child element, the application includes the JSON data or child objects for it. If a child remains unchanged, it does not need to be included in the loaded configuration. In the following example, the JSON member that specifies the element’s identifier has the field name "name":

When using configuration mode commands to merge new elements, the application includes the action="set" and format="text" attributes in the <load-configuration> tag, as shown in the examples at the end of this section. The application includes the set command, the statement path to the element, and the element’s identifier if it has one. If adding or changing the value of a child element, the application includes the child elements or statements in the command. If a child remains unchanged, it does not need to be included.

The following example shows how to merge in a new interface called so-3/0/0 at the [edit interfaces] hierarchy level in the configuration. The information is provided as Junos XML tag elements (the default).

The following example shows how to use formatted ASCII text to define the same new interface.

The following example shows how to use JSON configuration data to define the same interface.

The following example shows how to use configuration mode commands to define the same interface.