summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-11-01 00:06:17 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2018-10-18 16:12:20 +0200
commitab5a2a40c1318459a28dcce3293f3c3732107715 (patch)
tree4d59cc4f780b918d3b0d64c7468fc9e710ee060b /src
parent7853ce6dc93a09174e7f9e20a2c158a73f4f9ce9 (diff)
downloadbcfg2-ab5a2a40c1318459a28dcce3293f3c3732107715.tar.gz
bcfg2-ab5a2a40c1318459a28dcce3293f3c3732107715.tar.bz2
bcfg2-ab5a2a40c1318459a28dcce3293f3c3732107715.zip
Packages: add priority to sources and sort according to it
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Source.py3
2 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py b/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py
index 1af046ec0..9db521aae 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py
@@ -106,6 +106,8 @@ class PackagesSources(Bcfg2.Server.Plugin.StructFile):
source = self.source_from_xml(xsource)
if source is not None:
self.entries.append(source)
+ sorted(self.entries, key=(lambda source: source.priority),
+ reverse=True)
Index.__doc__ = Bcfg2.Server.Plugin.StructFile.Index.__doc__ + """
``Index`` is responsible for calling :func:`source_from_xml`
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
index 86f7698f7..43f6b91fb 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
@@ -188,6 +188,9 @@ class Source(Debuggable): # pylint: disable=R0902
#: The "name" attribute from :attr:`xsource`
self.name = None
+ #: The "priority" attribute from :attr:`xsource`
+ self.priority = xsource.get('priority', 500)
+
#: A list of predicates that are used to determine if this
#: source applies to a given
#: :class:`Bcfg2.Server.Plugins.Metadata.ClientMetadata`