cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1554
Views
15
Helpful
5
Replies

Push Device Config via REST curl call

Noelle9579
Level 1
Level 1

Hello,

I am trying to construct the curl call to push a device config onto an existing device on NSO. 

Similar to this: https://community.cisco.com/t5/nso-developer-hub-discussions/rest-api-for-config-push-onto-nso-device/m-p/3604043#M2330 but this discussion did not include the actual curl path to execute the call.

I have tried:

curl -H "Content-Type:applicaiton/vnd.yang.data+xml" -X PUT -d @sample.xml http:localhost:8080/api/running/devices/device/device-name -u user:password

Response: 

<errors xmlns="http://tail-f.com/ns/tailf-rest-error">
<error>
<error-tag>malformed-message</error-tag>
<error-urlpath>/api/running/devices/device/device-name</error-urlpath>
<error-message>unknown element: devices in /ncs:devices/ncs:devices</error-message>
</error>
</errors>

 

5 Replies 5

rogaglia
Cisco Employee
Cisco Employee

In recent versions, the pre-standard REST API has been deprecated in favor of the standard RESTCONF.

 

Your call would now look like:

 

curl --location  -u user:password --request GET 'http://127.0.0.1:8080/restconf/data/tailf-ncs:devices/device=ce1' \
--header 'Accept: application/yang-data+json'
 

Hello,

I did some digging and found out restconf should be the new way to do the call. This call seems to retrieves the config, but I was wondering if there is a way to push the config to a device? 

Maybe this collection of swagger example would be helpful to you: https://developer.cisco.com/docs/nso/#!cisco-nso-restconf-swagger-api-docs

It is certainly possible to update the device configuration!

 https://gitlab.com/nso-developer/rest-api-explorer  builds curl commands automatically by a few GUI clicks.

perander
Cisco Employee
Cisco Employee

I also suggest that you should use the standardized RESTCONF protocol.

 

I note however that there might be a mismatch in the path?

 

The request

curl -H "Content-Type:applicaiton/vnd.yang.data+xml" -X PUT -d @sample.xml http:localhost:8080/api/running/devices/device/device-name -u user:password

In the response error it says

<error-urlpath>/api/running/devices/device/device-name</error-urlpath>
<error-message>unknown element: devices in /ncs:devices/ncs:devices</error-message>

Is there a spurios "s" in the payload's device element perhaps?

Perhaps it says

<devices>
<devices>
<name>device-name</name>

Note the *two* devices elements, the latter should be <device> only.