cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1681
Views
0
Helpful
3
Replies

NSO Rollback per Rest API

DTtb
Level 1
Level 1

 

How to rollback the configuration file with the name <name>0</name> from rollback configuration datastore per REST-API?

Do I need a HTTP-POST-requests to start the rollback?

 

<rollbacks xmlns="http://tail-f.com/ns/rest" xmlns:y="http://tail-f.com/ns/rest">
  <file>
    <name>0</name>
    <creator>admin</creator>
    <date>2019-07-18 13:15:18</date>
    <via>rest</via>
    <label></label>
    <comment></comment>
  </file>
  <file>
    <name>1</name>
    <creator>admin</creator>
    <date>2019-07-18 13:13:16</date>
    <via>rest</via>
    <label></label>
    <comment></comment>
  </file>
  <file>
    <name>2</name>
    <creator>admin</creator>
    <date>2019-07-18 13:01:09</date>
    <via>rest</via>
    <label></label>
    <comment></comment>
  </file>
</rollbacks> 

 

1 Accepted Solution

Accepted Solutions

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

using admin:admin as username/password - this will apply the latest rollback file

 

curl -X POST \
  http://<IP>:<PORT>/api/running/_rollback \
  -H 'Accept: application/vnd.yang.data+json' \
  -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'Content-Type: application/vnd.yang.data+json' \
  -d '{ 
  "file": 0
}'

This is documented `$NCS_DIR/doc/html/nso_northbound/ch03s04s06.html` for NSO 4.7.2 if you want more information.

 

View solution in original post

3 Replies 3

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

via the REST(CONF) API you have an action apply-rollback-file defined in

$NCS_DIR/src/ncs/yang/tailf-rollback.yang

 

The documentation of NSO 5.1 has a chapter including an example on how to use this action (the two code snapshots below are from this documentation):

Step 1: (not mandatory if you know for sure which rollback file you want to apply). Get the list of available rollback files using

GET /restconf/data/tailf-rollback:rollback-files

Step 2: you can use the action to apply a rollback file:

POST /restconf/data/tailf-rollback:rollback-files/apply-rollback-file HTTP/1.1
Content-Type: application/yang-data+xml
<input xmlns="http://tail-f.com/ns/rollback">
  <id>0</id>
</input>

 

Note: there is a second action in the YANG module that allows you to get the content of the rollback file if you need it.

 

PS: the reason I wrote REST(CONF) is that the REST API will be deprecated in NSO 5.3 as per the release notes of NSO 5.1 and so it is better to start using RESTCONF rather than REST to be future proof.

 

Thanks for the answer.

Could you provide an example for REST-API (not RESTCONF) with JSON payload?
Only for testing purpose for NSO version 4.7..

gmuloche
Cisco Employee
Cisco Employee

Hello,

 

using admin:admin as username/password - this will apply the latest rollback file

 

curl -X POST \
  http://<IP>:<PORT>/api/running/_rollback \
  -H 'Accept: application/vnd.yang.data+json' \
  -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
  -H 'Content-Type: application/vnd.yang.data+json' \
  -d '{ 
  "file": 0
}'

This is documented `$NCS_DIR/doc/html/nso_northbound/ch03s04s06.html` for NSO 4.7.2 if you want more information.

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: