Specifying the Source and Format of New Configuration Data

A client application can provide new configuration data either in a file or as a data stream, and as either Junos XML tag elements or formatted ASCII text. See the following sections:

Providing Configuration Data in a File

To provide new configuration data 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, it either includes the format="xml" attribute or omits the format attribute:

<rpc><load-configuration url="file-location"/> </rpc>

If the data is formatted ASCII text, the format="text" attribute is included:

<rpc><load-configuration url="file-location" format="text"/> </rpc>

Before loading the file, the client application or an administrator saves either Junos XML tag elements (enclosed in a <configuration> tag element) or formatted ASCII as the contents of the file (formatted ASCII text is not enclosed in a <configuration-text> tag element in the file). For information about the syntax for the data in the file, see Defining Configuration Data as Formatted ASCII Text or Junos XML Tag Elements.

The value of the url attribute can be a local file path, an FTP location, or a Hypertext Transfer Protocol (HTTP) URL:

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 other attributes in the <load-configuration/> tag:

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.

Image t1179.gif

Providing Configuration Data as a Data Stream

To provide new configuration data as a data stream, a client application encloses the <load-configuration> tag element in an <rpc> tag element.

To define the configuration elements to change as Junos XML tag elements, the application emits the tag elements representing all levels of the configuration hierarchy from the root (represented by the <configuration> tag element) down to each element to change:

<rpc><load-configuration><configuration><!-- tag elements representing the configuration data --></configuration></load-configuration></rpc>

To define the configuration elements to change as formatted ASCII text, the application encloses them in a <configuration-text> tag element and includes the format="text" attribute in the opening <load-configuration> tag:

<rpc><load-configuration format="text"><configuration-text> /* formatted ASCII configuration data */</configuration-text></load-configuration></rpc>

For information about the syntax for Junos XML tag elements and formatted ASCII text, see Defining Configuration Data as Formatted ASCII Text or Junos XML Tag Elements.

Defining Configuration Data as Formatted ASCII Text or Junos XML Tag Elements

As discussed in Providing Configuration Data in a File and Providing Configuration Data as a Data Stream, a client application can provide new configuration data to the Junos XML protocol server either in a file or as a data stream emitted during the Junos XML protocol session. In both cases, it can use either Junos XML tag elements or formatted ASCII text to define the new configuration data.

If the application uses Junos XML tag elements, it includes the tag elements representing all levels of the configuration hierarchy from the root (the <configuration> tag element) down to each new or changed element. The notation is the same as that used to request configuration information, and is described in detail in Overview of Configuration Changes.

<configuration><!-- tag elements representing the configuration data --></configuration>

If the application provides the new data as formatted ASCII text, it uses the standard Junos OS CLI notation to indicate the hierarchical relationships between configuration statements—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 ASCII text is provided as a data stream, it is enclosed in the <configuration-text> tag element:

<configuration-text>/* formatted ASCII configuration statements */</configuration-text>

When ASCII text is provided in a previously saved file, the <configuration-text> tag element is not included in the file.

When providing new data as ASCII text, the application also includes the format="text" attribute in the <load-configuration/> tag or opening <load-configuration> tag.

<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>

The format attribute can be combined with one or more of the following attributes:

For reference pages for the <configuration> and <configuration-text> tag elements, see the Junos XML API Operational Reference.