- play_arrow Overview
- play_arrow Junos XML Management Protocol and Junos XML API Overview
- play_arrow Junos XML Protocol and Junos XML Tags Overview
- XML and Junos OS Overview
- XML Overview
- XML and Junos XML Management Protocol Conventions Overview
- Map Junos OS Commands and Command Output to Junos XML Tag Elements
- Map Configuration Statements to Junos XML Tag Elements
- Using Configuration Response Tag Elements in Junos XML Protocol Requests and Configuration Changes
- play_arrow Junos XML Protocol and JSON Overview
-
- play_arrow Manage Junos XML Protocol Sessions
- play_arrow Junos XML Protocol Session Overview
- play_arrow Manage Junos XML Protocol Sessions
- Satisfy the Prerequisites for Establishing a Connection to the Junos XML Protocol Server
- Configure clear-text or SSL Service for Junos XML Protocol Client Applications
- Connect to the Junos XML Protocol Server
- Start a Junos XML Protocol Session
- Authenticate with the Junos XML Protocol Server for Cleartext or SSL Connections
- Send Requests to the Junos XML Protocol Server
- Parse the Junos XML Protocol Server Response
- Parse Response Tag Elements Using a Standard API in NETCONF and Junos XML Protocol Sessions
- How Character Encoding Works on Juniper Networks Devices
- Handle an Error or Warning in Junos XML Protocol Sessions
- Halt a Request in Junos XML Protocol Sessions
- Lock, Unlock, or Create a Private Copy of the Candidate Configuration Using the Junos XML Protocol
- Terminate a Junos XML Protocol Session
- End a Junos XML Protocol Session and Close the Connection
- Sample Junos XML Protocol Session
- play_arrow Junos XML Protocol Tracing Operations
- play_arrow Junos XML Protocol Operations
- play_arrow Junos XML Protocol Processing Instructions
- play_arrow Junos XML Protocol Response Tags
- play_arrow Junos XML Element Attributes
- active
- count
- delete
- inactive
- insert
- junos:changed
- junos:changed-localtime
- junos:changed-seconds
- junos:commit-localtime
- junos:commit-seconds
- junos:commit-user
- junos:group
- junos:interface-range
- junos:key
- junos:position
- junos:total
- matching
- protect
- recurse
- rename
- replace
- replace-pattern
- start
- unprotect
- xmlns
-
- play_arrow Request Operational and Configuration Information Using the Junos XML Protocol
- play_arrow Request Operational Information Using the Junos XML Protocol
- play_arrow Request Configuration Information Using the Junos XML Protocol
- Request Configuration Data Using the Junos XML Protocol
- Specify the Source for Configuration Information Requests in a Junos XML Protocol Session
- Specify the Output Format for Configuration Data in a Junos XML Protocol Session
- Request Commit-Script-Style XML Configuration Data Using the Junos XML Protocol
- Specify the Output Format for Configuration Groups and Interface Ranges Using the Junos XML Protocol
- Request Identifier Indicators for Configuration Elements Using the Junos XML Protocol
- Request Change Indicators for Configuration Elements Using the Junos XML Protocol
- Specify the Scope of Configuration Data to Return in a Junos XML Protocol Session
- Request the Complete Configuration Using the Junos XML Protocol
- Request a Configuration Hierarchy Level or Container Object Without an Identifier Using the Junos XML Protocol
- Request All Configuration Objects of a Specific Type Using the Junos XML Protocol
- Request a Specific Number of Configuration Objects Using the Junos XML Protocol
- Request Identifiers for Configuration Objects of a Specific Type Using the Junos XML Protocol
- Request a Single Configuration Object Using the Junos XML Protocol
- Request Subsets of Configuration Objects Using Regular Expressions
- Request Multiple Configuration Elements Using the Junos XML Protocol
- Retrieve a Previous (Rollback) Configuration Using the Junos XML Protocol
- Retrieve the Rescue Configuration Using the Junos XML Protocol
- Compare the Active or Candidate Configuration to a Prior Version Using the Junos XML Protocol
- Compare Two Previous (Rollback) Configurations Using the Junos XML Protocol
- Request an XML Schema for the Configuration Hierarchy Using the Junos XML Protocol
-
- play_arrow Junos XML Protocol Utilities
- play_arrow Develop Junos XML Protocol C Client Applications
-
- play_arrow Configuration Statements and Operational Commands
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:
<rpc> <!-- For a file --> <load-configuration url="file" [format="format"]/> <!-- For a data stream --> <load-configuration [format="format"]> <!-- configuration data --> </load-configuration> </rpc>
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>
:
<configuration> <!-- opening tag for each parent of the element --> <container-tag> <name>identifier</name> <!-- if the element has an identifier --> <!-- tag elements for other children, if any --> </container-tag> <!-- closing tag for each parent of the element --> </configuration>
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.
<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>
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":
<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>
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.
<configuration-set> set statement-path-to-element element identifier child-statements </configuration-set>
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.
<rpc> <load-configuration format="json"> <configuration-json> { "configuration" : { "interfaces" : { "interface" : [ { "name" : "so-3/0/0", "unit" : [ { "name" : 0, "family" : { "inet" : { "address" : [ { "name" : "10.0.0.1/8" } ] } } } ] } ] } } } </configuration-json> </load-configuration> </rpc> <rpc-reply xmlns:junos="http://xml.juniper.net/junos/16.2R2/junos"> <load-configuration-results> <load-success/> </load-configuration-results> </rpc-reply>
The following example shows how to use configuration mode commands to define the same interface.
