summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2007-01-08 20:47:21 +0000
committerNarayan Desai <desai@mcs.anl.gov>2007-01-08 20:47:21 +0000
commitc1aa7f13c53c6093c72dc968aa0818c8bba9265b (patch)
tree81377999fb37c6098b314e639154bc612a45158e /src/lib
parent702bfa4d6840b36077ecef0253491a63b98869f4 (diff)
downloadbcfg2-c1aa7f13c53c6093c72dc968aa0818c8bba9265b.tar.gz
bcfg2-c1aa7f13c53c6093c72dc968aa0818c8bba9265b.tar.bz2
bcfg2-c1aa7f13c53c6093c72dc968aa0818c8bba9265b.zip
Metadata improvements
* XInclude support -- now clients.xml and groups.xml can include secondary files * Schema updates for XInclude and group comments git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@2631 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Plugins/Metadata.py35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index 1f442feed..d416b8c89 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -54,24 +54,43 @@ class Metadata(Bcfg2.Server.Plugin.Plugin):
except:
self.probes = False
self.probedata = {}
+ self.extra = {'groups.xml':[], 'clients.xml':[]}
def HandleEvent(self, event):
'''Handle update events for data files'''
filename = event.filename.split('/')[-1]
- if filename not in ['groups.xml', 'clients.xml']:
+ if filename in ['groups.xml', 'clients.xml']:
+ dest = filename
+ elif filename in reduce(lambda x,y:x+y, self.extra.values()):
+ if event.code2str() == 'exists':
+ return
+ dest = [key for key, value in self.extra.iteritems() if filename in value][0]
+ else:
return
if event.code2str() == 'endExist':
return
try:
- xdata = lxml.etree.parse("%s/%s" % (self.data, filename))
+ xdata = lxml.etree.parse("%s/%s" % (self.data, dest))
except lxml.etree.XMLSyntaxError:
- self.logger.error('Failed to parse %s' % (filename))
+ self.logger.error('Failed to parse %s' % (dest))
return
- if filename == 'clients.xml':
+ included = [ent.get('href') for ent in \
+ xdata.findall('./{http://www.w3.org/2001/XInclude}include')]
+ if included:
+ for name in included:
+ if name not in self.extra[dest]:
+ self.core.fam.AddMonitor("%s/%s" % (self.data, name), self)
+ self.extra[dest].append(name)
+ try:
+ xdata.xinclude()
+ except lxml.etree.XIncludeError:
+ self.logger.error("Failed to process XInclude for file %s" % dest)
+
+ if dest == 'clients.xml':
self.clients = {}
self.aliases = {}
self.clientdata = xdata
- for client in xdata.findall('./Client'):
+ for client in xdata.findall('.//Client'):
if 'address' in client.attrib:
self.addresses[client.get('address')] = client.get('name')
for alias in [alias for alias in client.findall('Alias') if 'address' in alias.attrib]:
@@ -79,14 +98,14 @@ class Metadata(Bcfg2.Server.Plugin.Plugin):
self.clients.update({client.get('name'): client.get('profile')})
[self.aliases.update({alias.get('name'): client.get('name')}) for alias in client.findall('Alias')]
- elif filename == 'groups.xml':
+ elif dest == 'groups.xml':
self.public = []
self.profiles = []
self.toolsets = {}
self.groups = {}
grouptmp = {}
self.categories = {}
- for group in xdata.findall('./Group'):
+ for group in xdata.findall('.//Group'):
grouptmp[group.get('name')] = tuple([[item.get('name') for item in group.findall(spec)]
for spec in ['./Bundle', './Group']])
grouptmp[group.get('name')][1].append(group.get('name'))
@@ -118,7 +137,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin):
self.groups[group][2][self.categories[ggg]] = ggg
[self.groups[group][0].append(bund) for bund in bundles
if bund not in self.groups[group][0]]
- self.states[filename] = True
+ self.states[dest] = True
if False not in self.states.values():
# check that all client groups are real and complete
real = self.groups.keys()