1
2
3
4
5
6
7
8
9
10
11
12
13
14 import re
15
16 from Globals import DTMLFile
17 from Globals import InitializeClass
18 from AccessControl import ClassSecurityInfo
19 from AccessControl import Permissions
20 from Products.ZenModel.ZenossSecurity import *
21 from Commandable import Commandable
22 from Products.ZenRelations.RelSchema import *
23 from Products.ZenWidgets import messaging
24 from ZenPackable import ZenPackable
25
26 from ZenModelRM import ZenModelRM
27
28
35
36 addOSProcessClass = DTMLFile('dtml/addOSProcessClass',globals())
37
39 meta_type = "OSProcessClass"
40 dmdRootName = "Processes"
41 default_catalog = "processSearch"
42
43 name = ""
44 regex = ""
45 ignoreParameters = False
46 description = ""
47 sequence = 0
48
49 _properties = (
50 {'id':'name', 'type':'string', 'mode':'w'},
51 {'id':'regex', 'type':'string', 'mode':'w'},
52 {'id':'ignoreParameters', 'type':'boolean', 'mode':'w'},
53 {'id':'description', 'type':'text', 'mode':'w'},
54 {'id':'sequence', 'type':'int', 'mode':'w'},
55 )
56
57 _relations = ZenPackable._relations + (
58 ("instances", ToMany(ToOne, "Products.ZenModel.OSProcess", "osProcessClass")),
59 ("osProcessOrganizer",
60 ToOne(ToManyCont,"Products.ZenModel.OSProcessOrganizer","osProcessClasses")),
61 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
62 )
63
64
65 factory_type_information = (
66 {
67 'immediate_view' : 'osProcessClassStatus',
68 'actions' :
69 (
70 { 'id' : 'status'
71 , 'name' : 'Status'
72 , 'action' : 'osProcessClassStatus'
73 , 'permissions' : (
74 Permissions.view, )
75 },
76 { 'id' : 'edit'
77 , 'name' : 'Edit'
78 , 'action' : 'osProcessClassEdit'
79 , 'permissions' : ("Manage DMD", )
80 },
81 { 'id' : 'manage'
82 , 'name' : 'Administration'
83 , 'action' : 'osProcessClassManage'
84 , 'permissions' : ("Manage DMD",)
85 },
86 { 'id' : 'zproperties'
87 , 'name' : 'zProperties'
88 , 'action' : 'zPropertyEdit'
89 , 'permissions' : ("Change Device",)
90 },
91 { 'id' : 'viewHistory'
92 , 'name' : 'Modifications'
93 , 'action' : 'viewHistory'
94 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
95 },
96 )
97 },
98 )
99
100 security = ClassSecurityInfo()
101
102
107
108
110 """Return the full name of this process class.
111 """
112 return self.getPrimaryDmdId("Processes", "osProcessClasses")
113
114
115 - def match(self, procKey):
116 """match procKey against our regex.
117 """
118 return re.search(self.regex, procKey)
119
120
122 """Return count of instances in this class.
123 """
124 return self.instances.countObjects()
125
126
127 security.declareProtected('Manage DMD', 'manage_editOSProcessClass')
128 - def manage_editOSProcessClass(self,
129 name="",
130 zMonitor=True,
131 zAlertOnRestart=False,
132 zFailSeverity=3,
133 regex="",
134 description="",
135 ignoreParameters=False,
136 REQUEST=None):
158
159
161 ''' Called by Commandable.doCommand() to ascertain objects on which
162 a UserCommand should be executed.
163 '''
164 return self.instances()
165
166
169
170
175
176
177
178
179
180 InitializeClass(OSProcessClass)
181