diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2012-11-01 00:06:17 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2015-05-10 16:25:26 +0200 |
commit | 610e4b140790dc2334aabd90a5b6fc5a636fd1be (patch) | |
tree | bbd1a164c13c5a0685fbf0a7a666c2c2b0de37e0 | |
parent | 5b39d1c5735452fd1116f0218531a60fe2746956 (diff) | |
download | bcfg2-610e4b140790dc2334aabd90a5b6fc5a636fd1be.tar.gz bcfg2-610e4b140790dc2334aabd90a5b6fc5a636fd1be.tar.bz2 bcfg2-610e4b140790dc2334aabd90a5b6fc5a636fd1be.zip |
Packages: add priority to sources and sort according to it
-rw-r--r-- | schemas/packages.xsd | 10 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/PackagesSources.py | 2 | ||||
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Source.py | 3 |
3 files changed, 15 insertions, 0 deletions
diff --git a/schemas/packages.xsd b/schemas/packages.xsd index fc5a1356c..3f2fe4f57 100644 --- a/schemas/packages.xsd +++ b/schemas/packages.xsd @@ -225,6 +225,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:attributeGroup ref="py:genshiAttrs"/> </xsd:complexType> 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 c9f6ea14a..2c2783394 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py @@ -202,6 +202,9 @@ class Source(Debuggable): # pylint: disable=R0902 #: The "name" attribute from :attr:`xsource` self.name = xsource.get('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` |