Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Compare the Active or Candidate Configuration to a Prior Version Using the Junos XML Protocol

In the Junos OS CLI, you use the compare command to compare the active or candidate configuration to a previously committed configuration and display the differences. You can specify the comparison configuration by referencing its configuration revision identifier or its rollback number.

For example, in operational mode, you can compare the active configuration to a previously committed configuration by using the following commands:

  • show configuration | compare revision revision-id

  • show configuration | compare rollback rollback-number

Similarly in configuration mode, you can compare the candidate configuration to a previously committed configuration by using the following commands:

  • show | compare revision revision-id

  • show | compare rollback rollback-number

In a Junos XML protocol session with a device running Junos OS, to request that the server display the differences between the active or candidate configuration and a previously committed configuration (the comparison configuration), a client application uses the <get-configuration> operation with the compare attribute. The compare attribute accepts the following values, which indicate the method used to reference the comparison configuration:

  • configuration-revision—Reference the comparison configuration by its configuration revision identifier string, which you define in the configuration-revision="revision-id" attribute.

  • rollback—Reference the comparison configuration by its rollback index, which you define in the rollback="rollback-number" attribute.

The compare attribute can be combined with the database attribute to indicate whether the candidate configuration or the active configuration is compared to the previously committed configuration. To compare the active configuration, specify database="committed". To compare the candidate configuration, specify database="candidate" or omit the database attribute.

You define the comparison configuration by defining the configuration-revision or rollback attribute and specifying the appropriate configuration revision identifier or rollback index. If you include the compare attribute but either omit the corresponding configuration-revision or rollback attribute or provide an invalid configuration revision identifier, the server uses the active configuration as the comparison configuration. The active configuration corresponds to rollback number 0.

For example, to compare the candidate configuration to the configuration that has the given configuration revision identifier, use the following syntax:

Similarly, to compare the candidate configuration to the configuration that has the given rollback index, use the following syntax:

To compare the active configuration to a previous configuration, include the database="committed" attribute. For example:

You can also specify the scope of the comparison. You can compare the full configuration or you can compare a subset of the configuration. To compare a subset of the configuration, define a subtree filter that selects the elements to compare, as shown in the following example:

When you compare the candidate configuration to the active configuration, the compare operation returns XML output. For all other comparisons, it returns the output as text using a patch format. The text output is enclosed in the <configuration-information> and <configuration-output> tags. The output uses the following conventions to specify the differences between configurations:

  • Statements that are only in the active or candidate configuration are prefixed with a plus sign (+).

  • Statements that are only in the comparison file are prefixed with a minus sign (–).

  • Statements that are unchanged are prefixed with a single blank space ( ).

When you compare the candidate configuration to the active configuration, you can display the differences in text, XML, or JSON format by including the appropriate value for the format attribute in the request. You can display the differences in XML format starting in Junos OS Release 15.1R1, and you can display the differences in JSON format starting in Junos OS Release 16.1R1.

Note:

Starting in Junos OS Release 16.2R2, when you compare the candidate and active configurations and display the differences in XML or JSON format, the device omits the <configuration> tag in the XML output and omits the configuration object in the JSON output if the comparison either returns no differences or if the comparison returns differences for only non-native configuration data, for example, configuration data associated with an OpenConfig data model.