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 )
110 },
111 )
112
113 security = ClassSecurityInfo()
114
115
116 - def __init__(self, id, serviceKeys=(), description=""):
122
123
130
131
133 """Return count of instances in this class.
134 """
135 return self.instances.countObjects()
136
137
139 """Return the full name of this service class.
140 """
141 return self.getPrimaryDmdId("Services", "serviceclasses")
142
143
157
170
172 """
173 index instances of this service class to ensure changes made on the
174 Service Class are reflected in the instances indexes
175 """
176 for inst in self.instances():
177 inst = inst.primaryAq()
178 inst.index_object()
179
180 security.declareProtected('Manage DMD', 'manage_editServiceClass')
181 - def manage_editServiceClass(self, name="", monitor=False, serviceKeys="",
182 port=0, description="", REQUEST=None):
208
209
211 ''' Called by Commandable.doCommand() to ascertain objects on which
212 a UserCommand should be executed.
213 '''
214 return self.instances()
215
216
219
220
221 InitializeClass(ServiceClass)
222