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