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 from Products.ZenEvents.ZenEventClasses import Change_Add,Change_Remove,Change_Set
27
29 """
30 DeviceComponent is a mix-in class for all components of a device.
31 These include LogicalComponent, Software, and Hardware.
32 """
33 event_key = "Component"
34
35 default_catalog = "componentSearch"
36
37 collectors = ('zenperfsnmp', 'zencommand', 'zenwinperf')
38
39 security = ClassSecurityInfo()
40
41
48 hostname = getParentDeviceName
49
51 """return the url of this component's device"""
52 url = ""
53 dev = self.device()
54 if dev: url = dev.absolute_url()
55 return url
56
57
59 """Return the name of this component. Default is id.
60 """
61 return self.id
62
63
65 """Return the monitored status of this component. Default is False.
66 """
67 return self.monitor
68
69
71 """Return list of collectors that want to monitor this component
72 """
73 return self.collectors
74
75
77 """Return some text that describes this component. Default is name.
78 """
79 return self.name()
80
81
91
92
95
96
98 """Return the manageIP of the device of this component.
99 """
100 dev = self.device()
101 if dev: return dev.getManageIp()
102 return ""
103
104
112
113
115 import warnings
116 warnings.warn('anything named nagios is deprecated', DeprecationWarning)
117
118
120 """Get a property from ourself if it exsits then try serviceclass path.
121 """
122 if getattr(aq_base(self), prop, None) is not None:
123 return getattr(self, prop)
124 classObj = self.getClassObject()
125 if classObj:
126 classObj = classObj.primaryAq()
127 return getattr(classObj, prop)
128
129
131 """Set a local prop if nessesaary on this service.
132 """
133 classObj = self.getClassObject()
134 if not classObj: return
135 classObj = classObj.primaryAq()
136 svcval = getattr(classObj, prop)
137 locval = getattr(aq_base(self),prop,None)
138 msg = ""
139 if svcval == value and locval is not None:
140 self._delProperty(prop)
141 msg = "Removed local %s" % prop
142 elif svcval != value and locval is None:
143 self._setProperty(prop, value, type=type)
144 msg = "Set local %s" % prop
145 elif locval is not None and locval != value:
146 setattr(self, prop, value)
147 msg = "Update local %s" % prop
148 return msg
149
150
152 """If you are going to use acquisition up different class path
153 override this.
154 """
155 return self.device()
156
157
164
165
170
171
179
180 InitializeClass(DeviceComponent)
181