1
2
3
4
5
6
7
8
9
10
11
12
13 __doc__="""ServiceClass
14
15 The service classification class. default identifiers, screens,
16 and data collectors live here.
17
18 $Id: ServiceClass.py,v 1.9 2003/03/11 23:32:13 edahl Exp $"""
19
20 __version__ = "$Revision: 1.9 $"[11:-2]
21
22 from Globals import DTMLFile
23 from Globals import InitializeClass
24 from AccessControl import ClassSecurityInfo
25 from AccessControl import Permissions
26 from Products.ZenModel.ZenossSecurity import *
27 from Commandable import Commandable
28 from ZenPackable import ZenPackable
29
30 from Products.ZenRelations.RelSchema import *
31 from Products.ZenRelations.ZenPropertyManager import iszprop
32 from Products.ZenWidgets import messaging
33
34 from ZenModelRM import ZenModelRM
35
47
48 addServiceClass = DTMLFile('dtml/addServiceClass',globals())
49
51 meta_type = "ServiceClass"
52 dmdRootName = "Services"
53 default_catalog = "serviceSearch"
54
55 name = ""
56 serviceKeys = ()
57 description = ""
58 port = 0
59
60 _properties = (
61 {'id':'name', 'type':'string', 'mode':'w'},
62 {'id':'serviceKeys', 'type':'lines', 'mode':'w'},
63 {'id':'description', 'type':'text', 'mode':'w'},
64 {'id':'port', 'type':'int', 'mode':'w'},
65 )
66
67 _relations = ZenPackable._relations + (
68 ("instances", ToMany(ToOne, "Products.ZenModel.Service", "serviceclass")),
69 ("serviceorganizer",
70 ToOne(ToManyCont,"Products.ZenModel.ServiceOrganizer","serviceclasses")),
71 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
72 )
73
74
75 factory_type_information = (
76 {
77 'id' : 'ServiceClass',
78 'meta_type' : 'ServiceClass',
79 'icon' : 'ServiceClass.gif',
80 'product' : 'ZenModel',
81 'factory' : 'manage_addServiceClass',
82 'immediate_view' : 'serviceClassStatus',
83 'actions' :
84 (
85 { 'id' : 'status'
86 , 'name' : 'Status'
87 , 'action' : 'serviceClassStatus'
88 , 'permissions' : (
89 Permissions.view, )
90 },
91 { 'id' : 'edit'
92 , 'name' : 'Edit'
93 , 'action' : 'serviceClassEdit'
94 , 'permissions' : ("Manage DMD", )
95 },
96 { 'id' : 'manage'
97 , 'name' : 'Administration'
98 , 'action' : 'serviceClassManage'
99 , 'permissions' : ("Manage DMD",)
100 },
101 { 'id' : 'zproperties'
102 , 'name' : 'zProperties'
103 , 'action' : 'zPropertyEdit'
104 , 'permissions' : ("Change Device",)
105 },
106 { 'id' : 'viewHistory'
107 , 'name' : 'Modifications'
108 , 'action' : 'viewHistory'
109 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
110 },
111 )
112 },
113 )
114
115 security = ClassSecurityInfo()
116
117
118 - def __init__(self, id, serviceKeys=(), description=""):
124
125
132
133
135 """Return count of instances in this class.
136 """
137 return self.instances.countObjects()
138
139
141 """Return the full name of this service class.
142 """
143 return self.getPrimaryDmdId("Services", "serviceclasses")
144
145
152
153
158
159
167
181
194
196 """
197 index instances of this service class to ensure changes made on the
198 Service Class are reflected in the instances indexes
199 """
200 for inst in self.instances():
201 inst = inst.primaryAq()
202 inst.index_object()
203
204 security.declareProtected('Manage DMD', 'manage_editServiceClass')
205 - def manage_editServiceClass(self, name="", monitor=False, serviceKeys="",
206 port=0, description="", REQUEST=None):
232
233
235 ''' Called by Commandable.doCommand() to ascertain objects on which
236 a UserCommand should be executed.
237 '''
238 return self.instances()
239
240
243
244
245 InitializeClass(ServiceClass)
246