Removing Commas From IDs and Names

From Zenoss Wiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search

If you imported devices into Zenoss and ended up with devices with IDs and names that include commas, the page will not display in the UI, essentially breaking the device. To remove the commas, run the following Python script. Edit the password in the "baseUrl" line, and change the text after the @ symbol to reflect the FQDN and port number you use to access Zenoss. Note, you may also need to change HTTP to HTTPS if you require that.

This script may also be used to replace other text in the ID/Name fields, simply change the "newname = string.replace(, ',', )" line. In this example it is searching for a comma and replacing it with <blank>.

from xmlrpclib import ServerProxy, ProtocolError
import string
baseUrl = 'http://admin:password@localhost:8080'
for d in dmd.Devices.getSubDevices():
        oldname =
        newname = string.replace(, ',', '')
        newname = string.replace(newname, '%2C', '')
        if newname != oldname:
            devpath = d.getPrimaryUrlPath()
            print "Renaming %s to %s" % (oldname, newname)
            url = '/'.join([baseUrl, devpath])
            serv = ServerProxy( url )

Chmod the script and run it from your ZenHub server:

$ chmod 755
$ zendmd