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