TECHZEN Zenoss User Community ARCHIVE  

Progamatically create local zProperty value?

Subject: Progamatically create local zProperty value?
Author: Joan
Posted: 2015-02-20 10:16

I am trying to accomplish resetting the bindings in a whole device class, but at the moment i am stuck in this part, I try to disable the monitoring for a device.


d = dmd.Devices.findDevice('RT-276')
d.setZenProperty('zSnmpMonitorIgnore', True)

I get

>>> d.setZenProperty('zSnmpMonitorIgnore', True)
Traceback (most recent call last):
File "", line 1, in
File "/opt/zenoss/Products/ZenRelations/ZenPropertyManager.py", line 426, in setZenProperty
self._updateProperty(propname, propvalue)
File "/opt/zenoss/Products/ZenRelations/ZenPropertyManager.py", line 316, in _updateProperty
super(ZenPropertyManager, self)._updateProperty(id, value)
File "/opt/zenoss/lib/python/OFS/PropertyManager.py", line 205, in _updateProperty
raise BadRequest, 'The property %s does not exist' % escape(id)
BadRequest: The property zSnmpMonitorIgnore does not exist

If I try instead:

d = dmd.Devices.findDevice('RT-276')
d.zSnmpMonitorIgnore = True
commit()

Then there are no errros, but the value isn't changed either (it only works for the local values)

Any tips



Subject: To do this using the JSON API
Author: [Not Specified]
Posted: 2015-02-20 10:29

To do this using the JSON API, you could do it this way:

zenoss_api "device_router" "DeviceRouter" "setZenProperty" '{"uid":"/zport/dmd/Devices/Server/Linux/devices/ZENOSSTEST","zProperty":"zSnmpMonitorIgnore","value":1}'

Note that it requires arguments of zProperty and value, not just the zproperty:value so maybe the DMD method works similarly



Subject: After running the command
Author: Joan
Posted: 2015-02-20 11:04

After running the command with the json api (just to try), I receive some similar answer to the one I am getting while using the web frontend. I guess something got broken when doing the zendmd commands, and the property is no longer there :(

{"uuid": "698a9bae-960a-4976-9750-c0352c18a93a", "action": "DeviceRouter", "result": {"msg": "BadRequest: The property zSnmpMonitorIgnore does not exist", "type": "exception", "success": false}, "tid": 1, "type": "rpc", "method": "setZenProperty"}



< Previous
XHR Request to the JSON API
  Next
how to query zodb database for device/status?
>