diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-27 10:40:44 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-27 10:43:25 -0400 |
commit | 935ff8b432af9a62002993e3e4c7bb789506fc29 (patch) | |
tree | cda2655e1afc0174211a47dcc1655bce6dcfd6c7 /src/lib/Bcfg2/Server/Plugins/Packages/Source.py | |
parent | 3923ecf5bbcc3e8836313f94e724ece1a3a5f705 (diff) | |
download | bcfg2-935ff8b432af9a62002993e3e4c7bb789506fc29.tar.gz bcfg2-935ff8b432af9a62002993e3e4c7bb789506fc29.tar.bz2 bcfg2-935ff8b432af9a62002993e3e4c7bb789506fc29.zip |
Packages: made url_map consistent across all source types
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Packages/Source.py')
-rw-r--r-- | src/lib/Bcfg2/Server/Plugins/Packages/Source.py | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py index df3706fb1..918c36afe 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Source.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Source.py @@ -45,7 +45,7 @@ class Source(Bcfg2.Server.Plugin.Debuggable): try: self.version = xsource.find('Version').text except AttributeError: - pass + self.version = None for key, tag in [('components', 'Component'), ('arches', 'Arch'), ('blacklist', 'Blacklist'), @@ -102,7 +102,27 @@ class Source(Bcfg2.Server.Plugin.Debuggable): self.cachefile = os.path.join(self.basepath, "cache-%s" % self.cachekey) + if not self.rawurl: + self.baseurl = self.url + "%(version)s/%(component)s/%(arch)s/" + else: + self.baseurl = self.rawurl self.url_map = [] + for arch in self.arches: + if self.url: + usettings = [dict(version=self.version, component=comp, + arch=arch) + for comp in self.components] + else: # rawurl given + usettings = [dict(version=self.version, component=None, + arch=arch)] + + for setting in usettings: + if not self.rawurl: + setting['baseurl'] = self.url + else: + setting['baseurl'] = self.rawurl + setting['url'] = self.baseurl % setting + self.url_map.extend(usettings) @property def cachekey(self): @@ -147,7 +167,7 @@ class Source(Bcfg2.Server.Plugin.Debuggable): def get_repo_name(self, url_map): # try to find a sensible name for a repo - if 'component' in url_map and url_map['component']: + if url_map['component']: rname = url_map['component'] else: name = None |