i have a basic script which i started; which traverses the dmd tree and then call a method device_info(d) to return all the attributes from the device (using http://fqdn:8080/zport/dmd/manage, clicking on Devices and then clicking on the "property" tab)
problem is when i iterate over the dmd.Devices the objects are strings; which then i cannot get any of the attributes. i was assuming that dmd.Devices would return an object reference to some sub-class of DeviceClass.
question: once you get the list of devices as a string; how can you then use that string to get all its attributes? also, is there a way to just simple get the DeviceClass objects directly?
def indent_spaces(level = 1):
ret = ''
indent = ' '
for i in xrange(level):
ret += indent
return ret
def device_info(device, level = 1):
ret = ""
#add device description
ret += indent_spaces(level)
ret += 'description => '
ret += device.description
ret += "\n"
#add device zPythonClass
ret += indent_spaces(level)
ret += 'pythonClass => '
ret += device.zPythonClass
ret += "\n"
# add more attributes here
return ret
dmd = ZenScriptBase(connect=True).dmd
print '######################################'
print 'dmd.Devices'
print '######################################'
for d in dmd.Devices:
print "device => %s " % d
print device_info(d)
print ''
print ''
print '######################################'
print 'dmd.Devices.getSubDevices'
print '######################################'
for d in dmd.Devices.getSubDevices():
print "device.subDevice => %s" % d
print device_info(d)
print ''
print ''