diff options
author | Tim Laszlo <tim.laszlo@gmail.com> | 2010-07-25 15:30:22 +0000 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2010-07-30 11:53:15 -0500 |
commit | 0e9daba224deee78a25e9ec8d2f7096d2d76c3c4 (patch) | |
tree | 1a8f514eeb55686eca1a99b8458fdc7973a87acf /src/lib/Server | |
parent | 09806826638be2c3fd3ef3888b8c4a040a57fedb (diff) | |
download | bcfg2-0e9daba224deee78a25e9ec8d2f7096d2d76c3c4.tar.gz bcfg2-0e9daba224deee78a25e9ec8d2f7096d2d76c3c4.tar.bz2 bcfg2-0e9daba224deee78a25e9ec8d2f7096d2d76c3c4.zip |
Packages: Allow for whitelisting
Patch from IRConan to allow for whitelisted packages in
sources.
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5988 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Plugins/Packages.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py index f327f5f94..0794dbd80 100644 --- a/src/lib/Server/Plugins/Packages.py +++ b/src/lib/Server/Plugins/Packages.py @@ -24,7 +24,8 @@ logger = logging.getLogger('Packages') def source_from_xml(xsource): ret = dict([('rawurl', False), ('url', False)]) for key, tag in [('groups', 'Group'), ('components', 'Component'), - ('arches', 'Arch'), ('blacklist', 'Blacklist')]: + ('arches', 'Arch'), ('blacklist', 'Blacklist'), + ('whitelist', 'Whitelist')]: ret[key] = [item.text for item in xsource.findall(tag)] # version and component need to both contain data for sources to work try: @@ -66,7 +67,7 @@ def _fetch_url(url): class Source(object): basegroups = [] def __init__(self, basepath, url, version, arches, components, groups, rawurl, - blacklist, recommended): + blacklist, whitelist, recommended): self.basepath = basepath self.version = version self.components = components @@ -77,6 +78,7 @@ class Source(object): self.deps = dict() self.provides = dict() self.blacklist = set(blacklist) + self.whitelist = set(whitelist) self.cachefile = None self.recommended = recommended @@ -170,8 +172,10 @@ class Source(object): Returns => (packages, unresolved requirements) ''' - if requirement in self.blacklist: + if requirement in self.blacklist or \ + (len(self.whitelist) > 0 and requirement not in self.whitelist): # Ignore blacklisted packages in this source + logger.error("Skipping %s" % requirement) raise NoData if self.is_package(metadata, requirement): @@ -248,9 +252,9 @@ class YUMSource(Source): ptype = 'yum' def __init__(self, basepath, url, version, arches, components, groups, - rawurl, blacklist, recommended): + rawurl, blacklist, whitelist, recommended): Source.__init__(self, basepath, url, version, arches, components, - groups, rawurl, blacklist, recommended) + groups, rawurl, blacklist, whitelist, recommended) if not self.rawurl: self.baseurl = self.url + '%(version)s/%(component)s/%(arch)s/' else: @@ -404,9 +408,9 @@ class APTSource(Source): ptype = 'deb' def __init__(self, basepath, url, version, arches, components, groups, - rawurl, blacklist, recommended): + rawurl, blacklist, whitelist, recommended): Source.__init__(self, basepath, url, version, arches, components, groups, - rawurl, blacklist, recommended) + rawurl, blacklist, whitelist, recommended) if not self.rawurl: self.cachefile = self.escape_url(self.url + '@' + self.version) + '.data' else: |