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