summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-02-08 13:44:32 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-02-08 13:44:32 -0500
commit76350ecc5f05ee5236dd98e37291061813b8e709 (patch)
tree0e6cf20a9fadfe78a2fb193970150ad543e73036
parent398be2c5cb613d9506e0c115510c1b55881ca64e (diff)
downloadbcfg2-76350ecc5f05ee5236dd98e37291061813b8e709.tar.gz
bcfg2-76350ecc5f05ee5236dd98e37291061813b8e709.tar.bz2
bcfg2-76350ecc5f05ee5236dd98e37291061813b8e709.zip
made Action entries in Independent structures run with when="always"
-rw-r--r--doc/client/tools/actions.txt3
-rw-r--r--src/lib/Bcfg2/Client/Frame.py62
-rw-r--r--src/lib/Bcfg2/Client/Tools/Action.py4
3 files changed, 41 insertions, 28 deletions
diff --git a/doc/client/tools/actions.txt b/doc/client/tools/actions.txt
index ffca8572e..268fcc51d 100644
--- a/doc/client/tools/actions.txt
+++ b/doc/client/tools/actions.txt
@@ -28,8 +28,7 @@ so they can be centrally observed. Actions look like:
Note that the status attribute tells the bcfg2 client to ignore
return status, causing failures to still not be centrally reported. If
central reporting of action failure is desired, set this attribute to
-'check'. Also note that Action entries included in Base will not be
-executed.
+'check'.
Actions are not completely defined inside of a bundle; they are an
abstract entry. The Rules plugin can bind these entries. For example
diff --git a/src/lib/Bcfg2/Client/Frame.py b/src/lib/Bcfg2/Client/Frame.py
index a95c0a7a6..f230aacb7 100644
--- a/src/lib/Bcfg2/Client/Frame.py
+++ b/src/lib/Bcfg2/Client/Frame.py
@@ -323,10 +323,10 @@ class Frame(object):
for bundle in self.setup['bundle']:
if bundle not in all_bundle_names:
self.logger.info("Warning: Bundle %s not found" % bundle)
- bundles = filter(lambda b: b.get('name') in self.setup['bundle'],
- bundles)
+ bundles = [b for b in bundles
+ if b.get('name') in self.setup['bundle']]
elif self.setup['indep']:
- bundles = filter(lambda b: b.tag != 'Bundle', bundles)
+ bundles = [b for b in bundles if b.tag != 'Bundle']
if self.setup['skipbundle']:
# warn if non-existent bundle given
if not self.setup['bundle_quick']:
@@ -334,39 +334,41 @@ class Frame(object):
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)
+ bundles = [b for b in bundles
+ if b.get('name') not in self.setup['skipbundle']]
if self.setup['skipindep']:
- bundles = filter(lambda b: b.tag == 'Bundle', bundles)
+ bundles = [b for b in bundles if b.tag == 'Bundle']
self.whitelist = [e for e in self.whitelist
- if True in [e in b for b in bundles]]
+ if any(e in b for b in bundles)]
# first process prereq actions
for bundle in bundles[:]:
- if bundle.tag != 'Bundle':
- continue
- bmodified = len([item for item in bundle
- if item in self.whitelist])
+ if bundle.tag == 'Bundle':
+ bmodified = any(item in self.whitelist for item in bundle)
+ else:
+ bmodified = False
actions = [a for a in bundle.findall('./Action')
- if (a.get('timing') != 'post' and
+ if (a.get('timing') in ['pre', 'both'] and
(bmodified or a.get('when') == 'always'))]
# now we process all "always actions"
if self.setup['interactive']:
self.promptFilter(prompt, actions)
self.DispatchInstallCalls(actions)
+ if bundle.tag != 'Bundle':
+ continue
+
# need to test to fail entries in whitelist
- if False in [self.states[a] for a in actions]:
+ if not all(self.states[a] for a in actions):
# then display bundles forced off with entries
- self.logger.info("Bundle %s failed prerequisite action" %
- (bundle.get('name')))
+ self.logger.info("%s %s failed prerequisite action" %
+ (bundle.tag, bundle.get('name')))
bundles.remove(bundle)
b_to_remv = [ent for ent in self.whitelist if ent in bundle]
if b_to_remv:
- self.logger.info("Not installing entries from Bundle %s" %
- (bundle.get('name')))
+ self.logger.info("Not installing entries from %s %s" %
+ (bundle.tag, bundle.get('name')))
self.logger.info(["%s:%s" % (e.tag, e.get('name'))
for e in b_to_remv])
for ent in b_to_remv:
@@ -432,14 +434,26 @@ class Frame(object):
# prune out unspecified bundles when running with -b
continue
for tool in self.tools:
+ if bundle in mbundles:
+ func = tool.BundleUpdated
+ else:
+ func = tool.BundleNotUpdated
try:
- if bundle in mbundles:
- tool.BundleUpdated(bundle, self.states)
- else:
- tool.BundleNotUpdated(bundle, self.states)
+ func(bundle, self.states)
+ except:
+ self.logger.error("%s.%s(%s:%s) call failed:" %
+ (tool.name, func.im_func.func_name,
+ bundle.tag, bundle.get("name")),
+ exc_info=1)
+
+ for indep in self.config.findall('.//Independent'):
+ for tool in self.tools:
+ try:
+ tool.BundleNotUpdated(indep, self.states)
except:
- self.logger.error("%s.BundleNotUpdated() call failed:" %
- tool.name, exc_info=1)
+ self.logger.error("%s.BundleNotUpdated(%s:%s) call failed:"
+ % (tool.name, indep.tag,
+ indep.get("name")), exc_info=1)
def Remove(self):
"""Remove extra entries."""
diff --git a/src/lib/Bcfg2/Client/Tools/Action.py b/src/lib/Bcfg2/Client/Tools/Action.py
index 5aada9c0b..d5caf3231 100644
--- a/src/lib/Bcfg2/Client/Tools/Action.py
+++ b/src/lib/Bcfg2/Client/Tools/Action.py
@@ -82,8 +82,8 @@ class Action(Bcfg2.Client.Tools.Tool):
def BundleNotUpdated(self, bundle, states):
"""Run Actions when bundles have not been updated."""
for action in bundle.findall("Action"):
- if action.get('timing') in ['post', 'both'] and \
- action.get('when') != 'modified':
+ if (action.get('timing') in ['post', 'both'] and
+ action.get('when') != 'modified'):
if not self._action_allowed(action):
continue
states[action] = self.RunAction(action)