Upload Configuration Data as a File Using the Junos XML Protocol
In a Junos XML protocol session with a device running Junos
OS, to upload configuration data stored in a file, a client application
encloses the <load-configuration/>
tag
with the url
attribute in an <rpc>
tag element.
If the data is Junos XML tag elements, either include
the format="xml"
attribute or omit the format
attribute, which defaults to XML.
<rpc> <load-configuration url="file-location"/> </rpc>
If the data is formatted ASCII text, include the format="text"
attribute.
<rpc> <load-configuration url="file-location" format="text"/> </rpc>
If the data is configuration mode set
commands,
include the action="set"
and format="text"
attributes.
<rpc> <load-configuration url="file-location" action="set" format="text"/> </rpc>
Starting in Junos
OS Release 16.1, you can load configuration data formatted using JavaScript
Object Notation (JSON) on devices running Junos OS. If the data uses JSON format, include the format="json"
attribute.
<rpc> <load-configuration url="file-location" format="json"/> </rpc>
Before loading the file, the client application or an administrator
saves the configuration data as the contents of the file. Enclose
Junos XML tag elements in a <configuration>
tag element. For information about the syntax for the data in the
file, see Defining the Format of Configuration
Data to Upload in a Junos XML Protocol Session.
Configuration data formatted as ASCII text, Junos OS configuration
mode commands, or JSON data is not enclosed in <configuration-text>
, <configuration-set>
, or <configuration-json>
tag elements when it is loaded
from a file.
The value of the url
attribute
can be a local file path, an FTP location, or a Hypertext Transfer
Protocol (HTTP) URL:
A local filename can have one of the following forms:
/path/filename—File on a mounted file system, either on the local flash disk 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 filename on an FTP server has the following form:
ftp://username:password@hostname/path/filename
A filename on an HTTP server has the following form:
http://username:password@hostname/path/filename
In each case, the default value for the path variable is the home directory for the username. To specify an absolute
path, the application starts the path with the characters %2F; for
example, ftp://username:password@hostname/%2Fpath/filename
.
The url
attribute can be combined
with one or more of the following attributes in the <load-configuration/>
tag:
format
action
The following example shows how to incorporate Junos XML-tagged
configuration data stored in the file /var/configs/user-accounts on the FTP server called cfg-server.mycompany.com. The opening <load-configuration>
tag appears on two lines for
legibility only.
Change History Table
Feature support is determined by the platform and release you are using. Use Feature Explorer to determine if a feature is supported on your platform.