Define the Format of Configuration Data to Upload in a Junos XML Protocol Session
In a Junos XML protocol session with a device running Junos OS, a client application can upload configuration data to the device either in a file or as a data stream emitted during the Junos XML protocol session. In both cases, the client application can use Junos XML tag elements, formatted ASCII text, Junos OS configuration mode commands, or JavaScript Object Notation (JSON) to define the new configuration data.
If the application uses Junos XML tag elements, it includes
the tag elements representing all levels of the configuration hierarchy
from the root (the <configuration>
tag
element) down to each new or changed element. The notation is the
same as that used to request configuration information, and is described
in detail in Requesting Configuration
Changes Using the Junos XML Protocol.
<configuration> <!-- tag elements representing the configuration data --> </configuration>
If the application provides the configuration data as formatted
ASCII text, it uses the standard Junos OS CLI notation to indicate
the hierarchical relationships between configuration statements—the
newline character, tabs and other white space, braces, and square
brackets. For each new or changed element, the complete statement
path is specified, starting with the top-level statement that appears
directly under the [edit]
hierarchy level.
When ASCII text is provided as a data stream, it is enclosed
in the <configuration-text>
tag element.
<configuration-text> /* formatted ASCII configuration statements */ </configuration-text>
When ASCII text is provided in a file, the <configuration-text>
tag element is not included in the file.
When providing configuration data as ASCII text, the
application must also include the format="text"
attribute in the <load-configuration>
tag.
<rpc> <load-configuration url="file-location" format="text"/> </rpc> <rpc> <load-configuration format="text"> <configuration-text> /* formatted ASCII configuration data */ </configuration-text> </load-configuration> </rpc>
Starting in Junos OS Release 11.4, you can load configuration
data as configuration mode set
commands. When you provide
configuration data as configuration mode set
commands,
Junos OS executes the configuration instructions line by line. For
each element, you can specify the complete statement path in the command,
or you can use navigation commands, such as edit
and up
, to move around the configuration hierarchy as you would
in CLI configuration mode.
When configuration mode set
commands are provided
as a data stream, the commands are enclosed in the <configuration-set>
tag element.
<configuration-set> /* configuration mode commands */ </configuration-set>
When configuration mode set
commands are provided
in a file, the <configuration-set>
tag
element is not included in the file.
When providing configuration data as Junos OS configuration
mode commands, the application must also include the action="set"
and format="text"
attributes in the <load-configuration>
tag.
<rpc> <load-configuration url="file-location" action="set" format="text"/> </rpc> <rpc> <load-configuration action="set" format="text"> <configuration-set> /* configuration mode commands to load */ </configuration-set> </load-configuration> </rpc>
Starting in Junos OS Release 16.1, you can load configuration data formatted using JavaScript Object Notation (JSON) on the device. If the application provides configuration data in JSON format, it includes the configuration data representing all levels of the configuration hierarchy from the root down to each new or changed element.
When configuration data in JSON format is provided as
a data stream, the data is enclosed in the <configuration-json>
tag element.
<configuration-json> /* JSON-formatted configuration data */ </configuration-json>
When configuration data in JSON format is provided in a file,
the <configuration-json>
tag element
is not included in the file.
When providing configuration data in JSON format, the
application must also include the format="json"
attribute in the <load-configuration>
tag.
<rpc> <load-configuration url="file-location" format="json"/> </rpc> <rpc> <load-configuration format="json"> <configuration-json> /* JSON-formatted configuration data */ </configuration-json> </load-configuration> </rpc>
The format
attribute can be
combined with one or more of the following attributes:
url
action
Note:JSON format is only supported for
action
values of merge, override, and update.
For reference pages for the <configuration>
, <configuration-text>
, <configuration-set>
, and <configuration-json>
tag elements, see the Junos XML API Operational Developer Reference.