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 )
94 },
95 )
96
97 security = ClassSecurityInfo()
98
99
105
107 """Return the full name of this process class.
108 """
109 return self.getPrimaryDmdId("Processes", "osProcessClasses")
110
111
112 - def match(self, procKey):
113 """match procKey against our regex.
114 """
115 return re.search(self.regex, procKey)
116
117
119 """Return count of instances in this class.
120 """
121 return self.instances.countObjects()
122
123
124 security.declareProtected('Manage DMD', 'manage_editOSProcessClass')
125 - def manage_editOSProcessClass(self,
126 name="",
127 zMonitor=True,
128 zAlertOnRestart=False,
129 zFailSeverity=3,
130 regex="",
131 description="",
132 ignoreParameters=False,
133 REQUEST=None):
155
156
158 ''' Called by Commandable.doCommand() to ascertain objects on which
159 a UserCommand should be executed.
160 '''
161 return self.instances()
162
163
166
167
172
173
174 InitializeClass(OSProcessClass)
175