Mouhammed Soueidane
2012-01-17 07:51:18 UTC
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]
"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]