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

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

Similarly, in a Junos XML protocol session, a client application can compare the active or candidate configuration to a previously committed configuration (the comparison configuration). To display the differences, the 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.

You can combine the compare attribute with the database attribute to indicate whether to compare the candidate configuration or the active configuration to the previously committed configuration. The database attribute accepts the following values:

  • database="candidate"—Compare the candidate configuration. This value is the default.

  • database="committed"—Compare the active configuration.

You specify the comparison configuration by including either the configuration-revision or rollback attribute and specifying the appropriate configuration revision identifier or rollback index. If you do not provide the configuration-revision or rollback attribute or if you 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 <configuration-information> and <configuration-output> tags enclose the text output. 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. To select a format, include the format attribute in the request and specify the format value.

For example, the following request returns XML format:

The following request returns JSON format:

Note:

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 in the following cases:

  • The comparison returns no differences

  • The comparison returns differences for only non-native configuration data, for example, configuration data associated with an OpenConfig data model.