Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Uploading and Formatting Configuration Data in a NETCONF Session

In a NETCONF session with a device running Junos OS, a client application can use a text file or streaming data to deliver configuration data to the candidate configuration. The data delivered can be in one of two formats: Junos XML or CLI configuration statements. You can specify the delivery mechanism and the format used when delivering configuration changes to the device.

When formatting your configuration data output, you can choose to stream your configuration changes within your 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.

You can format the configuration data using one of two formats: Junos XML or CLI configuration statements. The choice between one data format over the other is personal preference.

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

Referencing Configuration Data Files

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

<rpc>
    <copy-config>
        <target>
            <candidate/>
        </target>
        <source>
            <url>
                <!-- location and name of file containing configuration data -->
            </url>
        </source>

    </copy-config>
</rpc>
]]>]]>
<rpc>
    <edit-config>
        <target>
            <candidate/>
        </target>
        <url>
            <!-- location and name of file containing configuration data -->
        </url>

    </edit-config>
</rpc>
]]>]]>

The data within these files can be formatted as either Junos XML or CLI configuration statements. When the configuration data is formatted as CLI configuration statements, you set the <url> format attribute to text.

<url format=”text”>
    <!-- location and name of file containing configuration data -->
</url>

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:
      ftp://username:password@hostname/path/filename

      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:
      http://username:password@hostname/path/filename

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 configuration statements, see Mapping 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 configuration elements and Junos XML tag elements, see Mapping Configuration Statements to Junos XML Tag Elements. The CLI configuration statement notation are further described in the CLI User Guide.

<rpc>
    <edit-config>
        <target>
            <candidate/>
        </target>
        <config> or <config-text>
            <configuration> or <configuration-text>
                <!-- configuration changes -->
            </configuration> or </configuration-text>
        </config> or </config-text>
    </edit-config>
</rpc>
]]>]]>

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

Formatting Data: Junos XML versus CLI Configuration Statements

You can format the configuration data using one of two formats: Junos XML or CLI configuration statements. The choice between one data format over the other is personal preference.

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 are written in Junos XML. Thus, the following code declares that the data within the file is Junos XML:

<url>dataFile</url>

To specify that the data file be written as CLI configuration statements, you set the <url> tag's format attribute to text:

<url format=”text”>dataFile</url>

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

In the following example, Junos XML formatted configuration data is included between the <configuration> tag:

<config>
  <configuration>
    <system>
      <services>
        <ssh>
           <protocol-version>v2</protocol-version>
        </ssh>
      </services>
    </system>
  <configuration>
</config>

In this next example, the same data is formatted as CLI configuration statements and included within <configuration-text> tags:

<config-text>
  <configuration-text>
    system {
      services {
        ssh {
           protocol-version v2 ;
        }
      }
    }
  </configuration-text>
</config-text>

Published: 2013-07-26

Published: 2013-07-26