Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Upload and Format Configuration Data in a NETCONF Session

In a NETCONF session with a device running Junos OS, a client application can specify the delivery mechanism and the format of the configuration data used when delivering configuration changes to the device. Client applications can use a text file or streaming data to upload configuration data in one of the accepted formats to the candidate configuration or open configuration database.

A client can choose to stream configuration changes within the session or reference data files that include the desired configuration changes. Each method has advantages and disadvantages. Streaming data allows you to send your configuration change data in line, using your NETCONF connection. This is useful when the device is behind a firewall and you cannot establish another connection to upload a data file. With text files you can keep the edit configuration commands simple; with data files, there is no need to include the possibly complex configuration data stream.

The <copy-config> and <edit-config> operations accept one of two formats for the Junos OS configuration data: Junos XML or CLI configuration statements. The choice between one data format over the other is personal preference.

Note:

When managing devices running Junos OS, a client application can use the Junos XML protocol <load-configuration> operation in a NETCONF session to upload configuration data formatted using JSON or configuration mode set commands, in addition to Junos XML or CLI configuration statement formats.

The delivery mechanism and the format are discussed in detail in the following sections:

Referencing Configuration Data Files

To upload configuration data stored in a file, a client application emits the file location between the <url> tags within the <rpc> and the <edit-config> or <copy-config> tag elements.

The data within these files can be formatted as either Junos XML elements or CLI configuration statements. When the configuration data is formatted as CLI configuration statements, include the format="text" attribute in the <url> tag.

The configuration file can be placed locally or as a network resource.

  • When placed locally, the configuration file path can be relative or absolute:

    • Relative file path—The file location is based on the user’s home directory.

    • Absolute file path—The file location is based on the directory structure of the device, for example <drive>:filename or <drive>/:path/filename, If you are using removable media, the drive can be in the MS-DOS or UNIX (UFS) format.

  • When located on the network, the configuration file can be accessed using FTP or HTTP:

    • FTP example:

      Note:

      The default value for the FTP path variable is the user’s home directory. Thus, by default the file path to the configuration file is relative to the user directory. To specify an absolute path when using FTP, start the path with the characters %2F; for example: ftp://username:password@hostname/%2Fpath/filename.

    • HTTP example:

Before loading the file, the client application or an administrator saves Junos XML tag elements or CLI configuration statements as the contents of the file. The file includes the tag elements or configuration statements representing all levels of the configuration hierarchy from the root (represented by the <configuration> tag element) down to each element to change. The notation is the same as that used to request configuration information. For more detailed information about the Junos XML representation of Junos OS configuration statements, see Map Configuration Statements to Junos XML Tag Elements.

The following example shows how to incorporate configuration data stored in the file /var/tmp/configFile on the FTP server called ftp.myco.com:

Streaming Configuration Data

To provide configuration data as a data stream, a client application emits the <config> or <config-text> tag elements within the <rpc> and <edit-config> tag elements. To specify the configuration elements to change, the application emits Junos XML or CLI configuration statements representing all levels of the configuration hierarchy from the root (represented by the <configuration> or <configuration-text> tag element) down to each element to change. The Junos XML notation is the same as that used to request configuration information.

For more detailed information about the mappings between Junos OS configuration elements and Junos XML tag elements, see Map Configuration Statements to Junos XML Tag Elements. The CLI configuration statement notation is further described in the CLI User Guide.

The following example shows how to provide Junos XML configuration data in a data stream to configure the messages system log file:

Formatting Data: Junos XML versus CLI Configuration Statements

The NETCONF <copy-config> and <edit-config> operations accept one of two formats for Junos OS configuration data: Junos XML or CLI configuration statements. The choice between one data format over the other is personal preference.

Note:

When managing devices running Junos OS, a client application can use the Junos XML protocol <load-configuration> operation in a NETCONF session to upload configuration data formatted using JSON or configuration mode set commands, in addition to Junos XML or CLI configuration statement formats.

If you are supplying the configuration changes in the form of data files, you enclose the data filename and path within <url> tags. By default, these tags specify that the referenced data files contain Junos XML-formatted configuration data. Thus, the following code declares that the data within the file is Junos XML elements:

To specify that the data file contains CLI configuration statements, , include the format="text" attribute in the <url> tag.

When streaming data, you specify the data format by selecting one of two tags: <config> for Junos XML elements and <config-text> for CLI configuration statements.

In the following example, the <configuration> element encloses Junos XML-formatted configuration data:

In the following example, the <configuration-text> element encloses the same data formatted as CLI configuration statements: