Retrieve a Previous (Rollback) Configuration Using NETCONF
In a NETCONF session with a device running Junos OS, to request a previously committed
(rollback) configuration, a client application emits the Junos XML
<get-rollback-information>
tag element and its child
<rollback>
tag element in an <rpc>
tag element. This operation is equivalent to the show system
rollback
operational mode command. The
<rollback>
tag element specifies the index number of the
previous configuration to display; its value can be from 0 (zero, for the most
recently committed configuration) through 49.
To request Junos XML-tagged
output, the application either includes the <format>
tag
element with the value xml
or omits the
<format>
tag element (Junos XML tag elements are the
default):
<rpc> <get-rollback-information> <rollback>index-number</rollback> </get-rollback-information> </rpc> ]]>]]>
The
NETCONF server encloses its response in <rpc-reply>
,
<rollback-information>
, and
<configuration>
tag elements. The
<ok/>
tag is a side effect of the implementation and does
not affect the results. For information about the attributes in the opening
<configuration>
tag, see Specify the Source for Configuration Information Requests Using NETCONF.
<rpc-reply xmlns="URN" xmlns:junos="URL"> <rollback-information> <ok/> <configuration attributes> <!-- tag elements representing the complete previous configuration --> </configuration> </rollback-information> </rpc-reply> ]]>]]>
To
request formatted ASCII output, the application includes the
<format>
tag element with the value
text
.
<rpc> <get-rollback-information> <rollback>index-number</rollback> <format>text</format> </get-rollback-information> </rpc> ]]>]]>
The
NETCONF server encloses its response in <rpc-reply>
,
<rollback-information>
,
<configuration-information>
, and
<configuration-output>
tag elements. For more information
about the formatted ASCII notation used in Junos OS configuration statements, see
the CLI User
Guide.
<rpc-reply xmlns="URN" xmlns:junos="URL"> <rollback-information> <ok/> <configuration-information> <configuration-output> /* previous configuration in formatted ASCII*/ </configuration-output> </configuration-information> </rollback-information> </rpc-reply> ]]>]]>
Starting
in Junos OS Release 16.1, to request a previously committed (rollback) configuration
in JSON format, the application includes the <format>
tag
element with the value json
in the
<get-rollback-information>
element. Prior to Junos OS
Release 16.1, JSON-formatted data is requested by including the
format="json"
attribute in the opening
<get-rollback-information>
tag.
<rpc> <get-rollback-information> <rollback>index-number</rollback> <format>json</format> </get-rollback-information> </rpc> ]]>]]>
When
you use the format="json"
attribute to specify the format, the
NETCONF server encloses its response in an <rpc-reply>
element, the field name for the top-level JSON member is
"rollback-information"
, and the emitted configuration data uses
an older implementation for serialization. When you use the
<format>json</format>
element to request
JSON-formatted data, the NETCONF server encloses its response in
<rpc-reply>
,
<rollback-information>
,
<configuration-information>
, and
<json-output>
tag elements, the field name for the
top-level JSON member is "configuration"
, and the emitted
configuration data uses a newer implementation for serialization.
<rpc-reply xmlns="URN" xmlns:junos="URL"> <rollback-information> <ok/> <configuration-information> <json-output> <!-- JSON data for the complete previous configuration --> </json-output> </configuration-information> </rollback-information> </rpc-reply> ]]>]]>
The following example shows how to request Junos XML-tagged output for the rollback configuration that has an index of 2. In actual output, the Junos-version variable is replaced by a value such as 20.4R1 for the initial version of Junos OS Release 20.4.
<format>
tag element with the value json
in the <get-rollback-information>
element. Prior to Junos
OS Release 16.1, JSON-formatted data is requested by including the format="json"
attribute in the opening <get-rollback-information>
tag.