Developer's Guide

  • Docs Home
  • Community Home

2. Editing Device Information

Devices can be edited through the UI but also through a programmatic interface. This how to will describe editing device info using that interface.

2.1. Using a REST call

Editing device info through a rest call can be done by a simple web get. In this example we will use wget to add a device. If you use wget don't forget to escape the "&" or wrap the URL in single quotes.

$ wget 'http://admin:zenoss@MYHOST:8080/zport/dmd/Devices/\
Server/Linux/devices/MYDEVICE/manage_editDevice?serialNumber=MYSERIALNUM\
&tag=MYTAG'

The result of this command will change the Serial Number to MYSERIALNUM and the Tag to MYTAG for device, MYDEVICE.

2.2. Using an XML-RPC Call from Python

This is an example of how to edit device info using Python. Because XML-RPC can be used from any language feel free to use your favorite. What is important here is the base URL in ServerProxy, passing named parameters, and calling editDevice on your proxy object.

>>> from xmlrpclib import ServerProxy
>>> url = 'http://admin:zenoss@MYHOST:8080/zport/dmd/Devices/'
                   'Server/Linux/devices/MYDEVICE'
>>> serv = ServerProxy(url)
>>> serv.manage_editDevice('MYTAG', 'MYSERIALNUM')

Here is the signature of manage_editDevice() from Device.py

def manage_editDevice( self, tag="", serialNumber="",
zSnmpCommunity="", zSnmpPort=161, zSnmpVer="v1",
rackSlot=0, productionState=1000, comments="",
hwManufacturer="", hwProductName="",
osManufacturer="", osProductName="",
locationPath="", groupPaths=[], systemPaths=[],
statusMonitors=["localhost"], performanceMonitor="localhost",
priority=3, REQUEST=None):