From 979c84d2eba7b0e3b35741c8e15b4b5077b4942c Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Tue, 10 Aug 2004 19:44:12 +0000 Subject: add metadatastore class (Logical change 1.27) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@140 ce84e21b-d406-0410-9b95-82705330c041 --- src/Metadata.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/Metadata.py') diff --git a/src/Metadata.py b/src/Metadata.py index de83b229f..a824dc022 100644 --- a/src/Metadata.py +++ b/src/Metadata.py @@ -1,9 +1,11 @@ #!/usr/bin/env python +from elementtree.ElementTree import XML from threading import Lock from time import localtime, mktime from Error import NodeConfigurationError +from GeneratorUtils import SingleXMLFileBacked '''This file stores persistent metadata for the BCFG Configuration Repository''' @@ -82,11 +84,19 @@ class Metadata(object): return False return True -class eMetadata(Metadata): - def __init__(self, element): - self.all = False - self.image = element.attrib['image'] - self.classes = [x.attrib['name'] for x in element.findall(".//class")] - self.bundles = ['ssh'] - self.attributes = [] - self.hostname = element.attrib['client'] +class MetadataStore(SingleXMLFileBacked): + def Index(self): + self.clients = {} + self.classes = {} + self.element = XML(self.data) + for c in self.element.findall("Class"): + self.classes[c.attrib['name']] = map(lambda x:x.attrib['name'], c.findall(".//Bundle")) + for client in self.element.findall('Client'): + attributes = map(lambda x:"%s.%s"%(x.attrib['scope'],x.attrib['name']), + client.findall(".//Attribute")) + classes = map(lambda x:x.attrib['name'], client.findall(".//Class")) + bundles = reduce(lambda x,y:x+y, map(lambda z:self.classes.get(z,[]), classes),[]) + for b in bundles: + if bundles.count(b) > 1: bundles.remove(b) + self.clients[client.attrib['name']] = Metadata(False, client.attrib['image'], classes, + bundles, attributes, client.attrib['name']) -- cgit v1.2.3-1-g7c22