Oct 5, 2009 4:12 PM
Copy EventViews
-
Like (0)
Has anyone figured how to copy event views from user to user or group to group? I'd think it would be possible using the same manner used in copyDash.py and CopyAlert.py. Any idea? Thanks!
CopyAlert.py - docs/DOC-2534 {
#!/usr/bin/env python
import sys
import Globals
from transaction import commit
from Acquisition import aq_base
from copy import copy
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
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)
sourceUser = getattr(dmd.ZenUsers, sys.argv[1], None)
if not sourceUser:
print "%s is not a valid user." % (sys.argv[1],)
sys.exit(2)
destUser = getattr(dmd.ZenUsers, sys.argv[2], None)
if not destUser:
print "%s is not a valid user." % (sys.argv[2],)
sys.exit(3)
alert_rule = getattr(sourceUser, sys.argv[3], None)
if not alert_rule:
print "%s is not a valid alerting rule." % (sys.argv[3])
sys.exit(4)
ar_copy = copy(aq_base(alert_rule))
destUser._setObject(ar_copy.id, ar_copy)
}
You can do this in the exact similar way; (just by sed'ing the above code, the ultimate code will look like:)
#!/usr/bin/env python
import sys
import Globals
from transaction import commit
from Acquisition import aq_base
from copy import copy
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
dmd = ZenScriptBase(connect=True).dmd
if len(sys.argv) < 4:
print "Usage: %s <source_user> <destination_user> <event_view>" % (
sys.argv[0],)
sys.exit(1)
sourceUser = getattr(dmd.ZenUsers, sys.argv[1], None)
if not sourceUser:
print "%s is not a valid user." % (sys.argv[1],)
sys.exit(2)
destUser = getattr(dmd.ZenUsers, sys.argv[2], None)
if not destUser:
print "%s is not a valid user." % (sys.argv[2],)
sys.exit(3)
event_view = getattr(sourceUser, sys.argv[3], None)
if not event_view:
print "%s is not a valid event view." % (sys.argv[3])
sys.exit(4)
ev_copy = copy(aq_base(event_view))
destUser._setObject(ev_copy.id, ev_copy)
commit()
chitambira:
Thank you, that works perfectly. I had edited it before in attempt to do this, I must have typo'd something. Thanks again!
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||