From 87203e45182b62e93e206ae0a220be8567bf678e Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Thu, 12 Aug 2004 15:39:34 +0000 Subject: Rename: src/bundler.py -> src/lib/Server/Structures/bundler.py }(Logical change 1.38) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@223 ce84e21b-d406-0410-9b95-82705330c041 --- src/bundler.py | 71 ---------------------------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 src/bundler.py diff --git a/src/bundler.py b/src/bundler.py deleted file mode 100644 index 93658ed94..000000000 --- a/src/bundler.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python -# $Id: $ - -from copy import deepcopy -from syslog import LOG_ERR, syslog - -from GeneratorUtils import SingleXMLFileBacked, DirectoryBacked -from Structure import Structure - -from elementtree.ElementTree import Element, XML, tostring - -class ImageFile(SingleXMLFileBacked): - def Index(self): - a = XML(self.data) - self.attr = a.attrib - self.entries = a.getchildren() - self.images = {} - for child in self.entries: - (name, package, service) = map(lambda x:child.attrib.get(x), ['name', 'package', 'service']) - for grandchild in child.getchildren(): - self.images[grandchild.attrib['name']] = (name, package, service) - -class BundleSet(DirectoryBacked): - '''The Bundler handles creation of dependent clauses based on bundle definitions''' - __child__ = XMLFileBacked - -class bundler(Structure): - __name__ = 'bundler' - __version__ = '$Version' - - '''The bundler creates dependent clauses based on the bundle/translation scheme from bcfg1''' - def __init__(self, core, datastore): - Structure.__init__(self, core, datastore) - self.imageinfo = ImageFile("%s/common/imageinfo.xml"%(datastore)) - self.core.fam.AddMonitor(self.imageinfo.name, self.imageinfo) - self.bundles = BundleSet(self.data, self.core.fam) - - def Construct(self, metadata): - (system, package, service) = self.GetTransInfo(metadata) - bundleset = [] - for bundlename in metadata.bundles: - if self.bundles.entries.has_key("%s.xml"%(bundlename)): - bundle = self.bundles.entries["%s.xml"%(bundlename)] - else: - syslog(LOG_ERR, "Client %s requested nonexistent bundle %s"%(metadata.hostname, bundlename)) - continue - b = Element("Bundle", name=bundlename) - for entry in bundle.entries: - if entry.tag != 'System': - d = deepcopy(entry) - b.append(d) - else: - if entry.attrib['name'] == system: - d = deepcopy(entry.getchildren()) - b._children += d - for entry in b._children: - if entry.tag == 'Package': - entry.attrib['type'] = package - elif entry.tag == 'Service': - entry.attrib['type'] = service - bundleset.append(b) - return bundleset - - def GetTransInfo(self, metadata): - if self.imageinfo.images.has_key(metadata.image): - return self.imageinfo.images[metadata.image] - else: - raise KeyError, metadata.image - - - -- cgit v1.2.3-1-g7c22