1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""IpService.py
15
16 IpService 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: IpService.py,v 1.10 2004/04/22 22:04:14 edahl Exp $"""
20
21 __version__ = "$Revision: 1.10 $"[11:-2]
22
23 from Globals import DTMLFile
24 from Globals import InitializeClass
25 from AccessControl import ClassSecurityInfo, Permissions
26
27 from Products.ZenRelations.RelSchema import *
28
29 from Service import Service
30 from Products.ZenModel.IpServiceClass import IpServiceClass
31
46
47 addIpService = DTMLFile('dtml/addIpService',globals())
48
49
52
53
55 """
56 IpService object
57 """
58
59 portal_type = meta_type = 'IpService'
60
61 protocols = ('tcp', 'udp')
62
63 ipaddresses = []
64 discoveryAgent = ""
65 port = 0
66 protocol = ""
67
68 collectors = ('zenstatus',)
69
70 _properties = (
71 {'id':'port', 'type':'int', 'mode':'', 'setter': 'setPort'},
72 {'id':'protocol', 'type':'string', 'mode':'', 'setter': 'setProtocol'},
73 {'id':'ipaddresses', 'type':'lines', 'mode':''},
74 {'id':'discoveryAgent', 'type':'string', 'mode':''},
75 )
76 _relations = Service._relations + (
77 ("os", ToOne(ToManyCont,"Products.ZenModel.OperatingSystem","ipservices")),
78 )
79
80 factory_type_information = (
81 {
82 'immediate_view' : 'ipServiceDetail',
83 'actions' :
84 (
85 { 'id' : 'status'
86 , 'name' : 'Status'
87 , 'action' : 'ipServiceDetail'
88 , 'permissions' : (
89 Permissions.view, )
90 },
91 { 'id' : 'manage'
92 , 'name' : 'Administration'
93 , 'action' : 'ipServiceManage'
94 , 'permissions' : ("Manage DMD",)
95 },
96 { 'id' : 'viewHistory'
97 , 'name' : 'Modifications'
98 , 'action' : 'viewHistory'
99 , 'permissions' : (
100 Permissions.view, )
101 },
102 )
103 },
104 )
105
106 security = ClassSecurityInfo()
107
108
110 """Return monitored state of ipservice.
111 If service only listens on 127.0.0.1 return false.
112 """
113 if self.cantMonitor(): return False
114 return super(IpService, self).monitored()
115
116
118 """Return true if IpService only listens on 127.0.0.1.
119 """
120 return len(self.ipaddresses) == 1 and "127.0.0.1" in self.ipaddresses
121
122
124 """Return some text that describes this component. Default is name.
125 """
126 return "%s-%d ips:%s" % (self.protocol, self.port,
127 ", ".join(self.ipaddresses))
128
129
142
143
146
147
150
151
153 """Return a dict like one set by IpServiceMap for services.
154 """
155 svc = self.serviceclass()
156 if svc:
157 return {'protocol': self.protocol, 'port': svc.port }
158 return {}
159
160
163
170
173
176
178 sc = self.serviceclass()
179 if sc: return sc.name
180
182 sc = self.serviceclass()
183 if sc: return sc.description
184
188
189
190 security.declareProtected('Manage DMD', 'manage_editService')
191 - def manage_editService(self, id=None,
192 status=None, ipaddresses=None,
193 protocol=None, port=None,
194 description=None,
195 monitor=False, severity=5, sendString="",
196 expectRegex="", REQUEST=None):
216
217
218 InitializeClass(IpService)
219