Not sure you want to iterate over Devices - just the subDevices. Then you need to print d.id to get the "name" of the device - or, better, use the titleOrId function so if you have set up a human-friendly name, it will use that rather than the id field:
#!/usr/bin/env python
import Globals
import csv
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit
def indent_spaces(level = 1):
ret = ''
indent = ' '
for i in xrange(level):
ret += indent
return ret
def device_info(device, level = 1):
ret = ""
# device description
ret += indent_spaces(level)
ret += 'description => '
#ret += 'testing'
ret += device.description
ret += "\n"
# device zPythonClass
ret += indent_spaces(level)
ret += 'zPythonClass => '
#ret += 'testing'
ret += device.zPythonClass
ret += "\n"
# device property - add 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.titleOrId()
print device_info(d)
print ''
print ''
Does that do what you want?
Cheers,
Jane