1
2
3
4
5
6
7
8
9
10
11
12
13
14 import types
15 import logging
16 log = logging.getLogger("zen.OSProcessOrganizer")
17
18 from Globals import DTMLFile
19 from Globals import InitializeClass
20 from AccessControl import ClassSecurityInfo
21 from AccessControl import Permissions
22 from Products.ZenModel.ZenossSecurity import *
23 from Acquisition import aq_base
24 from Commandable import Commandable
25 from Products.ZenRelations.RelSchema import *
26 from ZenPackable import ZenPackable
27
28 from Organizer import Organizer
29 from OSProcessClass import OSProcessClass
30
38
39 addOSProcessOrganizer = DTMLFile('dtml/addOSProcessOrganizer',globals())
40
42 meta_type = "OSProcessOrganizer"
43 dmdRootName = "Processes"
44
45
46 description = ""
47
48 _properties = (
49 {'id':'description', 'type':'text', 'mode':'w'},
50 )
51
52 _relations = Organizer._relations + ZenPackable._relations + (
53 ("osProcessClasses", ToManyCont(
54 ToOne,"Products.ZenModel.OSProcessClass","osProcessOrganizer")),
55 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
56 )
57
58 factory_type_information = (
59 {
60 'immediate_view' : 'osProcessOrganizerOverview',
61 'actions' :
62 (
63 { 'id' : 'classes'
64 , 'name' : 'Classes'
65 , 'action' : 'osProcessOrganizerOverview'
66 , 'permissions' : (
67 Permissions.view, )
68 },
69 { 'id' : 'resequence'
70 , 'name' : 'Sequence'
71 , 'action' : 'osProcessResequence'
72 , 'permissions' : (
73 Permissions.view, )
74 },
75 { 'id' : 'manage'
76 , 'name' : 'Administration'
77 , 'action' : 'osProcessOrganizerManage'
78 , 'permissions' : ("Manage DMD",)
79 },
80 { 'id' : 'zproperties'
81 , 'name' : 'zProperties'
82 , 'action' : 'zPropertyEdit'
83 , 'permissions' : ("Change Device",)
84 },
85 { 'id' : 'viewHistory'
86 , 'name' : 'Modifications'
87 , 'action' : 'viewHistory'
88 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
89 },
90 )
91 },
92 )
93
94 security = ClassSecurityInfo()
95
101
102
104 """Return a list of hashs that define the screen tabs for this object.
105 [{'name':'Name','action':'template','selected':False},...]
106 """
107 tabs = Organizer.zentinelTabs(self, templateName)
108 if self.getPrimaryId() != '/zport/dmd/Processes':
109 tabs = [t for t in tabs if t['id'] != 'resequence']
110 return tabs
111
112
114 """Return generator that goes through all process classes.
115 """
116 for proc in self.osProcessClasses.objectValuesGen():
117 yield proc
118 for subgroup in self.children():
119 for proc in subgroup.getSubOSProcessClassesGen():
120 yield proc
121
122
124 '''Return list of the process classes sorted by sequence.
125 '''
126 def cmpProc(a, b):
127 return cmp(a.sequence, b.sequence)
128 procs = list(self.getSubOSProcessClassesGen())
129 procs.sort(cmpProc)
130 for i, p in enumerate(procs):
131 p.sequence = i
132 return procs
133
134
142
143
144 security.declareProtected(ZEN_ADD, 'manage_addOSProcessClass')
156
157
163
166
167
169 """Remove OSProcessClasses from an EventClass.
170 """
171 if not ids: return self()
172 if type(ids) == types.StringType: ids = (ids,)
173 for id in ids:
174 svc = self.osProcessClasses._getOb(id)
175 svc.setZenProperty("zMonitor", monitor)
176 if REQUEST: return self()
177
178
192
193
207
208
215
216
218 ''' Called by Commandable.doCommand() to ascertain objects on which
219 a UserCommand should be executed.
220 '''
221 targets = []
222 for osc in self.osProcessClasses():
223 targets += osc.getUserCommandTargets()
224 for org in self.children():
225 targets += org.getUserCommandTargets()
226 return targets
227
228
231
232
233 InitializeClass(OSProcessOrganizer)
234