diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2011-10-07 08:37:17 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2011-10-07 08:37:17 -0400 |
commit | bd0fd1c4c32864414b60b51828c79198503cb3f6 (patch) | |
tree | 9bc328fedc111ce3e679c4921ef48d8566c3f562 /src/lib/Server/Plugins/Packages/PackagesSources.py | |
parent | e8821c043cdee6ab61b811fcc508fb83f85ce71b (diff) | |
download | bcfg2-bd0fd1c4c32864414b60b51828c79198503cb3f6.tar.gz bcfg2-bd0fd1c4c32864414b60b51828c79198503cb3f6.tar.bz2 bcfg2-bd0fd1c4c32864414b60b51828c79198503cb3f6.zip |
* Added support for yum libraries (if available and configured). This
can dramatically reduce memory usage, and fixed several bugs:
* #1014 (Package plugin can't resolve dependencies for rpms with
Require: tags for full paths that aren't Provided explicitly)
* #991 (Dependency Resolution difference between Package and yum)
* #996 (Packages high memory usage)
* Added support for Yum package groups when using yum libraries
(#1039)
* Fixed #911 (bcfg2 output for wrong package version with Packages is
misleading)
* YUMng turns down the Yum debug level itself depending on the
debug/verbosity level requested by bcfg2 so you don't have to reduce
the Yum debug level on a global basis
* Added support for Pulp repositories, including registering Pulp
consumers and binding to repositories
* Added ability to disable magic OS groups
Diffstat (limited to 'src/lib/Server/Plugins/Packages/PackagesSources.py')
-rw-r--r-- | src/lib/Server/Plugins/Packages/PackagesSources.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/lib/Server/Plugins/Packages/PackagesSources.py b/src/lib/Server/Plugins/Packages/PackagesSources.py new file mode 100644 index 000000000..5f82deb1f --- /dev/null +++ b/src/lib/Server/Plugins/Packages/PackagesSources.py @@ -0,0 +1,66 @@ +import os +import sys +import lxml.etree +import logging +import Bcfg2.Server.Plugin + +logger = logging.getLogger("Packages") + + +class PackagesSources(Bcfg2.Server.Plugin.SingleXMLFileBacked, + Bcfg2.Server.Plugin.StructFile): + __identifier__ = None + + def __init__(self, filename, cachepath, fam, packages, config): + try: + Bcfg2.Server.Plugin.SingleXMLFileBacked.__init__(self, + filename, + fam) + except OSError: + err = sys.exc_info()[1] + msg = "Packages: Failed to read configuration file: %s" % err + if not os.path.exists(self.name): + msg += " Have you created it?" + logger.error(msg) + raise Bcfg2.Server.Plugin.PluginInitError(msg) + Bcfg2.Server.Plugin.StructFile.__init__(self, filename) + self.cachepath = cachepath + self.config = config + if not os.path.exists(self.cachepath): + # create cache directory if needed + os.makedirs(self.cachepath) + self.pkg_obj = packages + self.loaded = False + + def Index(self): + Bcfg2.Server.Plugin.SingleXMLFileBacked.Index(self) + self.entries = [] + for xsource in self.xdata.findall('.//Source'): + source = self.source_from_xml(xsource) + if source is not None: + self.entries.append(source) + + self.pkg_obj.Reload() + self.loaded = True + + def source_from_xml(self, xsource): + """ create a *Source object from its XML representation in + sources.xml """ + stype = xsource.get("type") + if stype is None: + logger.error("No type specified for source, skipping") + return None + + try: + module = getattr(__import__("Bcfg2.Server.Plugins.Packages.%s" % + stype.title()).Server.Plugins.Packages, + stype.title()) + cls = getattr(module, "%sSource" % stype.title()) + except (ImportError, AttributeError): + logger.error("Unknown source type %s" % stype) + return None + + return cls(self.cachepath, xsource, self.config) + + def __getitem__(self, key): + return self.entries[key] |