summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-11-01 00:06:17 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-11-22 11:37:49 +0100
commit7d4f1ba69c541cb649101e40527200b8e2a0051a (patch)
tree9c9bbe1c189bc3fca4588a67fc655f892b923795
parent8dec64dc8e0259bdbf2f5cb57455a3d351ebf43c (diff)
downloadbcfg2-7d4f1ba69c541cb649101e40527200b8e2a0051a.tar.gz
bcfg2-7d4f1ba69c541cb649101e40527200b8e2a0051a.tar.bz2
bcfg2-7d4f1ba69c541cb649101e40527200b8e2a0051a.zip
Packages: add priority to sources and sort according to it
-rw-r--r--schemas/packages.xsd10
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py2
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Packages/Source.py3
3 files changed, 15 insertions, 0 deletions
diff --git a/schemas/packages.xsd b/schemas/packages.xsd
index e538bb0e7..0fd3f6647 100644
--- a/schemas/packages.xsd
+++ b/schemas/packages.xsd
@@ -211,6 +211,16 @@
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
+ <xsd:attribute type="xsd:integer" name="priority">
+ <xsd:annotation>
+ <xsd:documentation>
+ The priority of the source. This is used to order the
+ sources. After sorting, the first source, that could
+ deliver the package, is used. If not supplied the default
+ priority is 500.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
</xsd:complexType>
<xsd:complexType name="PackagesGroupType">
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py b/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py
index c47e18201..b18db5baf 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py
@@ -115,6 +115,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 55d12c400..01f2a732f 100644
--- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
+++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py
@@ -209,6 +209,9 @@ class Source(Bcfg2.Server.Plugin.Debuggable): # pylint: disable=R0902
#: The "version" attribute from :attr:`xsource`
self.version = xsource.get('version', '')
+ #: 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`