summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2004-09-02 02:37:27 +0000
committerNarayan Desai <desai@mcs.anl.gov>2004-09-02 02:37:27 +0000
commit4d1d6ee0bba17dd8ca0951cbb994e72d78b14f62 (patch)
tree0cc85bedcf804ef9e19dbfde4cb13674e5e089fa /src/lib
parent8610410554b5ff20da5e444ff10745cc9f75ce27 (diff)
downloadbcfg2-4d1d6ee0bba17dd8ca0951cbb994e72d78b14f62.tar.gz
bcfg2-4d1d6ee0bba17dd8ca0951cbb994e72d78b14f62.tar.bz2
bcfg2-4d1d6ee0bba17dd8ca0951cbb994e72d78b14f62.zip
move to bundle prestructuring
implement bundle attribute restructuring (Logical change 1.53) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@301 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Structures/bundler.py48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/lib/Server/Structures/bundler.py b/src/lib/Server/Structures/bundler.py
index dd27b439e..3bc9cf510 100644
--- a/src/lib/Server/Structures/bundler.py
+++ b/src/lib/Server/Structures/bundler.py
@@ -19,10 +19,36 @@ class ImageFile(SingleXMLFileBacked):
(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 Bundle(XMLFileBacked):
+ def Index(self):
+ x = XML(self.data)
+ # scan self.entries to build partial bundle fragments
+ self.all = []
+ self.systems = {}
+ self.attributes = {}
+ for entry in x.getchildren():
+ if entry.tag == 'System':
+ self.systems[entry.attrib['name']] = entry.getchildren()
+ elif entry.tag == 'Attribute':
+ self.attributes["%s.%s"%(entry.attrib['scope'], entry.attrib['name'])] = entry.getchildren()
+ else:
+ self.all.append(entry)
+ del self.data
+
+ def BuildBundle(self,metadata, system):
+ bundlename = self.name[:-4]
+ b = Element('Bundle', name=bundlename)
+ for entry in self.all + self.systems.get(system, []):
+ b.append(deepcopy(entry))
+ for attribute in metadata.attributes:
+ for entry in self.attributes.get(attribute, []):
+ b.append(deepcopy(entry))
+ return b
class BundleSet(DirectoryBacked):
'''The Bundler handles creation of dependent clauses based on bundle definitions'''
- __child__ = XMLFileBacked
+ __child__ = Bundle
class bundler(Structure):
__name__ = 'bundler'
@@ -38,26 +64,18 @@ class bundler(Structure):
(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:
+ if not self.bundles.entries.has_key("%s.xml"%(bundlename)):
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:
+
+ bundle = self.bundles.entries["%s.xml"%(bundlename)].BuildBundle(metadata, system)
+ # now we need to populate service/package types
+ for entry in bundle.getchildren():
if entry.tag == 'Package':
entry.attrib['type'] = package
elif entry.tag == 'Service':
entry.attrib['type'] = service
- bundleset.append(b)
+ bundleset.append(bundle)
return bundleset
def GetTransInfo(self, metadata):