cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3229
Views
35
Helpful
10
Replies

Restconf re-deploy dry-run

Hi NSO Developer HUB Community, 

I'm have some trouble to make a restconf api call to work, to get the output of the command re-deploy dry-run as below:


}dry-run.png

 

I'm able to perform the re-deploy operation, but I'm not able to use the api properly to get only the output of the re-deploy dry-run operation

 

curl -i -u xxx:xxx http://localhost:8080/restconf/data/tailf-ncs:services/tim-ncs-services:tim-ncs-services/ce-services=00186/re-deploy -X POST -H "Accept: application/yang-data+json"

 

 

 

10 Replies 10

gutizar
Level 1
Level 1

You can use the dry-run query parameter to do that via RESTCONF. Something like:

 

curl -i -u xxx:xxx http://localhost:8080/restconf/data/tailf-ncs:services/tim-ncs-services:tim-ncs-services/ce-services=00186/re-deploy?dry-run=native -X POST -H "Accept: application/yang-data+json"

 

Valid options are xml, cli and native.

Hi gutizar , manyt thanks for your reply.

 

I tried your solution, but it appears tha NSO is ignoring the dry-run parameter and only executes the re-deploy operation:

 

[root@NSODEV01 yang]# curl -i -u xxx:xxx http://localhost:8080/restconf/data/tailf-ncs:services/tim-ncs-services:tim-ncs-services/ce-services=00186/re-deploy?dry-run=native -X POST -H "Accept: application/yang-data+json"
HTTP/1.1 204 No Content
Date: Wed, 31 Mar 2021 14:35:05 GMT
Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
Content-Length: 0
Content-Type: text/html
Pragma: no-cache

 

Captura de tela 2021-03-31 121659.png

You need to do something like this (this example works with examples.ncs/getting-started/developing-with-ncs/4-rfs-service:

curl -v -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json' -u admin:admin -X POST http://localhost:8080/restconf/data/tailf-ncs:services/syslog-service:syslog/re-deploy -d '{ "dry-run": {} }'

Hi vleijon, thanks for your help.

Unfortunelly your solution didn't work as well. I got the same behavior as before, the re-deploy operation is performed without the dry-run parameter.

 

Service status before the call execution:

befor_call.png

Performing the restconf call: Returned 204 No Content

02-request.png

 

On NSO the service re-deploy is executed, and the service gets in sync again. But all I want is the dry-run output.

03-after-request.png

vleijon
Cisco Employee
Cisco Employee

It definitely worked for me, I saw this output:

VLEIJON-M-V8CE:4-rfs-service vleijon$ curl -v -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+json' -u admin:admin -X POST http://localhost:8080/restconf/data/tailf-ncs:services/syslog-service:syslog/re-deploy -d '{ "dry-run": {} }'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8080 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'admin'
> POST /restconf/data/tailf-ncs:services/syslog-service:syslog/re-deploy HTTP/1.1
> Host: localhost:8080
> Authorization: Basic YWRtaW46YWRtaW4=
> User-Agent: curl/7.54.0
> Accept: application/yang-data+json
> Content-Type: application/yang-data+json
> Content-Length: 17
>
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 200 OK
< Date: Wed, 31 Mar 2021 15:45:19 GMT
< Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
< Content-Length: 56
< Content-Type: application/yang-data+json
< Pragma: no-cache
< Content-Security-Policy: default-src 'self'; block-all-mixed-content; base-uri 'self'; frame-ancestors 'none';
< Strict-Transport-Security: max-age=15552000; includeSubDomains
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
< X-XSS-Protection: 1; mode=block
<
{
  "syslog-service:output": {
    "cli": {
    }
  }
}

I can't see a difference. Maybe you could try it on the example service too just to see if it works there for you or not?

Hi vleijon,

Thanks again for you help. In the end, I had to open a TAC to request assistance on this. At first they provide the same solution as gutizar and you, that wasn't working for me. Finally they provide the correct call sintax that worked:

 

curl -v -H 'Accept: application/yang-data+json' -H 'Content-Type: application/yang-data+xml' -u xxx:xxx -X POST http://localhost:8080/restconf/data/tailf-ncs:services/tim-ncs-services:tim-ncs-services/ce-services=00186/re-deploy -d '<input><dry-run><outformat>native</outformat></dry-run></input>'

 

Regards,

I am glad they resolved it, but I wonder why JSON works for me and not for you!

Yes, me too. I asked them about this. They didn't answer so far.

I just ran into this today, the correct JSON payload seems to be:

{
	"input": {
		"dry-run": {
			"outformat": "native"
		}
	}
}

curl --location 'https://localhost:4464/restconf/operations/tailf-ncs:devices/device=pe-0/sync-from' \
--header 'Accept: application/yang-data+xml' \
--header 'Content-Type: application/yang-data+xml' \
--data '<input>
<dry-run></dry-run>
</input>'

response like,

<output xmlns='http://tail-f.com/ns/ncs'>
    <cli> config {
     snmp-server {
         vrfs {
             vrf MGMT-VRF {
                 hosts {
-                    host 10.10.10.10 {
-                        traps {
-                            encrypted {