summaryrefslogtreecommitdiffstats
path: root/src/lib/Server
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2005-09-07 17:35:15 +0000
committerNarayan Desai <desai@mcs.anl.gov>2005-09-07 17:35:15 +0000
commit47d0ca27ba448001dc0c686341795e91785b4881 (patch)
tree871315fc9283ff9e3fa8db6876bcaeeff1487e9d /src/lib/Server
parent124ca4521a57d904fd893f8ccf40bbf2f8967ffa (diff)
downloadbcfg2-47d0ca27ba448001dc0c686341795e91785b4881.tar.gz
bcfg2-47d0ca27ba448001dc0c686341795e91785b4881.tar.bz2
bcfg2-47d0ca27ba448001dc0c686341795e91785b4881.zip
switch to new Plugin API
switch to using Plugin.LogError }(Logical change 1.300) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1223 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server')
-rw-r--r--src/lib/Server/Generators/Pkgmgr.py81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/lib/Server/Generators/Pkgmgr.py b/src/lib/Server/Generators/Pkgmgr.py
deleted file mode 100644
index eb648d2f8..000000000
--- a/src/lib/Server/Generators/Pkgmgr.py
+++ /dev/null
@@ -1,81 +0,0 @@
-'''This module implements a package management scheme for all images'''
-__revision__ = '$Revision$'
-
-from copy import deepcopy
-from re import compile as regcompile
-from syslog import syslog, LOG_ERR
-
-from Bcfg2.Server.Generator import Generator, GeneratorError, GeneratorInitError, DirectoryBacked, XMLFileBacked
-
-class PackageEntry(XMLFileBacked):
- '''PackageEntry is a set of packages and locations for a single image'''
- __identifier__ = 'image'
- rpm = regcompile('^(?P<name>[\w\+\d\.]+(-[\w\+\d\.]+)*)-(?P<version>[\w\d\.]+-([\w\d\.]+))\.(?P<arch>\w+)\.rpm$')
-
- def Index(self):
- '''Build internal data structures'''
- XMLFileBacked.Index(self)
- self.packages = {}
- for location in self.entries:
- for pkg in location.getchildren():
- if pkg.attrib.has_key("simplefile"):
- self.packages[pkg.get('name')] = deepcopy(pkg.attrib)
- # most attribs will be set from pkg
- self.packages[pkg.get('name')]['uri'] = "%s/%s" % (location.get('uri'), pkg.get('simplefile'))
- elif pkg.attrib.has_key("file"):
- mdata = self.rpm.match(pkg.get('file'))
- if not mdata:
- print "failed to rpm match %s" % (pkg.get('file'))
- continue
- pkgname = mdata.group('name')
- self.packages[pkgname] = mdata.groupdict()
- self.packages[pkgname]['file'] = pkg.get('file')
- self.packages[pkgname]['uri'] = location.get('uri')
- self.packages[pkgname]['type'] = 'rpm'
- else:
- self.packages[pkg.get('name')] = pkg.attrib
-
-class PackageDir(DirectoryBacked):
- '''A directory of package files'''
- __child__ = PackageEntry
-
-class Pkgmgr(Generator):
- '''This is a generator that handles package assignments'''
- __name__ = 'Pkgmgr'
- __version__ = '$Id$'
- __author__ = 'bcfg-dev@mcs.anl.gov'
-
- def __init__(self, core, datastore):
- Generator.__init__(self, core, datastore)
- try:
- self.pkgdir = PackageDir(self.data, self.core.fam)
- except OSError:
- syslog(LOG_ERR, "Pkgmgr: Failed to load package indices")
- raise GeneratorInitError
-
- def FindHandler(self, entry):
- '''Non static mechanism of determining entry provisioning'''
- if entry.tag != 'Package':
- raise GeneratorError, (entry.tag, entry.get('name'))
- return self.LocatePackage
-
- def LocatePackage(self, entry, metadata):
- '''Locates a package entry for particular metadata'''
- pkgname = entry.get('name')
- if self.pkgdir.entries.has_key("%s.xml" % metadata.hostname):
- pkglist = self.pkgdir["%s.xml" % metadata.hostname]
- if pkglist.packages.has_key(pkgname):
- entry.attrib.update(pkglist.packages[pkgname])
- return
- elif not self.pkgdir.entries.has_key("%s.xml" % metadata.image):
- syslog(LOG_ERR, "Pkgmgr: no package index for image %s" % metadata.image)
- raise GeneratorError, ("Image", metadata.image)
- pkglist = self.pkgdir["%s.xml" % (metadata.image)]
- if pkglist.packages.has_key(pkgname):
- pkg = pkglist.packages[pkgname]
- if pkg.get('type', None) == 'rpm':
- entry.attrib.update({'url':"%s/%s" % (pkg['uri'], pkg['file']), 'version':pkg['version']})
- else:
- entry.attrib.update(pkg)
- else:
- raise GeneratorError, ("Package", pkgname)