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 example = ""
48 sequence = 0
49
50 _properties = (
51 {'id':'name', 'type':'string', 'mode':'w'},
52 {'id':'regex', 'type':'string', 'mode':'w'},
53 {'id':'ignoreParameters', 'type':'boolean', 'mode':'w'},
54 {'id':'description', 'type':'text', 'mode':'w'},
55 {'id':'sequence', 'type':'int', 'mode':'w'},
56 {'id':'example', 'type':'string', 'mode':'w'},
57 )
58
59 _relations = ZenPackable._relations + (
60 ("instances", ToMany(ToOne, "Products.ZenModel.OSProcess", "osProcessClass")),
61 ("osProcessOrganizer",
62 ToOne(ToManyCont,"Products.ZenModel.OSProcessOrganizer","osProcessClasses")),
63 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
64 )
65
66
67 factory_type_information = (
68 {
69 'immediate_view' : 'osProcessClassStatus',
70 'actions' :
71 (
72 { 'id' : 'status'
73 , 'name' : 'Status'
74 , 'action' : 'osProcessClassStatus'
75 , 'permissions' : (
76 Permissions.view, )
77 },
78 { 'id' : 'edit'
79 , 'name' : 'Edit'
80 , 'action' : 'osProcessClassEdit'
81 , 'permissions' : ("Manage DMD", )
82 },
83 { 'id' : 'manage'
84 , 'name' : 'Administration'
85 , 'action' : 'osProcessClassManage'
86 , 'permissions' : ("Manage DMD",)
87 },
88 { 'id' : 'zProperties'
89 , 'name' : 'Configuration Properties'
90 , 'action' : 'zPropertyEdit'
91 , 'permissions' : ("Change Device",)
92 },
93 { 'id' : 'viewHistory'
94 , 'name' : 'Modifications'
95 , 'action' : 'viewHistory'
96 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
97 },
98 )
99 },
100 )
101
102 security = ClassSecurityInfo()
103
104
110
112 """Return the full name of this process class.
113 """
114 return self.getPrimaryDmdId("Processes", "osProcessClasses")
115
116
117 - def match(self, procKey):
118 """match procKey against our regex.
119 """
120 return re.search(self.regex, procKey)
121
122
124 """Return count of instances in this class.
125 """
126 return self.instances.countObjects()
127
128
129 security.declareProtected('Manage DMD', 'manage_editOSProcessClass')
130 - def manage_editOSProcessClass(self,
131 name="",
132 zMonitor=True,
133 zAlertOnRestart=False,
134 zFailSeverity=3,
135 regex="",
136 description="",
137 ignoreParameters=False,
138 REQUEST=None):
160
161
163 ''' Called by Commandable.doCommand() to ascertain objects on which
164 a UserCommand should be executed.
165 '''
166 return self.instances()
167
168
171
172
177
178
179 InitializeClass(OSProcessClass)
180