1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""DeviceComponent
15
16 All device components inherit from this class
17
18 $Id: DeviceComponent.py,v 1.1 2004/04/06 21:05:03 edahl Exp $"""
19
20 __version__ = "$Revision: 1.1 $"[11:-2]
21
22 from Globals import InitializeClass
23 from AccessControl import ClassSecurityInfo
24 from Acquisition import aq_base
25 from Lockable import Lockable
26
28 """
29 DeviceComponent is a mix-in class for all components of a device.
30 These include LogicalComponent, Software, and Hardware.
31 """
32 __pychecker__='no-override'
33 event_key = "Component"
34
35 default_catalog = "componentSearch"
36
37 collectors = ('zenperfsnmp', 'zencommand', 'zenwinperf')
38
39 security = ClassSecurityInfo()
40
41 perfmonInstance = None
42
51 hostname = getParentDeviceName
52
53
55 """
56 Return the url of this component's device
57 """
58 url = ""
59 dev = self.device()
60 if dev: url = dev.absolute_url()
61 return url
62
63
65 """
66 Return the name of this component. Default is id.
67 """
68 return self.id
69
70
72 """
73 Return the monitored status of this component. Default is False.
74 """
75 return self.monitor
76
77
79 """
80 Return list of collectors that want to monitor this component
81 """
82 return self.collectors
83
84
86 """
87 Return some text that describes this component. Default is name.
88 """
89 return self.name()
90
91
102
103
105 """
106 Return a text representation of this component's status
107 """
108 return self.convertStatus(self.getStatus(statClass))
109
110
112 """
113 Return the manageIP of the device of this component.
114 """
115 dev = self.device()
116 if dev: return dev.getManageIp()
117 return ""
118
119
121 import warnings
122 warnings.warn('anything named nagios is deprecated', DeprecationWarning)
123
124
126 """
127 Get a property from ourself if it exsits then try serviceclass path.
128 """
129 if getattr(aq_base(self), prop, None) is not None:
130 return getattr(self, prop)
131 classObj = self.getClassObject()
132 if classObj:
133 classObj = classObj.primaryAq()
134 return getattr(classObj, prop)
135
136
138 """
139 Set a local prop if nessesaary on this service.
140 """
141 classObj = self.getClassObject()
142 if not classObj: return
143 classObj = classObj.primaryAq()
144 svcval = getattr(classObj, prop)
145 locval = getattr(aq_base(self),prop,None)
146 msg = ""
147 if svcval == value and locval is not None:
148 self._delProperty(prop)
149 msg = "Removed local %s" % prop
150 elif svcval != value and locval is None:
151 self._setProperty(prop, value, type=type)
152 msg = "Set local %s" % prop
153 elif locval is not None and locval != value:
154 self._updateProperty(prop, value)
155 msg = "Update local %s" % prop
156 return msg
157
158
160 """
161 If you are going to use acquisition up different class path
162 override this.
163 """
164 return self.device()
165
166
167 - def getRRDContextData(self, context):
168 context['comp'] = self
169 context['compId'] = self.id
170 context['compName'] = self.name()
171 if self.device():
172 context['dev'] = self.device()
173 context['devId'] = self.device().id
174
175
182
183
190
191
199
201 """Test if automatic creation (and anchoring into a model) is
202 appropriate for this object. Lets us ignore detectable gunk
203 that's not very interesting to model, like most processes, and
204 loopback network devices, CDROM file systems, etc.
205
206 Returns False if the object should not be added.
207
208 The object will have its full acquisition path, but will not
209 have been added to the database.
210 """
211 return True
212
213 InitializeClass(DeviceComponent)
214