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.ZenRelations.RelSchema import *
29 from Products.ZenWidgets import messaging
30
31 from OSComponent import OSComponent
32 from ZenPackable import ZenPackable
33
34 -class Service(OSComponent, Commandable, ZenPackable):
35 """
36 Service class
37 """
38 portal_type = meta_type = 'Service'
39
40 _relations = OSComponent._relations + ZenPackable._relations + (
41 ("serviceclass", ToOne(ToMany,"Products.ZenModel.ServiceClass","instances")),
42 ('userCommands', ToManyCont(ToOne, 'Products.ZenModel.UserCommand', 'commandable')),
43 )
44
45 security = ClassSecurityInfo()
46
48 """
49 Return tuple (manageIp, name) for this service to uniquely id it.
50 """
51 return (self.getManageIp(), self.name())
52
53
55 """
56 Return the name of this service. (short name for net stop/start).
57 """
58 svccl = self.serviceclass()
59 if svccl: return svccl.name
60 return ""
61
62
64 """
65 Should this service be monitored or not. Use ServiceClass aq path.
66 """
67 return self.monitor and self.getAqProperty("zMonitor")
68
69
71 """
72 Return a list of tuples with the possible severities
73 """
74 return self.ZenEventManager.getSeverities()
75
76
78 """
79 Return the severity for this service when it fails.
80 """
81 return self.getAqProperty("zFailSeverity")
82
83
85 """
86 Return a string representation of zFailSeverity
87 """
88 return self.ZenEventManager.severities[self.getAqProperty("zFailSeverity")]
89
90
101
102
115
116
118 """
119 Return the ServiceClass for this service.
120 """
121 return self.serviceclass()
122
123
124 security.declareProtected('Manage DMD', 'manage_editService')
141
142
144 '''
145 Called by Commandable.doCommand() to ascertain objects on which
146 a UserCommand should be executed.
147 '''
148 return [self]
149
150
159
160
162 """
163 Setup the aq chain as appropriate for the execution of a UserCommand
164 """
165 chain = aq_chain(self.getClassObject().primaryAq())
166 chain.insert(0, self)
167 return chain
168
169
171 """
172 Return the url where UserCommands are viewed for this object
173 """
174 return self.getPrimaryUrlPath() + '/serviceManage'
175