1
2
3
4
5
6
7
8
9
10
11 __doc__="""ServiceClass
12
13 The service classification class. default identifiers, screens,
14 and data collectors live here.
15
16 $Id: ServiceClass.py,v 1.9 2003/03/11 23:32:13 edahl Exp $"""
17
18 __version__ = "$Revision: 1.9 $"[11:-2]
19
20 from Globals import DTMLFile
21 from Globals import InitializeClass
22 from AccessControl import ClassSecurityInfo
23 from AccessControl import Permissions
24 import zope.interface
25 from Products.ZenModel.ZenossSecurity import *
26 from Products.ZenModel.interfaces import IIndexed
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 zope.interface.implements(IIndexed)
52 meta_type = "ServiceClass"
53 dmdRootName = "Services"
54 default_catalog = "serviceSearch"
55
56 name = ""
57 serviceKeys = ()
58 description = ""
59 port = 0
60
61 _properties = (
62 {'id':'name', 'type':'string', 'mode':'w'},
63 {'id':'serviceKeys', 'type':'lines', 'mode':'w'},
64 {'id':'description', 'type':'text', 'mode':'w'},
65 {'id':'port', 'type':'int', 'mode':'w'},
66 )
67
68 _relations = ZenPackable._relations + (
69 ("instances", ToMany(ToOne, "Products.ZenModel.Service", "serviceclass")),
70 ("serviceorganizer",
71 ToOne(ToManyCont,"Products.ZenModel.ServiceOrganizer","serviceclasses")),
72 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
73 )
74
75
76 factory_type_information = (
77 {
78 'id' : 'ServiceClass',
79 'meta_type' : 'ServiceClass',
80 'icon' : 'ServiceClass.gif',
81 'product' : 'ZenModel',
82 'factory' : 'manage_addServiceClass',
83 'immediate_view' : 'serviceClassStatus',
84 'actions' :
85 (
86 { 'id' : 'status'
87 , 'name' : 'Status'
88 , 'action' : 'serviceClassStatus'
89 , 'permissions' : (
90 Permissions.view, )
91 },
92 { 'id' : 'edit'
93 , 'name' : 'Edit'
94 , 'action' : 'serviceClassEdit'
95 , 'permissions' : ("Manage DMD", )
96 },
97 { 'id' : 'manage'
98 , 'name' : 'Administration'
99 , 'action' : 'serviceClassManage'
100 , 'permissions' : ("Manage DMD",)
101 },
102 { 'id' : 'zProperties'
103 , 'name' : 'Configuration Properties'
104 , 'action' : 'zPropertyEdit'
105 , 'permissions' : ("Change Device",)
106 },
107 )
108 },
109 )
110
111 security = ClassSecurityInfo()
112
113
114 - def __init__(self, id, serviceKeys=(), description=""):
120
121
128
129
131 """Return count of instances in this class.
132 """
133 return self.instances.countObjects()
134
135
137 """Return the full name of this service class.
138 """
139 return self.getPrimaryDmdId("Services", "serviceclasses")
140
141
155
168
170 """
171 index instances of this service class to ensure changes made on the
172 Service Class are reflected in the instances indexes
173 """
174 for inst in self.instances():
175 inst = inst.primaryAq()
176 inst.index_object()
177
178 security.declareProtected('Manage DMD', 'manage_editServiceClass')
179 - def manage_editServiceClass(self, name="", monitor=False, serviceKeys="",
180 port=0, description="", REQUEST=None):
206
207
209 ''' Called by Commandable.doCommand() to ascertain objects on which
210 a UserCommand should be executed.
211 '''
212 return self.instances()
213
214
217
218
219 InitializeClass(ServiceClass)
220