summaryrefslogtreecommitdiffstats
path: root/src/lib/Client/Frame.py
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2008-10-08 16:14:52 +0000
committerNarayan Desai <desai@mcs.anl.gov>2008-10-08 16:14:52 +0000
commit66faa8ba82f6ef2c7916c2f0c9f1b4b1a7f78a7b (patch)
treec90f40bd0d06766a31f33f135230c02b264c68d6 /src/lib/Client/Frame.py
parent1d71f20f8dd5365c43ccffe1ec740d2efa56b886 (diff)
downloadbcfg2-66faa8ba82f6ef2c7916c2f0c9f1b4b1a7f78a7b.tar.gz
bcfg2-66faa8ba82f6ef2c7916c2f0c9f1b4b1a7f78a7b.tar.bz2
bcfg2-66faa8ba82f6ef2c7916c2f0c9f1b4b1a7f78a7b.zip
Tighten up decision-list client-side code
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4931 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Client/Frame.py')
-rw-r--r--src/lib/Client/Frame.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/lib/Client/Frame.py b/src/lib/Client/Frame.py
index 009ee61ec..a2312e495 100644
--- a/src/lib/Client/Frame.py
+++ b/src/lib/Client/Frame.py
@@ -27,6 +27,16 @@ def promptFilter(prompt, entries):
continue
return ret
+def matches_white_list(entry, whitelist):
+ return (entry.tag, entry.get('name')) in whitelist or \
+ (entry.tag, '*') in whitelist or \
+ ('*', entry.get('name')) in whitelist
+
+def passes_black_list(entry, blacklist):
+ return (entry.tag, entry.get('name')) not in blacklist and \
+ and (entry.tag, '*') not in blacklist and \
+ ('*', entry.get('name')) not in blacklist
+
class Frame:
'''Frame is the container for all Tool objects and state information'''
def __init__(self, config, setup, times, drivers, dryrun):
@@ -150,17 +160,20 @@ class Frame:
self.whitelist = [entry for entry in self.states if not self.states[entry]]
# Need to process decision stuff early, so that dryrun mode works with it
if self.setup['decision'] == 'whitelist':
- dwl = self.setup['decision_list'][0]
- self.whitelist = [e for e in self.whitelist \
- if (e.tag, e.get('name')) in dwl or \
- (e.tag, '*') in dwl or \
- ('*', e.get('name')) in dwl]
+ dwl = self.setup['decision_list']
+ w_to_rem = [e for e in self.whitelist \
+ if not matches_white_list(e, dwl)]
+ if w_to_rem:
+ self.logger.info("In whitelist mode: suppressing installation of:")
+ self.logger.info(["%s:%s" % (e.tag, e.get('name')) for e in w_to_rem])
+ self.whitelist = [x for x in self.whitelist if x not in w_to_rem]
elif self.setup['decision'] == 'blacklist':
- dbl = self.setup['decision_list'][1]
- self.whitelist = [e for e in self.whitelist \
- if (e.tag, e.get('name')) not in dbl and \
- (e.tag, '*') not in dbl and \
- ('*', e.get('name')) not in dbl]
+ b_to_rem = [e for e in self.whitelist \
+ if not passes_black_list(e, self.setup['decision_list'])]
+ if b_to_rem:
+ self.logger.info("In blacklist mode: suppressing installation of:")
+ self.logger.info(["%s:%s" % (e.tag, e.get('name')) for e in b_to_rem])
+ self.whitelist = [x for x in self.whitelist if x not in b_to_rem]
if self.dryrun:
if self.whitelist: