On Feb 28, 2007, at 10:32 AM, Duncan McGreggor wrote:

Traceback (most recent call last):
[snip]
xml.parsers.expat.ExpatError: mismatched tag: line 22, column 10

I am still getting this error in the latest Zenoss source (updated from trunk). Well, almost: the line number has changed:

xml.parsers.expat.ExpatError: mismatched tag: line 24, column 10

Okay, I had a chance to look at this some more:

The first argument in the loadDevice() signature is an unnamed parameter, 'deviceName'. Therefore, if a dict (hash, named array, whatever your language calls it) is passed as the first parameter, that data structure is dumped into the 'deviceName' variable in the loadDevice() method.

However, if you use extended call syntax and instead attempt something like the following:

>>> from xmlrpclib import ServerProxy
>>> serv = ServerProxy('http://admin:[EMAIL PROTECTED]:8080/zport/dmd')
>>> dev = {'deviceName':'127.0.0.1', 'devicePath':'/Server/Linux', 'discoverProto': 'none'}
>>> serv.DeviceLoader.loadDevice(**dev)

loadDevice() never actually gets called because this errs out. I'm not really sure why, except that is looks like the ZPublisher may be misapplying the __call__() method to one of its methods instead of the proxied object.

So, while the following (for events) is correct:

>>> evt = {'device':'mydevice', 'component':'eth0', 'summary':'eth0 is down','severity':4, 'eclass':'/Net'}
>>> serv.ZenEventManager.sendEvent(evt)

one cannot use the same technique (passing a dict) for adding a device. It seems to be broken. For now, you must actually do the following for adding a device via XML-RPC:

>>> serv.DeviceLoader.loadDevice('127.0.0.1', '/Server/Linux', '', '', '', 161, 'v1', 0, 1000, '', '', '', '', '', '', [], [], ['localhost'], 'localhost', 'snmp')

By not using named parameters, all parameters are treated positionally. You must pass these in order, though. For reference, here they are:

            deviceName,
            devicePath="/Discovered",
            tag="", serialNumber="",
            zSnmpCommunity="", zSnmpPort=161, zSnmpVer="v1",
            rackSlot=0, productionState=1000, comments="",
            hwManufacturer="", hwProductName="",
            osManufacturer="", osProductName="",
            locationPath="", groupPaths=[], systemPaths=[],
statusMonitors=["localhost"], performanceMonitor="localhost",
            discoverProto="snmp"

The only Zenoss XML-RPC method I have ever personally used is sendEvent(), so I'm not sure if the others were working at some point and are broken now, or were never tested.

I have opened a ticket for this and you may track it here:
  http://dev.zenoss.org/trac/ticket/1028
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users

Reply via email to