ZenDMD Tip - Replace modeler plugin programmatically

From Zenoss Wiki
Revision as of 14:57, 20 November 2013 by Crouthamela (Talk | contribs)$7

(diff) ← Older revision | Approved revision (diff) | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Updating modeler plugins can be a hassle. Why not do it the easy way? The following DMD function allows one to search a list of devices and replace an old plugin with a new one. As the zenoss user on your Zenoss master, zendmd and paste the following code after filling in the plugins you wish to update.

oldPlugin="zenoss.snmp.RouteMap"
newPlugin="zenoss.snmp.NewRouteMap"
def replacePlugin(objs):
for obj in objs:
    if not obj.hasProperty('zCollectorPlugins'): continue
    if oldPlugin not in obj.zCollectorPlugins: continue
    print "Replacing plugin for %s." % obj.id
    obj.zCollectorPlugins = [ p for p in obj.zCollectorPlugins if p != oldPlugin ]
    commit()

Example usage:

replacePlugin(dmd.Devices.Network.Router.Cisco.getSubOrganizers())

and

replacePlugin(dmd.Devices.Network.Router.Cisco.getSubDevices())

Don't forget to

commit()