From add1e4e38fce73e282a2301b37db72201765d564 Mon Sep 17 00:00:00 2001 From: Brian Pellin Date: Thu, 6 Jan 2005 20:50:12 +0000 Subject: Added support for image to toolset mapping. (Logical change 1.174) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@757 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Metadata.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/lib/Server/Metadata.py') diff --git a/src/lib/Server/Metadata.py b/src/lib/Server/Metadata.py index 6838a7525..2c00db22e 100644 --- a/src/lib/Server/Metadata.py +++ b/src/lib/Server/Metadata.py @@ -7,13 +7,14 @@ from Bcfg2.Server.Generator import SingleXMLFileBacked class Metadata(object): '''The Metadata class is a container for all classes of metadata used by Bcfg2''' - def __init__(self, all, image, classes, bundles, attributes, hostname): + def __init__(self, all, image, classes, bundles, attributes, hostname, toolset): self.all = all self.image = image self.classes = classes self.bundles = bundles self.attributes = attributes self.hostname = hostname + self.toolset = toolset def Applies(self, other): '''Check if metadata styled object applies to current metadata''' @@ -44,6 +45,7 @@ class MetadataStore(SingleXMLFileBacked): self.clients = {} self.profiles = {} self.classes = {} + self.images = {} self.element = Element("dummy") def Index(self): @@ -53,12 +55,15 @@ class MetadataStore(SingleXMLFileBacked): self.clients = {} self.profiles = {} self.classes = {} + self.images = {} for prof in self.element.findall("Profile"): self.profiles[prof.attrib['name']] = Profile(prof) for cli in self.element.findall("Client"): self.clients[cli.attrib['name']] = (cli.attrib['image'], cli.attrib['profile']) for cls in self.element.findall("Class"): self.classes[cls.attrib['name']] = [bundle.attrib['name'] for bundle in cls.findall("Bundle")] + for img in self.element.findall("Image"): + self.images[img.attrib['name']] = img.attrib['toolset'] for key in [key[8:] for key in self.element.attrib if key[:8] == 'default_']: self.defaults[key] = self.element.get("default_%s" % key) @@ -87,7 +92,8 @@ class MetadataStore(SingleXMLFileBacked): prof = self.profiles[profile] # should we uniq here? V bundles = reduce(lambda x, y:x + y, [self.classes.get(cls) for cls in prof.classes]) - return Metadata(False, image, prof.classes, bundles, prof.attributes, client) + toolset = self.images[image] + return Metadata(False, image, prof.classes, bundles, prof.attributes, client, toolset) def pretty_print(self, element, level=0): '''Produce a pretty-printed text representation of element''' -- cgit v1.2.3-1-g7c22