1
2
3
4
5
6
7
8
9
10
11 __doc__="""Service.py
12
13 Service is a function provided by computer (like a server). it
14 is defined by a protocol type (udp/tcp) and a port number.
15
16 $Id: Service.py,v 1.15 2003/03/11 23:32:13 edahl Exp $"""
17
18 __version__ = "$Revision: 1.15 $"[11:-2]
19
20 import Globals
21 from Acquisition import aq_chain
22 from AccessControl import ClassSecurityInfo
23 from Commandable import Commandable
24
25 from Products.CMFCore.utils import getToolByName
26 from Products.ZenRelations.RelSchema import *
27 from Products.ZenWidgets import messaging
28
29 from EventView import EventView
30 from OSComponent import OSComponent
31 from ZenPackable import ZenPackable
32
33 -class Service(OSComponent, Commandable, ZenPackable):
34 """
35 Service class
36 """
37 portal_type = meta_type = 'Service'
38
39 _relations = OSComponent._relations + ZenPackable._relations + (
40 ("serviceclass", ToOne(ToMany,"Products.ZenModel.ServiceClass","instances")),
41 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
42 )
43
44 security = ClassSecurityInfo()
45
47 """
48 Return tuple (manageIp, name) for this service to uniquely id it.
49 """
50 return (self.getManageIp(), self.name())
51
53 """
54 Return the name of this service. (short name for net stop/start).
55 """
56 svccl = self.serviceclass()
57 if svccl: return svccl.name
58 return ""
59
60 title = name
61
63 """
64 Should this service be monitored or not. Use ServiceClass aq path.
65 """
66 return self.monitor and self.getAqProperty("zMonitor")
67
68
70 """
71 Returns the same as "monitored" but from the catalog instead of from
72 the service class.
73 """
74 try:
75 index_dict = self.primaryAq().componentSearch.getIndexDataForUID(
76 self.getPrimaryId())
77 except KeyError:
78 return self.monitored()
79
80 return bool(index_dict.get('monitored', self.monitored()))
81
82
92
94 """
95 Return a list of tuples with the possible severities
96 """
97 return self.ZenEventManager.getSeverities()
98
99
101 """
102 Return the severity for this service when it fails.
103 """
104 return self.getAqProperty("zFailSeverity")
105
106
108 """
109 Return a string representation of zFailSeverity
110 """
111 return self.ZenEventManager.severities[self.getAqProperty("zFailSeverity")]
112
113
124
125
138
139
141 """
142 Return the ServiceClass for this service.
143 """
144 return self.serviceclass()
145
146
147 security.declareProtected('Manage DMD', 'manage_editService')
164
165
167 '''
168 Called by Commandable.doCommand() to ascertain objects on which
169 a UserCommand should be executed.
170 '''
171 return [self]
172
173
182
183
185 """
186 Setup the aq chain as appropriate for the execution of a UserCommand
187 """
188 chain = aq_chain(self.getClassObject().primaryAq())
189 chain.insert(0, self)
190 return chain
191
192
194 """
195 Return the url where UserCommands are viewed for this object
196 """
197 return self.getPrimaryUrlPath() + '/serviceManage'
198