Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Replace the Configuration Using the Junos XML Protocol

In a Junos XML protocol session with a device running Junos OS, a client application can replace the entire candidate configuration or a private copy of it, either with new data or by rolling back to a previous configuration or a rescue configuration. Starting in Junos OS Release 18.1R1, a client application can also replace all configuration data in an ephemeral configuration database instance with new data.

Note:

Junos OS does not support rolling back the configuration committed to an instance of the ephemeral configuration database.

The following sections discuss how to replace all configuration data in the candidate configuration or open configuration database. The client application must commit the configuration after replacing the data to make it the active configuration on the device. For instructions that modify individual configuration elements, see Creating, Modifying, or Deleting Configuration Elements Using the Junos XML Protocol.

Replacing the Candidate Configuration with New Data

To discard all configuration data in the candidate configuration or open configuration database and replace it with new configuration data, a client application executes the <load-configuration> operation and includes the action="override" attribute. If a client application issues the <open-configuration> operation to open a specific configuration database before executing the <load-configuration> operation, the server loads the configuration data into the open configuration database. Otherwise, the server loads the configuration data into the candidate configuration.

For more information about the url and format attributes and the syntax for the new configuration data, see Uploading and Formatting Configuration Data in a Junos XML Protocol Session.

The following example shows how to specify that the contents of the file /tmp/new.conf replace the entire candidate configuration. The file contains Junos XML tag elements (the default), so the format attribute is omitted.

Client Application

Junos XML Protocol Server

Rolling Back the Candidate Configuration to a Previously Committed Configuration

Devices running Junos OS store a copy of the most recently committed configuration and up to 49 previous configurations, depending on the platform. You can roll back to any of the stored configurations. This is useful when configuration changes cause undesirable results, and you want to revert back to a known working configuration. Rolling back the configuration is similar to the process for making configuration changes on the device, but instead of loading configuration data, you perform a rollback, which replaces the entire candidate configuration with a previously committed configuration.

When you successfully commit a configuration, Junos OS assigns that configuration a unique configuration revision identifier. The configuration is also associated with a rollback index, where the most recently committed configuration has rollback index 0. Whereas the rollback index for a previously committed configuration increments with each commit, the configuration revision identifier remains static for the same configuration. When you roll back to a previously committed configuration, you can reference the configuration by its current rollback index or its configuration revision identifier.

To replace the candidate configuration (or open configuration database) with a previously committed configuration, Junos XML protocol clients can use one of the following methods:

  • Execute the <load-configuration/> operation with the rollback="index" attribute to roll back to the configuration with the given rollback index.

  • Execute the <load-configuration/> operation with the configuration-revision="revision-id" attribute to roll back to the configuration with the given configuration revision identifier.

  • Execute the <rollback-config> RPC with the <index> child element, which defines a rollback index. This RPC, which is available starting in Junos OS Release 18.1R1, is useful when an application does not support executing RPCs that include XML attributes.

Note:

Junos OS does not support rolling back the configuration committed to an instance of the ephemeral configuration database. Thus the ephemeral database does not support using the <rollback-config> RPC or the <load-configuration> operation with either the rollback or the configuration-revision attributes.

To use the <load-configuration> operation to replace the candidate configuration or open configuration database with a previously committed configuration, a client application executes the <load-configuration/> operation and includes the rollback or configuration-revision attribute. The rollback value is the numerical rollback index of the appropriate previous configuration. Valid values are 0 (zero, for the most recently committed configuration) through one less than the number of stored previous configurations (maximum is 49). The configuration-revision value is the configuration revision identifier of the configuration to load, for example, re0-1605228066-332.

The Junos XML protocol server indicates that the load operation was successful by returning the <load-configuration-results> and <load-success/> elements in its RPC reply.

To use the <rollback-config> RPC to load a previously committed configuration, a client application executes the <rollback-config> RPC with the <index> element. The <index> element specifies the rollback index for the configuration to load.

The Junos XML protocol server indicates that the load operation was successful by returning the <rollback-config-results> and <load-success/> elements in its RPC reply.

If the load operation is successful, the client application must commit the configuration to make it the active configuration on the device. If the server encounters an error while loading the rollback configuration, it returns an <xnm:error> element with information about the error.

Replacing the Candidate Configuration with a Rescue Configuration

A rescue configuration allows you to define a known working configuration or a configuration with a known state that you can restore at any time. You use the rescue configuration when you need to revert to a known configuration or as a last resort if the device configuration and the backup configuration files become damaged beyond repair. When you create a rescue configuration, the device saves the most recently committed configuration as the rescue configuration.

To replace the candidate configuration or the open configuration database with the device’s rescue configuration, a Junos XML protocol application can use one of the following methods. The rescue configuration must exist on the device before you can load it.

  • Execute the <load-configuration/> operation with the rescue="rescue" attribute.

  • Execute the <rollback-config> RPC with the <rescue/> child element. This RPC, which is available starting in Junos OS Release 18.1R1, is useful when an application does not support executing RPCs that include XML attributes.

To use the <load-configuration/> operation to replace the candidate configuration with the rescue configuration, include the rescue="rescue" attribute in the <load-configuration/> tag.

The Junos XML protocol server indicates that the load operation was successful by returning the <load-configuration-results> and <load-success/> elements in its RPC reply.

To use the <rollback-config> RPC to load the rescue configuration, a client application emits the <rollback-config> element and the <rescue/> child tag.

The Junos XML protocol server indicates that the load operation was successful by returning the <rollback-config-results> and <load-success/> elements in its RPC reply.

If the load operation is successful, the client application must commit the configuration to make it the active configuration on the device. If the rescue configuration does not exist or the server encounters another error while loading the configuration data, it returns an <xnm:error> element with information about the error.

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.

Release
Description
18.1R1
Starting in Junos OS Release 18.1R1, a client application can also replace all configuration data in an ephemeral configuration database instance with new data.