diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2004-08-11 20:40:57 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2004-08-11 20:40:57 +0000 |
commit | 5776fba0963a5293647342c3eb4ec6a7285bb3f2 (patch) | |
tree | 69c504e9f31fbbd84e9e0c220c5945a0cc6371ee /src/lib/Server | |
parent | d81ddd2c7dfa1cc519261ba1265de4f0b31902f6 (diff) | |
download | bcfg2-5776fba0963a5293647342c3eb4ec6a7285bb3f2.tar.gz bcfg2-5776fba0963a5293647342c3eb4ec6a7285bb3f2.tar.bz2 bcfg2-5776fba0963a5293647342c3eb4ec6a7285bb3f2.zip |
Rename: generators/pkgmgr.py -> src/lib/Server/Generators/pkgmgr.py
(Logical change 1.37)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@212 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Generators/pkgmgr.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/lib/Server/Generators/pkgmgr.py b/src/lib/Server/Generators/pkgmgr.py index e69de29bb..85dd9ea48 100644 --- a/src/lib/Server/Generators/pkgmgr.py +++ b/src/lib/Server/Generators/pkgmgr.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +from re import compile + +from Generator import Generator +from GeneratorUtils import DirectoryBacked, XMLFileBacked +from Types import Package + +class PackageEntry(XMLFileBacked): + __identifier__ = 'image' + rpm = compile('^(?P<name>[\w\+\d\.]+(-[\w\+\d\.]+)*)-(?P<version>[\w\d\.]+-([\w\d\.]+))\.(?P<arch>\w+)\.rpm$') + + def Index(self): + XMLFileBacked.Index(self) + self.packages = {} + for location in self.entries: + for pkg in location.getchildren(): + if pkg.attrib.has_key("file"): + m = self.rpm.match(pkg.attrib['file']) + if not m: + print "failed to rpm match %s"%(pkg.attrib['file']) + continue + self.packages[m.group('name')] = m.groupdict() + self.packages[m.group('name')]['file'] = pkg.attrib['file'] + self.packages[m.group('name')]['uri'] = location.attrib['uri'] + self.packages[m.group('name')]['type'] = 'rpm' + else: + self.packages[pkg.attrib['name']] = pkg.attrib + +class PackageDir(DirectoryBacked): + __child__ = PackageEntry + +class pkgmgr(Generator): + '''This is a generator that handles service assignments''' + __name__ = 'pkgmgr' + __version__ = '$Id$' + __author__ = 'bcfg-dev@mcs.anl.gov' + + def __setup__(self): + self.pkgdir=PackageDir(self.data,self.core.fam) + + def FindHandler(self, entry): + if entry.tag != 'Package': + raise KeyError, (entry.tag, entry.attrib['name']) + return self.LocatePackage + + def LocatePackage(self, entry, metadata): + pkgname = entry.attrib['name'] + pl = self.pkgdir["%s.xml"%(metadata.image)] + if pl.packages.has_key(pkgname): + p = pl.packages[pkgname] + if p['type'] == 'rpm': + entry.attrib.update({'url':"%s/%s"%(p['uri'],p['file']), 'version':p['version']}) + else: + raise KeyError, ("Package", name) |