diff options
-rw-r--r-- | src/lib/Bcfg2/Client/Frame.py | 52 | ||||
-rw-r--r-- | src/lib/Bcfg2/Options.py | 10 | ||||
-rwxr-xr-x | src/sbin/bcfg2 | 8 |
3 files changed, 51 insertions, 19 deletions
diff --git a/src/lib/Bcfg2/Client/Frame.py b/src/lib/Bcfg2/Client/Frame.py index 9ad669ad6..56ac80695 100644 --- a/src/lib/Bcfg2/Client/Frame.py +++ b/src/lib/Bcfg2/Client/Frame.py @@ -190,14 +190,23 @@ class Frame: self.whitelist = [x for x in self.whitelist if x not in b_to_rem] # take care of important entries first - if not self.dryrun and not self.setup['bundle']: - for cfile in [cfl for cfl in self.config.findall(".//Path") \ - if cfl.get('name') in self.__important__ and \ - cfl.get('type') == 'file']: - if cfile not in self.whitelist: + if not self.dryrun: + for cfile in self.config.findall(".//Path"): + if (cfile.get('name') not in self.__important__ or + cfile.get('type') != 'file' or + cfile not in self.whitelist): continue - tl = [t for t in self.tools if t.handlesEntry(cfile) \ - and t.canVerify(cfile)] + parent = cfile.getparent() + if ((parent.tag == "Bundle" and + ((self.setup['bundle'] and + parent.get("name") not in self.setup['bundle']) or + (self.setup['skipbundle'] and + parent.get("name") in self.setup['skipbundle']))) or + (parent.tag == "Independent" and + (self.setup['bundle'] or self.setup['skipindep']))): + continue + tl = [t for t in self.tools + if t.handlesEntry(cfile) and t.canVerify(cfile)] if tl: if self.setup['interactive'] and not \ promptFilter("Install %s: %s? (y/N):", [cfile]): @@ -262,22 +271,31 @@ class Frame: return # Here is where most of the work goes # first perform bundle filtering + all_bundle_names = [b.get('name') + for b in self.config.findall('./Bundle')] + bundles = self.config.getchildren() if self.setup['bundle']: - all_bundle_names = [b.get('name') for b in - self.config.findall('./Bundle')] # warn if non-existent bundle given for bundle in self.setup['bundle']: if bundle not in all_bundle_names: self.logger.info("Warning: Bundle %s not found" % bundle) - bundles = [b for b in self.config.findall('./Bundle') - if b.get('name') in self.setup['bundle']] - self.whitelist = [e for e in self.whitelist - if True in [e in b for b in bundles]] + bundles = filter(lambda b: b.get('name') in self.setup['bundle'], + bundles) elif self.setup['indep']: - bundles = [nb for nb in self.config.getchildren() - if nb.tag != 'Bundle'] - else: - bundles = self.config.getchildren() + bundles = filter(lambda b: b.tag != 'Bundle', bundles) + if self.setup['skipbundle']: + # warn if non-existent bundle given + for bundle in self.setup['skipbundle']: + if bundle not in all_bundle_names: + self.logger.info("Warning: Bundle %s not found" % bundle) + bundles = filter(lambda b: \ + b.get('name') not in self.setup['skipbundle'], + bundles) + if self.setup['skipindep']: + bundles = filter(lambda b: b.tag == 'Bundle', bundles) + + self.whitelist = [e for e in self.whitelist + if True in [e in b for b in bundles]] # first process prereq actions for bundle in bundles[:]: diff --git a/src/lib/Bcfg2/Options.py b/src/lib/Bcfg2/Options.py index 6d3dd0a8c..96a99b582 100644 --- a/src/lib/Bcfg2/Options.py +++ b/src/lib/Bcfg2/Options.py @@ -495,6 +495,12 @@ CLIENT_BUNDLE = \ cmd='-b', odesc='<bundle:bundle>', cook=colon_split) +CLIENT_SKIPBUNDLE = \ + Option('Configure everything except the given bundle(s)', + default=[], + cmd='-B', + odesc='<bundle:bundle>', + cook=colon_split) CLIENT_BUNDLEQUICK = \ Option('Only verify/configure the given bundle(s)', default=False, @@ -503,6 +509,10 @@ CLIENT_INDEP = \ Option('Only configure independent entries, ignore bundles', default=False, cmd='-z') +CLIENT_SKIPINDEP = \ + Option('Do not configure independent entries', + default=False, + cmd='-Z') CLIENT_KEVLAR = \ Option('Run in kevlar (bulletproof) mode', default=False, diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2 index 3cfdf38f6..2a7e5f585 100755 --- a/src/sbin/bcfg2 +++ b/src/sbin/bcfg2 @@ -43,8 +43,10 @@ class Client: dryrun=Bcfg2.Options.CLIENT_DRYRUN, paranoid=Bcfg2.Options.CLIENT_PARANOID, bundle=Bcfg2.Options.CLIENT_BUNDLE, + skipbundle=Bcfg2.Options.CLIENT_SKIPBUNDLE, bundle_quick=Bcfg2.Options.CLIENT_BUNDLEQUICK, indep=Bcfg2.Options.CLIENT_INDEP, + skipindep=Bcfg2.Options.CLIENT_SKIPINDEP, file=Bcfg2.Options.CLIENT_FILE, interactive=Bcfg2.Options.INTERACTIVE, cache=Bcfg2.Options.CLIENT_CACHE, @@ -271,8 +273,10 @@ class Client: if self.setup['bundle_quick']: newconfig = Bcfg2.Client.XML.XML('<Configuration/>') - [newconfig.append(bundle) for bundle in self.config.getchildren() if \ - bundle.tag == 'Bundle' and bundle.get('name') in self.setup['bundle']] + [newconfig.append(bundle) + for bundle in self.config.getchildren() + if (bundle.tag == 'Bundle' and + bundle.get('name') in self.setup['bundle'])] self.config = newconfig self.tools = Bcfg2.Client.Frame.Frame(self.config, |