03-30-2021 12:05 PM
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:
}
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"
03-31-2021 01:04 AM
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.
03-31-2021 08:18 AM
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
03-31-2021 08:48 AM
03-31-2021 09:55 AM
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:
Performing the restconf call: Returned 204 No Content
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-31-2021 10:30 AM
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?
04-01-2021 06:35 AM
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,
04-01-2021 07:09 AM
04-01-2021 08:36 AM
05-27-2021 01:58 AM
I just ran into this today, the correct JSON payload seems to be:
{ "input": { "dry-run": { "outformat": "native" } } }
03-14-2024 08:51 PM
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,
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide