1
2
3
4
5
6
7
8
9
10
11
12
13
14 from AccessControl import ClassSecurityInfo
15 from Acquisition import aq_parent
16 from Products.ZenModel.ZenModelRM import ZenModelRM
17 from Products.ZenModel.Commandable import Commandable
18 from Products.ZenModel.ZenPackable import ZenPackable
19 from Products.ZenRelations.RelSchema import *
20 from Globals import InitializeClass
21 from EventFilter import EventFilter
22
23 -class EventCommand(ZenModelRM, Commandable, EventFilter, ZenPackable):
24
25 where = ''
26 command = ''
27 clearCommand = ''
28 enabled = False
29 delay = 0
30 repeatTime = 0
31
32 _properties = ZenModelRM._properties + (
33 {'id':'command', 'type':'string', 'mode':'w'},
34 {'id':'clearCommand', 'type':'string', 'mode':'w'},
35 {'id':'where', 'type':'string', 'mode':'w'},
36 {'id':'defaultTimeout', 'type':'int', 'mode':'w'},
37 {'id':'enabled', 'type':'boolean', 'mode':'w'},
38 {'id':'delay', 'type':'int', 'mode':'w'},
39 {'id':'repeatTime', 'type':'int', 'mode':'w'},
40 )
41
42 _relations = ZenPackable._relations + (
43 ("eventManager", ToOne(ToManyCont, "Products.ZenEvents.EventManagerBase", "commands")),
44 )
45
46 factory_type_information = (
47 {
48 'immediate_view' : 'editEventCommand',
49 'actions' :
50 (
51 { 'id' : 'edit'
52 , 'name' : 'Edit'
53 , 'action' : 'editEventCommand'
54 , 'permissions' : ( "Manage DMD", )
55 },
56 )
57 },
58 )
59
60 security = ClassSecurityInfo()
61
64
67
69 """Return the breadcrumb links for this object add ActionRules list.
70 [('url','id'), ...]
71 """
72 crumbs = super(EventCommand, self).breadCrumbs(terminator)
73 url = aq_parent(self).absolute_url_path() + "/listEventCommands"
74 crumbs.insert(-1,(url,'Event Commands'))
75 return crumbs
76
77
79 """Clear state in alert_state before we are deleted.
80 """
81 self._clearAlertState()
82
83
85 """Return sql where to select alert_state data for this event.
86 """
87 return "userid = '' and rule = '%s'" % (self.id)
88
90 """Clear state in alert_state before we are deleted.
91 """
92 zem = self.dmd.ZenEventManager
93 conn = zem.connect()
94 try:
95 delcmd = "delete from alert_state where %s" % self.sqlwhere()
96 curs = conn.cursor()
97 curs.execute(delcmd)
98 finally: zem.close(conn)
99
100
101 security.declareProtected('Manage EventManager', 'manage_editEventCommand')
110
111
112 InitializeClass(EventCommand)
113