blob: 95565f2e47b1a55b3a019c624efc3f9ea1564bff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import copy
import lxml.etree
import Bcfg2.Server.Plugin
class PropertyFile(Bcfg2.Server.Plugin.StructFile):
"""Class for properties files."""
def Index(self):
"""Build local data structures."""
try:
xdata = XML(self.data)
except XMLSyntaxError:
self.label = None
self.entries = []
return
self.label = xdata.attrib[self.__identifier__]
self.entries = xdata.getchildren()
class PropDirectoryBacked(Bcfg2.Server.Plugin.DirectoryBacked):
__child__ = PropertyFile
class Properties(Bcfg2.Server.Plugin.Plugin,
Bcfg2.Server.Plugin.Connector):
"""
The properties plugin maps property
files into client metadata instances.
"""
name = 'Properties'
version = '$Revision$'
def __init__(self, core, datastore):
Bcfg2.Server.Plugin.Plugin.__init__(self, core, datastore)
Bcfg2.Server.Plugin.Connector.__init__(self)
try:
self.store = PropDirectoryBacked(self.data, core.fam)
except OSError:
e = sys.exc_info()[1]
Bcfg2.Server.Plugin.logger.error("Error while creating Properties "
"store: %s %s" % (e.strerror, e.filename))
raise Bcfg2.Server.Plugin.PluginInitError
def get_additional_data(self, _):
return copy.deepcopy(self.store.entries)
|