1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""ServiceClass
15
16 The service classification class. default identifiers, screens,
17 and data collectors live here.
18
19 $Id: ServiceClass.py,v 1.9 2003/03/11 23:32:13 edahl Exp $"""
20
21 __version__ = "$Revision: 1.9 $"[11:-2]
22
23 from Globals import DTMLFile
24 from Globals import InitializeClass
25 from AccessControl import ClassSecurityInfo
26 from AccessControl import Permissions
27 from Acquisition import aq_base
28 from Commandable import Commandable
29 from ZenPackable import ZenPackable
30
31 from Products.ZenRelations.RelSchema import *
32
33 from ZenModelRM import ZenModelRM
34
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 )
65
66 _relations = ZenPackable._relations + (
67 ("instances", ToMany(ToOne, "Products.ZenModel.Service", "serviceclass")),
68 ("serviceorganizer",
69 ToOne(ToManyCont,"Products.ZenModel.ServiceOrganizer","serviceclasses")),
70 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
71 )
72
73
74 factory_type_information = (
75 {
76 'id' : 'ServiceClass',
77 'meta_type' : 'ServiceClass',
78 'icon' : 'ServiceClass.gif',
79 'product' : 'ZenModel',
80 'factory' : 'manage_addServiceClass',
81 'immediate_view' : 'serviceClassStatus',
82 'actions' :
83 (
84 { 'id' : 'status'
85 , 'name' : 'Status'
86 , 'action' : 'serviceClassStatus'
87 , 'permissions' : (
88 Permissions.view, )
89 },
90 { 'id' : 'edit'
91 , 'name' : 'Edit'
92 , 'action' : 'serviceClassEdit'
93 , 'permissions' : ("Manage DMD", )
94 },
95 { 'id' : 'manage'
96 , 'name' : 'Administration'
97 , 'action' : 'serviceClassManage'
98 , 'permissions' : ("Manage DMD",)
99 },
100 { 'id' : 'zproperties'
101 , 'name' : 'zProperties'
102 , 'action' : 'zPropertyEdit'
103 , 'permissions' : ("Change Device",)
104 },
105 { 'id' : 'viewHistory'
106 , 'name' : 'Modifications'
107 , 'action' : 'viewHistory'
108 , 'permissions' : (
109 Permissions.view, )
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
168
169 security.declareProtected('Manage DMD', 'manage_editServiceClass')
194
195
197 ''' Called by Commandable.doCommand() to ascertain objects on which
198 a UserCommand should be executed.
199 '''
200 return self.instances()
201
202
205
206
207 InitializeClass(ServiceClass)
208