07-09-2015 01:24 PM
Hi team,
Is there a direct REST call to create a device or I have to do it via a service?
E.g.: curl -i -u admin:admin http://127.0.0.1:8080/api/config/devices/device/newDevice -X PUT -H "Content-Type: application/vnd.yang.data+xml" -T deviceProperties.xml
Solved! Go to Solution.
07-09-2015 01:25 PM
I gues this is what you where looking for:
mleske$ curl -i -u admin:admin -X POST -T device.xml http://127.0.0.1:8080/api/config/devices
HTTP/1.1 100 Continue
Server:
Allow: GET, POST, OPTIONS, HEAD
Content-Length: 0
HTTP/1.1 201 Created
Server:
Location: http://127.0.0.1:8080/api/config/devices/device/x2
Date: Thu, 25 Jun 2015 21:04:02 GMT
Allow: GET, POST, OPTIONS, HEAD
Last-Modified: Thu, 25 Jun 2015 21:04:02 GMT
Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
Etag: 1435-266242-872900
Content-Length: 0
Content-Type: text/html
Pragma: no-cache
mleske$ cat device.xml
<device>
<name>x2</name>
<address>127.0.0.1</address>
<port>10030</port>
<ssh>
<host-key>
<algorithm>ssh-dss</algorithm>
<key-data>.......</key-data>
</host-key>
</ssh>
<state>
<admin-state>unlocked</admin-state>
</state>
<authgroup>default</authgroup>
<device-type>
<cli>
<ned-id xmlns:cisco-ios-xr-id="http://tail-f.com/ned/cisco-ios-xr-id">cisco-ios-xr-id:cisco-ios-xr</ned-id>
</cli>
</device-type>
</device>
07-09-2015 01:25 PM
I gues this is what you where looking for:
mleske$ curl -i -u admin:admin -X POST -T device.xml http://127.0.0.1:8080/api/config/devices
HTTP/1.1 100 Continue
Server:
Allow: GET, POST, OPTIONS, HEAD
Content-Length: 0
HTTP/1.1 201 Created
Server:
Location: http://127.0.0.1:8080/api/config/devices/device/x2
Date: Thu, 25 Jun 2015 21:04:02 GMT
Allow: GET, POST, OPTIONS, HEAD
Last-Modified: Thu, 25 Jun 2015 21:04:02 GMT
Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
Etag: 1435-266242-872900
Content-Length: 0
Content-Type: text/html
Pragma: no-cache
mleske$ cat device.xml
<device>
<name>x2</name>
<address>127.0.0.1</address>
<port>10030</port>
<ssh>
<host-key>
<algorithm>ssh-dss</algorithm>
<key-data>.......</key-data>
</host-key>
</ssh>
<state>
<admin-state>unlocked</admin-state>
</state>
<authgroup>default</authgroup>
<device-type>
<cli>
<ned-id xmlns:cisco-ios-xr-id="http://tail-f.com/ned/cisco-ios-xr-id">cisco-ios-xr-id:cisco-ios-xr</ned-id>
</cli>
</device-type>
</device>
07-09-2015 01:26 PM
It worked perfectly well. Thank you!
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 community: