TECHZEN Zenoss User Community ARCHIVE  

Not able to delete device using Curl/Json API

Subject: Not able to delete device using Curl/Json API
Author: [Not Specified]
Posted: 2015-03-27 07:01

I have installed Zenoss and when I am trying to delete device, I am getting below error.
Would appretiate if you guys can help me with that.

Adding device is working fine, but deleting device throwing errors.

curl -u "admin:xxxxxx" -X POST -H "Content-Type:application/json" -d "{\"action\":\"DeviceRouter\", \"method\":\"getDevices\", \"data\":[{\"uid\":\"/zport/dmd/Devices/Server/JBoss/devices/server.example.com\"}], \"type\":\"rpc\", \"tid\":1}" "zenoss.example.com:8080/zport/dmd/device_router"

and then use this within a subsequent removeDevices call

curl -u "admin:xxxxxx" -X POST -H "Content-Type:application/json" -d "{\"action\":\"DeviceRouter\", \"method\":\"removeDevices\", \"data\":[{\"uids\":\"/zport/dmd/Devices/Server/JBoss/devices/ server.example.com \", \"hashcheck\":\"1\", \"action\":\"remove\", \"deleteEvents\":\"true\", \"deletePerf\":\"true\"}], \"type\":\"rpc\", \"tid\":1}" " zenoss.example.com:8080/zport/dmd/device_router"

However, I get an AssertionError on the removeDevices call:

{"uuid": "dcbd97be-861b-4c3c-a9de-f8a6689b7596", "action": "DeviceRouter", "result": {"msg": "Failed to remove devices.: AssertionError: ", "type": "exception", "success": false}, "tid": 1, "type": "rpc", "method": "removeDevices"}



Subject: RE: Not able to delete device using Curl/Json API
Author: Josh Zenker
Posted: 2019-06-17 15:06

I'm reviving this old thread in case anyone else encounters the same issue. You need to use the action "delete" instead of "remove" if you want to entirely delete a device. So your curl command would be:

curl -u "admin:xxxxxx" -X POST -H "Content-Type:application/json" -d "{\"action\":\"DeviceRouter\", \"method\":\"removeDevices\", \"data\":[{\"uids\":\"/zport/dmd/Devices/Server/JBoss/devices/ server.example.com \", \"hashcheck\":\"1\", \"action\":\"delete\", \"deleteEvents\":\"true\", \"deletePerf\":\"true\"}], \"type\":\"rpc\", \"tid\":1}" " zenoss.example.com:8080/zport/dmd/device_router"

This works in RM 6.2.1 and probably newer releases too.

------------------------------
Josh Zenker
Linux System Administrator
Temple University
------------------------------


< Previous
Was unable to start service
  Next
Zenoss 5 Core - can't install QUILT
>