Discussion:
Exception while adding device with loadDevice
Mouhammed Soueidane
2012-01-17 07:51:18 UTC
Permalink
Mouhammed Soueidane [http://community.zenoss.org/people/raziology] created the discussion

"Exception while adding device with loadDevice"

To view the discussion, visit: http://community.zenoss.org/message/63742#63742

--------------------------------------------------------------
Dear Guys,

I have wrote a small python script that I shall pass to Zendmd. What the script does is reading lines from a text file, and calls the loadDevice( dmd.DeviceLoader.loadDevice). Each line corresponds to a device, whereby the device attributes are a comma separated strings. A line in my file looks like this:

*ELTEST11,Server/SSH/Linux/ErrorOnly,EL10004,00:21:85:CC:84:3F,,161,None,INTERFACE,1000,,,,,,Locations/Dorm/Room 1,,,localhost,snmp,3,None*

The script that I wrote is as follows:
filePath = "/home/zenoss/DCPController/newDevices.txt"

for line in file(filePath):
   fields = line.split(',')  
   deviceId= fields[0]
   deviceClass = fields[1]
   deviceIp = fields[2]
   deviceMac = fields[3]
   snmpCommunity =fields[4]
   snmpPort = fields[5]
   snmpVersion = None
   deviceType = fields[7]
   productionState = fields[8]
   comments = fields[9]
   hwManufacturer = fields[10]
   hwProductName = fields[11]
   osManufacturer = fields[12]
   osProductName = fields[13]
   locationPath = fields[14]
dmd.DeviceLoader.loadDevice(deviceId,deviceClass,deviceIp,deviceMac,snmpCommunity,snmpPort,snmpVersion,deviceType,productionState,comments,hwManufacturer,hwProductName,osManufacturer,osProductName,locationPath)

(Please disregard the indentation towards the end of my script, I couldn't fix it with editor in here =))

This the reuslt I'm getting:

2012-01-17 02:45:25,799 INFO zen.ZenDisc: Connecting to localhost:8789
2012-01-17 02:45:26,032 INFO zen.ZenDisc: Connected to ZenHub
2012-01-17 02:45:26,765 INFO zen.ZenDisc: Looking for ELTEST11
2012-01-17 02:45:26,808 ERROR zen.ZenDisc: Error: [Failure instance: Traceback (failure with no frames): <class 'Products.ZenModel.Exceptions.NoIPAddress'>: No IP found for name ELTEST11
]
2012-01-17 02:45:26,808 INFO zen.ZenDisc: Scan time: 0.00 seconds
2012-01-17 02:45:26,833 INFO zen.ZenDisc: Daemon ZenDisc shutting down
2012-01-17 02:45:28 ERROR Zope.ZCatalog uncatalogObject unsuccessfully attempted to uncatalog an object with a uid of /zport/dmd/Devices/Server/SSH/Linux/ErrorOnly/devices/ELTEST11/os.
2012-01-17 02:45:29 ERROR zen.DeviceLoader Unable to add the device ELTEST11
Tue Jan 17 02:45:31 EST 2012 - Process Ended


Interestingly, the device is being added correctly, and all the attributes are being set correctly, and the device is being added under the correct location.
Another thing that I noticed is that running this simple script to add the device, is taking around 6-7 seconds to finish, which is not convenient when I want to add a bulk of devices altogether ( I tried using the JSON API provided by Zenoss, and it's taking almost the same amount of time to add a device, with an additional disadvantage which is that the device creation ends up as a job, which takes an additional time to be executed.
My question is: What is the best way to add devices to zenoss using Zendmd, with all the attributes that I included in my script? And how do I prevent the exceptions that were generated after its execution from being thrown?
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63742#63742]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
jcurry
2012-01-17 20:27:14 UTC
Permalink
jcurry [http://community.zenoss.org/people/jcurry] created the discussion

"Re: Exception while adding device with loadDevice"

To view the discussion, visit: http://community.zenoss.org/message/63758#63758

--------------------------------------------------------------
Is ELTEST11 resolvable by your DNS??
Cheers,
Jane
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63758#63758]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Mouhammed Soueidane
2012-01-17 20:36:11 UTC
Permalink
Mouhammed Soueidane [http://community.zenoss.org/people/raziology] created the discussion

"Re: Exception while adding device with loadDevice"

To view the discussion, visit: http://community.zenoss.org/message/63759#63759

--------------------------------------------------------------
I found what my problem is. As you have pointed out, my device could not be resolved using zendisc. I am frankly interested with adding a device, and I do not care much about any SNMP services.
I fixed the problem by passing the string value "none" as the discovery protocol which ended up adding 828 devices in 8 minutes, which is far more efficient than using the RPC calls from my java code.
Thanks a ton for your fast response.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63759#63759]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...