summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/Packages/Collection.py
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-03-12 03:42:14 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-03-12 03:42:14 +0100
commitaf94542b8d938dd931c07d439e9eb6437aab38bf (patch)
tree678dacafce7f3ff7106ab689737659de0136c766 /src/lib/Server/Plugins/Packages/Collection.py
parent0a289059cab2dfd6005b4e8fe6852221b49efcbe (diff)
downloadbcfg2-af94542b8d938dd931c07d439e9eb6437aab38bf.tar.gz
bcfg2-af94542b8d938dd931c07d439e9eb6437aab38bf.tar.bz2
bcfg2-af94542b8d938dd931c07d439e9eb6437aab38bf.zip
Plugins/Packages: backported packages_form_entry/_to_entry
1.3.0 adds an layer of abstraction to the Packages plugin, that makes it possible to change the method how Packages gets the name of a configured entry or how it build the Package object, send to the client. This backports these changes.
Diffstat (limited to 'src/lib/Server/Plugins/Packages/Collection.py')
-rw-r--r--src/lib/Server/Plugins/Packages/Collection.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/Server/Plugins/Packages/Collection.py b/src/lib/Server/Plugins/Packages/Collection.py
index d2d8a015d..f5e5bbe02 100644
--- a/src/lib/Server/Plugins/Packages/Collection.py
+++ b/src/lib/Server/Plugins/Packages/Collection.py
@@ -1,5 +1,6 @@
import copy
import logging
+import lxml.etree
import Bcfg2.Server.Plugin
logger = logging.getLogger(__name__)
@@ -156,6 +157,40 @@ class Collection(Bcfg2.Server.Plugin.Debuggable):
""" do any collection-level data setup tasks """
pass
+ def packages_from_entry(self, entry):
+ """ Given a Package or BoundPackage entry, get a list of the
+ package(s) described by it in a format appropriate for passing
+ to :func:`complete`. By default, that's just the name; only
+ the :mod:`Bcfg2.Server.Plugins.Packages.Yum` backend supports
+ versions or other extended data. See :ref:`pkg-objects` for
+ more details.
+
+ :param entry: The XML entry describing the package or packages.
+ :type entry: lxml.etree._Element
+ :returns: list of strings, but see :ref:`pkg-objects`
+ """
+ return [entry.get("name")]
+
+ def packages_to_entry(self, pkglist, entry, config):
+ """ Given a list of package objects as returned by
+ :func:`packages_from_entry` or :func:`complete`, return an XML
+ tree describing the BoundPackage entries that should be
+ included in the client configuration. See :ref:`pkg-objects`
+ for more details.
+
+ :param pkglist: A list of packages as returned by
+ :func:`complete`
+ :type pkglist: list of strings, but see :ref:`pkg-objects`
+ :param entry: The base XML entry to add all of the Package
+ entries to. This should be modified in place.
+ :type entry: lxml.etree._Element
+ """
+ for pkg in pkglist:
+ lxml.etree.SubElement(entry, 'BoundPackage', name=pkg,
+ version=config.get("packages", "version",
+ default="auto"),
+ type=self.ptype, origin='Packages')
+
def complete(self, packagelist, pinnings=None, recommended=None):
'''Build the transitive closure of all package dependencies