summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2010-07-25 15:30:22 +0000
committerSol Jerome <sol.jerome@gmail.com>2010-07-30 11:53:15 -0500
commit0e9daba224deee78a25e9ec8d2f7096d2d76c3c4 (patch)
tree1a8f514eeb55686eca1a99b8458fdc7973a87acf
parent09806826638be2c3fd3ef3888b8c4a040a57fedb (diff)
downloadbcfg2-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
-rw-r--r--schemas/packages.xsd10
-rw-r--r--src/lib/Server/Plugins/Packages.py18
2 files changed, 18 insertions, 10 deletions
diff --git a/schemas/packages.xsd b/schemas/packages.xsd
index 1b6d465d7..342920c2b 100644
--- a/schemas/packages.xsd
+++ b/schemas/packages.xsd
@@ -20,9 +20,13 @@
<xsd:element name="Version" type="xsd:string" minOccurs='0'
maxOccurs='1'/>
<xsd:element name="Component" type="xsd:string" minOccurs='0'
- maxOccurs='unbounded'/>
- <xsd:element name="Blacklist" type="xsd:string" minOccurs='0'
- maxOccurs='unbounded'/>
+ maxOccurs='unbounded'/>
+ <xsd:choice>
+ <xsd:element name="Blacklist" type="xsd:string" minOccurs='0'
+ maxOccurs='unbounded'/>
+ <xsd:element name="Whitelist" type="xsd:string" minOccurs='0'
+ maxOccurs='unbounded'/>
+ </xsd:choice>
<xsd:element name="Arch" type="xsd:string" minOccurs='1'
maxOccurs='unbounded'/>
</xsd:sequence>
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: