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. To merge new configuration data with the existing configuration, the application emits the <load-configuration> operation in an <rpc> element.

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 later examples.

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

The following sections outline how to merge configuration items into the existing configuration using the different formats:

Junos XML

To use Junos XML to merge the element into the configuration, the application first includes the basic tag elements described in Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol. The application does not include any attributes in the element’s container tag. To add or change the value of a child element, the application includes the elements for it. If a child remains unchanged, the loaded configuration does not need to include it. In the following example, the identifier tag is <name>:

The following example uses Junos XML elements (the default) to merge configuration data for interface ge-0/0/1 at the [edit interfaces] hierarchy level.

Formatted ASCII Text

To use formatted ASCII text to merge statements, the application first includes the statement path described in Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol. The application does not include a preceding operator, but it does include the element’s identifier if it has one. To add or change the value of a child element, the application includes the elements for it. If a child remains unchanged, the loaded configuration does not need to include it. To provide the configuration data as a data stream, enclose the data in a <configuration-text> element.

The following example uses formatted ASCII text to merge the configuration data for interface ge-0/0/1.

Configuration Mode Commands

To use configuration mode commands to merge new elements, an application includes the set command, the statement path to the element, and the element’s identifier if it has one. To add or change the value of a child element, the application includes the child elements or statements in the command. If a child remains unchanged, the configuration mode commands do not need to include it. To provide the configuration data as a data stream, enclose the commands in a <configuration-set> element.

To load configuration mode commands, the application includes the action="set" and format="text" attributes in the <load-configuration> tag. The following example uses configuration mode commands to define the ge-0/0/1 interface.

JSON

To use JSON data to merge elements into the configuration, an application first includes the basic JSON data described in Create, Modify, or Delete Configuration Elements Using the Junos XML Protocol. The application does not need to include any specific operation attributes in the JSON configuration data in order to merge the new or changed element. To add or change the value of a child element, the application includes the JSON data or child objects for it. If a child remains unchanged, the loaded configuration does not need to include it. To provide the configuration data as a data stream, enclose the data in a <configuration-json> element.

In the following example, the JSON member that specifies the element’s identifier has the field name "name":

The following example uses JSON configuration data to define the ge-0/0/1 interface.