diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2014-10-21 14:58:59 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2014-10-21 14:58:59 -0500 |
commit | 37ee63c35cc1a9378f3167d63a3254d6d3d239a9 (patch) | |
tree | ebeb7bb6fc65c3def2fa28bd3c5a21753b5ea5d7 /src/lib/Bcfg2/Server/Plugins | |
parent | c91af1486d2969d9938f9f11050b818d825326f3 (diff) | |
parent | 2aea371d005e74471b6b601772e847402a9a804e (diff) | |
download | bcfg2-37ee63c35cc1a9378f3167d63a3254d6d3d239a9.tar.gz bcfg2-37ee63c35cc1a9378f3167d63a3254d6d3d239a9.tar.bz2 bcfg2-37ee63c35cc1a9378f3167d63a3254d6d3d239a9.zip |
Merge branch 'add-name-for-sources' of https://github.com/AlexanderS/bcfg2 into maint
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Source.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py index 22073493c..d08c7d285 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 "name" attribute from :attr:`xsource` + self.name = xsource.get('name', None) + #: A list of predicates that are used to determine if this #: source applies to a given #: :class:`Bcfg2.Server.Plugins.Metadata.ClientMetadata` @@ -292,6 +295,7 @@ class Source(Bcfg2.Server.Plugin.Debuggable): # pylint: disable=R0902 else: setting['baseurl'] = self.rawurl setting['url'] = baseurl % setting + setting['name'] = self.get_repo_name(setting) self.url_map.extend(usettings) @property @@ -395,8 +399,10 @@ class Source(Bcfg2.Server.Plugin.Debuggable): # pylint: disable=R0902 doing other operations that require repository names. This function tries several approaches: - #. First, if the map contains a ``component`` key, use that as - the name. + #. First, if the source element containts a ``name`` attribute, + use that as the name. + #. If the map contains a ``component`` key, use that as the + name. #. If not, then try to match the repository URL against :attr:`Bcfg2.Server.Plugins.Packages.Source.REPO_RE`. If that succeeds, use the first matched group; additionally, @@ -426,6 +432,9 @@ class Source(Bcfg2.Server.Plugin.Debuggable): # pylint: disable=R0902 :type url_map: dict :returns: string - the name of the repository. """ + if self.name: + return self.name + if url_map['component']: rname = url_map['component'] else: |