1
2
3
4
5
6
7
8
9
10
11
12
13
14 __doc__='Base Classes for loading gunk in a ZenPack'
15
16 import Globals
17 from Products.ZenReports.ReportLoader import ReportLoader
18 from Products.ZenUtils.Utils import getObjByPath, zenPath
19
20 import os
21 import ConfigParser
22 import logging
23 log = logging.getLogger('zen.ZPLoader')
24
25 CONFIG_FILE = 'about.txt'
26 CONFIG_SECTION_ABOUT = 'about'
27
36
44
46 "return the branch after the given directory name"
47 path = filename.split('/')
48 return prefix + '/'.join(path[path.index(directory)+1:])
49
50
52
53 name = "Set This Name"
54
55 - def load(self, pack, app):
56 """Load things from the ZenPack and put it
57 into the app"""
58
60 """Remove things from Zenoss defined in the ZenPack"""
61
62 - def list(self, pack, app):
63 "List the items that would be loaded from the given (unpacked) ZenPack"
64
66 "Run an upgrade on an existing pack"
67
68 from xml.sax import saxutils, make_parser
69 from xml.sax.handler import ContentHandler
70
72
73 name = "Objects"
74
75 - def load(self, pack, app):
91 importer = AddToPack(noopts=True, app=app)
92 importer.options.noindex = True
93 for f in self.objectFiles(pack):
94 log.info("Loading %s", f)
95 importer.loadObjectFromXML(xmlfile=f)
96
97
98 - def parse(self, filename, handler):
99 parser = make_parser()
100 parser.setContentHandler(handler)
101 parser.parse(open(filename))
102
103
123
124 - def list(self, pack, app):
126
127
129 def isXml(f): return f.endswith('.xml')
130 return findFiles(pack, 'objects', isXml)
131
132
134
135 name = "Reports"
136
137 - def load(self, pack, app):
138 class HookReportLoader(ReportLoader):
139 def loadFile(self, root, id, fullname):
140 rpt = ReportLoader.loadFile(self, root, id, fullname)
141 rpt.addRelation('pack', pack)
142 return rpt
143 rl = HookReportLoader(noopts=True, app=app)
144 rl.options.force = True
145 rl.loadDirectory(pack.path('reports'))
146
149
150 - def list(self, pack, app):
152
153
155
156 name = "Daemons"
157
158 extensionsToIgnore = ('.svn-base', '.pyc' '~')
164
165
168
169 - def load(self, pack, app):
176
179
186
187 - def list(self, pack, app):
190
191
213
214
236
237
239
240 name = "Modeler Plugins"
241
242
243 - def list(self, pack, app):
246
247
249
250 name = "Skins"
251
252
253 - def load(self, pack, app):
257
258
262
263
264 - def list(self, pack, app):
266
267
269
270 name = "DataSources"
271
272
273 - def list(self, pack, app):
274 return [branchAfter(d, 'datasources')
275 for d in findFiles(pack, 'datasources',
276 lambda f: not f.endswith('.pyc') and f != '__init__.py')]
277
278
280
281 name = "Libraries"
282
283
284 - def list(self, pack, app):
285 d = pack.path('lib')
286 if os.path.isdir(d):
287 return [l for l in os.listdir(d)]
288 return []
289
291
292 name = "About"
293
309
310
311 - def load(self, pack, app):
314
315
318
319
320 - def list(self, pack, app):
322