1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__="""RRDDataSource
15
16 Base class for DataSources
17 """
18
19 import os
20
21 from Globals import DTMLFile
22 from Globals import InitializeClass
23 from DateTime import DateTime
24 from Acquisition import aq_parent
25 from AccessControl import ClassSecurityInfo, Permissions
26
27 from Products.PageTemplates.Expressions import getEngine
28
29 from Products.ZenUtils.ZenTales import talesCompile
30 from Products.ZenRelations.RelSchema import *
31
32 from ZenModelRM import ZenModelRM
33 from ZenPackable import ZenPackable
34
35
42
43
44
45
46
56
57
58
59
60
61
63
64 meta_type = 'RRDDataSource'
65
66 paramtypes = ('integer', 'string', 'float')
67 sourcetypes = ()
68
69 sourcetype = None
70 enabled = True
71 component = ''
72 eventClass = ''
73 eventKey = ''
74 severity = 3
75 commandTemplate = ""
76 cycletime = 300
77
78 _properties = (
79 {'id':'sourcetype', 'type':'selection',
80 'select_variable' : 'sourcetypes', 'mode':'w'},
81 {'id':'enabled', 'type':'boolean', 'mode':'w'},
82 {'id':'component', 'type':'string', 'mode':'w'},
83 {'id':'eventClass', 'type':'string', 'mode':'w'},
84 {'id':'eventKey', 'type':'string', 'mode':'w'},
85 {'id':'severity', 'type':'int', 'mode':'w'},
86 {'id':'commandTemplate', 'type':'string', 'mode':'w'},
87 {'id':'cycletime', 'type':'int', 'mode':'w'},
88 )
89
90 _relations = ZenPackable._relations + (
91 ("rrdTemplate", ToOne(ToManyCont,"Products.ZenModel.RRDTemplate","datasources")),
92 ("datapoints", ToManyCont(ToOne,"Products.ZenModel.RRDDataPoint","datasource")),
93 )
94
95
96 factory_type_information = (
97 {
98 'immediate_view' : 'editRRDDataSource',
99 'actions' :
100 (
101 { 'id' : 'edit'
102 , 'name' : 'Data Source'
103 , 'action' : 'editRRDDataSource'
104 , 'permissions' : ( Permissions.view, )
105 },
106 )
107 },
108 )
109
110 security = ClassSecurityInfo()
111
112
120
121
124
125
127 return self.datapoints()
128
129
132
133
149
150
160
161 if not ids: return self.callZenScreen(REQUEST)
162 for id in ids:
163 dp = getattr(self.datapoints,id,False)
164 if dp:
165 if getattr(self, 'device', False):
166 perfConf = self.device().getPerformanceServer()
167 perfConf.deleteRRDFiles(device=self.device().id, datapoint=dp.name())
168 else:
169 for d in self.deviceClass.obj.getSubDevicesGen():
170 perfConf = d.getPerformanceServer()
171 perfConf.deleteRRDFiles(device=d.id, datapoint=dp.name())
172
173 clean(self.graphs, dp.name())
174 clean(self.thresholds, dp.name())
175 self.datapoints._delObject(dp.id)
176
177 if REQUEST:
178 return self.callZenScreen(REQUEST)
179
180
201
202
204 if not cmd.startswith('/') and not cmd.startswith('$'):
205 if not cmd.startswith(context.zCommandPath):
206 cmd = os.path.join(context.zCommandPath, cmd)
207 return cmd
208
209
212
213
216