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 Acquisition import aq_base
21 from Commandable import Commandable
22 from Products.ZenRelations.RelSchema import *
23 from ZenPackable import ZenPackable
24
25 from ZenModelRM import ZenModelRM
26
27
34
35 addOSProcessClass = DTMLFile('dtml/addOSProcessClass',globals())
36
38 meta_type = "OSProcessClass"
39 dmdRootName = "Processes"
40 default_catalog = "processSearch"
41
42 name = ""
43 regex = ""
44 ignoreParameters = False
45 description = ""
46 sequence = 0
47
48 _properties = (
49 {'id':'name', 'type':'string', 'mode':'w'},
50 {'id':'regex', 'type':'string', 'mode':'w'},
51 {'id':'ignoreParameters', 'type':'boolean', 'mode':'w'},
52 {'id':'description', 'type':'text', 'mode':'w'},
53 {'id':'sequence', 'type':'int', 'mode':'w'},
54 )
55
56 _relations = ZenPackable._relations + (
57 ("instances", ToMany(ToOne, "Products.ZenModel.OSProcess", "osProcessClass")),
58 ("osProcessOrganizer",
59 ToOne(ToManyCont,"Products.ZenModel.OSProcessOrganizer","osProcessClasses")),
60 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
61 )
62
63
64 factory_type_information = (
65 {
66 'immediate_view' : 'osProcessClassStatus',
67 'actions' :
68 (
69 { 'id' : 'status'
70 , 'name' : 'Status'
71 , 'action' : 'osProcessClassStatus'
72 , 'permissions' : (
73 Permissions.view, )
74 },
75 { 'id' : 'edit'
76 , 'name' : 'Edit'
77 , 'action' : 'osProcessClassEdit'
78 , 'permissions' : ("Manage DMD", )
79 },
80 { 'id' : 'manage'
81 , 'name' : 'Administration'
82 , 'action' : 'osProcessClassManage'
83 , 'permissions' : ("Manage DMD",)
84 },
85 { 'id' : 'zproperties'
86 , 'name' : 'zProperties'
87 , 'action' : 'zPropertyEdit'
88 , 'permissions' : ("Change Device",)
89 },
90 { 'id' : 'viewHistory'
91 , 'name' : 'Modifications'
92 , 'action' : 'viewHistory'
93 , 'permissions' : (
94 Permissions.view, )
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')
153
154
156 ''' Called by Commandable.doCommand() to ascertain objects on which
157 a UserCommand should be executed.
158 '''
159 return self.instances()
160
161
164
165
170
171
172
173
174
175 InitializeClass(OSProcessClass)
176