1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 __doc__="""MonitorClass
16
17 Organizes Monitors
18
19 $Id: MonitorClass.py,v 1.11 2004/04/09 00:34:39 edahl Exp $"""
20
21 __version__ = "$Revision$"[11:-2]
22
23 from Globals import DTMLFile
24 from Globals import InitializeClass
25 from AccessControl import ClassSecurityInfo
26 from AccessControl import Permissions as permissions
27 from Acquisition import aq_base
28 from OFS.Folder import Folder
29 from Products.ZenUtils.Utils import checkClass
30 from ZenModelRM import ZenModelRM
31 from Products.ZenWidgets import messaging
32
33 from RRDTemplate import RRDTemplate
34 from TemplateContainer import TemplateContainer
35
43
44 addMonitorClass = DTMLFile('dtml/addMonitorClass',globals())
45
46
48
49 meta_type = "MonitorClass"
50 sub_class = 'MonitorClass'
51 dmdRootName = 'Monitors'
52
53 _properties = (
54 {'id':'title', 'type':'string', 'mode':'w'},
55 {'id':'sub_class', 'type':'string', 'mode':'w'},
56 {'id':'sub_meta_types', 'type':'lines', 'mode':'w'},
57 )
58
59 factory_type_information = (
60 {
61 'id' : 'MonitorClass',
62 'meta_type' : meta_type,
63 'description' : "Monitor Class",
64 'icon' : 'Classification_icon.gif',
65 'product' : 'ZenModel',
66 'factory' : 'manage_addMonitorClass',
67 'immediate_view' : 'monitorList',
68 'actions' :
69 (
70 { 'id' : 'view'
71 , 'name' : 'View'
72 , 'action' : 'monitorList'
73 , 'permissions' : (
74 permissions.view, )
75 , 'visible' : 0
76 },
77 )
78 },
79 )
80
81 security = ClassSecurityInfo()
82 _relations = TemplateContainer._relations
83
84 - def __init__(self, id, title=None, buildRelations=True):
86
87
90
91
100
101
108
109
111 """get contained objects that are sub classes of sub_class"""
112 retdata = []
113 for obj in self.objectValues():
114 if checkClass(obj.__class__, self.sub_class):
115 retdata.append(obj)
116 return retdata
117
118
120 'Add an object of sub_class, from a module of the same name'
121 msg = ''
122 if isinstance(ids, basestring):
123 ids = (ids,)
124 child = self._getOb(submon, self)
125 if ids:
126 if len(ids) < len(child._objects):
127 num = 0
128 for id in ids:
129 if child.hasObject(id):
130 child._delObject(id)
131 num += 1
132 messaging.IMessageSender(self).sendToBrowser(
133 'Collectors Deleted',
134 'Deleted collectors: %s' % (', '.join(ids))
135 )
136 else:
137 messaging.IMessageSender(self).sendToBrowser(
138 'Error',
139 'You must have at least one collector.',
140 priority=messaging.WARNING
141 )
142 else:
143 messaging.IMessageSender(self).sendToBrowser(
144 'Error',
145 'No collectors were selected.',
146 priority=messaging.WARNING
147 )
148 if REQUEST:
149 return self.callZenScreen(REQUEST)
150
151
166
167
169 """patch to export all device components
170 """
171 for o in self.objectValues():
172 if hasattr(aq_base(o), 'exportXml'):
173 o.exportXml(ofile, ignorerels)
174
175
177 """
178 Return a list of all RRDTemplates at this level and below.
179
180 Note: DeviceClass.getAllRRDTemplates has been rewritted to
181 use the searchRRDTemplates catalog. Because there is only
182 one level of MonitorClass this approach might be overkill for
183 this situation. However, if MonitorClasses ever become
184 hierarchical and contain many RRDTemplates it should probably
185 be refactored in a similar way.
186 """
187 return self.rrdTemplates()
188
189
191 "return the list of RRD Templates available at this level"
192 return self.rrdTemplates()
193
194
195 security.declareProtected('Add DMD Objects', 'manage_addRRDTemplate')
209
210
228
231
232
233 InitializeClass(MonitorClass)
234