Define the Format of Configuration Data to Upload in a Junos XML Protocol Session
Junos XML protocol client applications can use the
<load-configuration> operation with the appropriate attribute
values to load configuration data in the requested format from a file or a data
stream.
A Junos XML protocol client application can load configuration data on a device running Junos OS or a device running Junos OS Evolved. The application can load the data from a file or as a data stream. The configuration data can use any of the following formats:
-
Junos XML elements (default)
-
Formatted ASCII text
-
Configuration mode commands
-
JavaScript Object Notation (JSON)
To specify the format of the data, a client application includes the
format attribute in the opening
<load-configuration> tag. The
<load-configuration> operation can combine the
format attribute with the following attributes:
-
url -
actionNote:JSON format only supports
actionvalues of merge, override, and update.
The following sections discuss how to load configuration data from a file or as a data stream using the requested format in a Junos XML protocol session.
Junos XML Elements
When providing Junos XML data, the application includes the elements representing
all levels of the configuration hierarchy from the root (the
<configuration> element) down to each new or changed
element.
<configuration>
<!-- elements representing the configuration data -->
</configuration> In the request, the application can include the format="xml"
attribute or omit the format attribute in the
<load-configuration> tag, since this is the default.
To load the configuration data from a file, the application also includes the
url attribute. To load the configuration data as a data
stream, the application sends the data in the request.
<rpc>
<load-configuration url="file-location"/>
</rpc>
<rpc>
<load-configuration>
<configuration>
<!-- elements representing the configuration data -->
</configuration>
</load-configuration>
</rpc>Formatted ASCII Text
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. This notation uses 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 providing configuration data as ASCII text, the application must include the
format="text" attribute in the
<load-configuration> tag. To load the configuration
data from a file, the application also includes the url
attribute. To load the configuration data as a data stream, the application
encloses the data in a <configuration-text> element.
<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>Configuration Mode Commands
A client application can load configuration data as configuration mode commands.
The device 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 providing configuration mode commands, the application must include the
action="set" and format="text" attributes
in the <load-configuration> tag. To load the
configuration data from a file, the application also includes the
url attribute. To load the configuration data as a data
stream, the application encloses the commands in a
<configuration-set> element.
<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>JSON
A client application can load JSON configuration data onto a device. The application includes the configuration data representing all levels of the configuration hierarchy from the root configuration object down to each new or changed element.
When providing JSON configuration data, the application must include the
format="json" attribute in the
<load-configuration> tag. To load the configuration
data from a file, the application also includes the url
attribute. To load the configuration data as a data stream, the application
encloses the data in a <configuration-json> element.
<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>