Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Upload Configuration Data as a File Using the Junos XML Protocol

Junos XML protocol client applications can use the <load-configuration> operation to load configuration data onto a Junos device from a local or remote file.

A Junos XML protocol client application can load configuration data from a file onto a device running Junos OS or a device running Junos OS Evolved. The file can be a local file on the Junos device or a remote file on an FTP or HTTP server. After loading the configuration data, the client must commit the configuration to make it active.

Before loading the file, an administrator saves the configuration data as the contents of the file. The configuration data can be Junos XML elements, formatted ASCII text, Junos OS configuration mode commands, or JavaScript Object Notation (JSON). For more information, see Define the Format of Configuration Data to Upload in a Junos XML Protocol Session.

Note:

When you load configuration data from a file, you do not need to enclose data formatted as ASCII text, configuration mode commands, or JSON in <configuration-text>, <configuration-set>, or <configuration-json> elements as you do for a data stream.

To load the configuration data from a local or remote file, the Junos XML protocol client application emits the <rpc> element and encloses the <load-configuration/> operation with the url attribute. The format and action attributes specify the format of the data and how to load the data into the target configuration database.

The value of the url attribute can be a local file path, an FTP location, or an HTTP URL.

  • A local file can have one of the following forms:

    • /path/filename —File on a mounted file system, either on the local flash drive or on hard disk.

    • a:filename or a:path/filename —File on the local drive. The default path is / (the root-level directory). The removable media can be in MS-DOS or UNIX (UFS) format.

  • A file on an FTP server has the following form:

  • A file on an HTTP server has the following form:

In each case, the default value for the path variable is the user's home directory. To specify an absolute path, start the path with the characters %2F; for example, ftp://username:password@hostname/%2Fpath/filename .

You can combine the url attribute with one or more of the following attributes in the <load-configuration/> tag:

  • format

  • action

The request must include the format attribute to specify the format of the data in the file unless the data format is Junos XML elements, which is the default. You can also include the action attribute to specify how to load the new data into the existing configuration. Table 1 outlines the data format and corresponding attributes.

Table 1: load-configuration format and action Attributes
Data Format format Attribute action Attribute

ASCII text

format="text"

action="(merge | override | replace | update)"

Configuration mode commands

format="text"

action="set"

JSON

format="json"

action="(merge | override | update)"

Junos XML elements (default)

format="xml"

action="(merge | override | replace | update)"

For example, if the data is Junos XML tag elements, include the format="xml" attribute or omit the format attribute, which defaults to XML.

If the data is formatted ASCII text, include the format="text" attribute.

If the data comprises configuration mode commands, include the action="set" and format="text" attributes.

If the data uses JSON format, include the format="json" attribute.

The following example loads Junos XML-tagged configuration data stored in the file /var/configs/user-accounts from the FTP server cfg-server.mycompany.com. The opening <load-configuration> tag appears on two lines for legibility only.

The Junos XML Protocol server response is: