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 import zope.interface
27 from Products.ZenModel.ZenossSecurity import *
28 from Products.ZenModel.interfaces import IIndexed
29 from Commandable import Commandable
30 from ZenPackable import ZenPackable
31
32 from Products.ZenRelations.RelSchema import *
33 from Products.ZenRelations.ZenPropertyManager import iszprop
34 from Products.ZenWidgets import messaging
35
36 from ZenModelRM import ZenModelRM
37
49
50 addServiceClass = DTMLFile('dtml/addServiceClass',globals())
51
53 zope.interface.implements(IIndexed)
54 meta_type = "ServiceClass"
55 dmdRootName = "Services"
56 default_catalog = "serviceSearch"
57
58 name = ""
59 serviceKeys = ()
60 description = ""
61 port = 0
62
63 _properties = (
64 {'id':'name', 'type':'string', 'mode':'w'},
65 {'id':'serviceKeys', 'type':'lines', 'mode':'w'},
66 {'id':'description', 'type':'text', 'mode':'w'},
67 {'id':'port', 'type':'int', 'mode':'w'},
68 )
69
70 _relations = ZenPackable._relations + (
71 ("instances", ToMany(ToOne, "Products.ZenModel.Service", "serviceclass")),
72 ("serviceorganizer",
73 ToOne(ToManyCont,"Products.ZenModel.ServiceOrganizer","serviceclasses")),
74 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
75 )
76
77
78 factory_type_information = (
79 {
80 'id' : 'ServiceClass',
81 'meta_type' : 'ServiceClass',
82 'icon' : 'ServiceClass.gif',
83 'product' : 'ZenModel',
84 'factory' : 'manage_addServiceClass',
85 'immediate_view' : 'serviceClassStatus',
86 'actions' :
87 (
88 { 'id' : 'status'
89 , 'name' : 'Status'
90 , 'action' : 'serviceClassStatus'
91 , 'permissions' : (
92 Permissions.view, )
93 },
94 { 'id' : 'edit'
95 , 'name' : 'Edit'
96 , 'action' : 'serviceClassEdit'
97 , 'permissions' : ("Manage DMD", )
98 },
99 { 'id' : 'manage'
100 , 'name' : 'Administration'
101 , 'action' : 'serviceClassManage'
102 , 'permissions' : ("Manage DMD",)
103 },
104 { 'id' : 'zProperties'
105 , 'name' : 'Configuration Properties'
106 , 'action' : 'zPropertyEdit'
107 , 'permissions' : ("Change Device",)
108 },
109 { 'id' : 'viewHistory'
110 , 'name' : 'Modifications'
111 , 'action' : 'viewHistory'
112 , 'permissions' : (ZEN_VIEW_MODIFICATIONS,)
113 },
114 )
115 },
116 )
117
118 security = ClassSecurityInfo()
119
120
121 - def __init__(self, id, serviceKeys=(), description=""):
127
128
135
136
138 """Return count of instances in this class.
139 """
140 return self.instances.countObjects()
141
142
144 """Return the full name of this service class.
145 """
146 return self.getPrimaryDmdId("Services", "serviceclasses")
147
148
162
175
177 """
178 index instances of this service class to ensure changes made on the
179 Service Class are reflected in the instances indexes
180 """
181 for inst in self.instances():
182 inst = inst.primaryAq()
183 inst.index_object()
184
185 security.declareProtected('Manage DMD', 'manage_editServiceClass')
186 - def manage_editServiceClass(self, name="", monitor=False, serviceKeys="",
187 port=0, description="", REQUEST=None):
213
214
216 ''' Called by Commandable.doCommand() to ascertain objects on which
217 a UserCommand should be executed.
218 '''
219 return self.instances()
220
221
224
225
226 InitializeClass(ServiceClass)
227