Thanks Chet!
Here's my new and improved version of the script you got me started on.
It should copy all the schedules that are attached to the action rule
specified,
and all the action rule properties of course.
Note: If there are already rules and/or maintenance windows with the same name,
this will essentially copy the settings from the source user's rules over top
of the destination user's existing rules.
-Scott
Code:
#!/usr/bin/env python
import Globals, sys
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit
dmd = ZenScriptBase(connect=True).dmd
if len(sys.argv) < 4:
print "Usage: %s <source_user> <destination_user> <alerting_rule>" %
(sys.argv[0])
sys.exit(1)
srcUser = getattr(dmd.ZenUsers, sys.argv[1], None)
if not srcUser:
print "%s is not a valid user." % (sys.argv[1])
sys.exit(2)
dstUser = getattr(dmd.ZenUsers, sys.argv[2], None)
if not dstUser:
print "%s is not a valid user." % (sys.argv[2])
sys.exit(3)
srcAlert = getattr(srcUser, sys.argv[3], None)
if not srcAlert:
print "%s is not a valid alerting rule." % (sys.argv[3])
sys.exit(4)
if not getattr(dstUser, sys.argv[3], None):
#the alert rule doesn't yet exist, create it
dstAlert = dstUser.manage_addActionRule(sys.argv[3])
dstAlert = getattr(dstUser, sys.argv[3], None)
for srcMntWin in srcAlert.windows():
if not getattr(dstAlert.windows, srcMntWin.id, None):
#maint window doesn't exist yet, create it
dstMntWin = dstAlert.manage_addActionRuleWindow(srcMntWin.id)
dstMntWin = getattr(dstAlert.windows, srcMntWin.id, None)
for thing in srcMntWin.propertyItems():
dstMntWin._setPropValue(thing[0], thing[1])
#for some reason, the enabled property doesn't get copied above...
dstMntWin.enabled = srcMntWin.enabled
#all the maintenance windows should be copied now
for thing in srcAlert.propertyItems():
dstAlert._setPropValue(thing[0], thing[1])
#all the alert properties should be copied now
commit()
-------------------- m2f --------------------
Read this topic online here:
http://community.zenoss.com/forums/viewtopic.php?p=25142#25142
-------------------- m2f --------------------
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users