From aece6f8901711fa9e662b63f4f6b12cb90b84503 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 30 Oct 2012 09:05:23 -0400 Subject: removed deprecated PostInstall support --- src/lib/Bcfg2/Client/Tools/Action.py | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'src/lib/Bcfg2/Client/Tools/Action.py') diff --git a/src/lib/Bcfg2/Client/Tools/Action.py b/src/lib/Bcfg2/Client/Tools/Action.py index b1a897c81..5aada9c0b 100644 --- a/src/lib/Bcfg2/Client/Tools/Action.py +++ b/src/lib/Bcfg2/Client/Tools/Action.py @@ -11,9 +11,8 @@ from Bcfg2.Compat import input # pylint: disable=W0622 class Action(Bcfg2.Client.Tools.Tool): """Implement Actions""" name = 'Action' - __handles__ = [('PostInstall', None), ('Action', None)] - __req__ = {'PostInstall': ['name'], - 'Action': ['name', 'timing', 'when', 'command', 'status']} + __handles__ = [('Action', None)] + __req__ = {'Action': ['name', 'timing', 'when', 'command', 'status']} def _action_allowed(self, action): """ Return true if the given action is allowed to be run by @@ -66,28 +65,14 @@ class Action(Bcfg2.Client.Tools.Tool): """Actions always verify true.""" return True - def VerifyPostInstall(self, dummy, _): - """Actions always verify true.""" - return True - def InstallAction(self, entry): """Run actions as pre-checks for bundle installation.""" if entry.get('timing') != 'post': return self.RunAction(entry) return True - def InstallPostInstall(self, entry): - """ Install a deprecated PostInstall entry """ - self.logger.warning("Installing deprecated PostInstall entry %s" % - entry.get("name")) - return self.InstallAction(entry) - def BundleUpdated(self, bundle, states): """Run postinstalls when bundles have been updated.""" - for postinst in bundle.findall("PostInstall"): - if not self._action_allowed(postinst): - continue - self.cmd.run(postinst.get('name')) for action in bundle.findall("Action"): if action.get('timing') in ['post', 'both']: if not self._action_allowed(action): -- cgit v1.2.3-1-g7c22 From 76350ecc5f05ee5236dd98e37291061813b8e709 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Fri, 8 Feb 2013 13:44:32 -0500 Subject: made Action entries in Independent structures run with when="always" --- src/lib/Bcfg2/Client/Tools/Action.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/lib/Bcfg2/Client/Tools/Action.py') 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) -- cgit v1.2.3-1-g7c22 From 3a0618331e009439ce6b9c664915669884cd4aed Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 12 Feb 2013 16:02:24 -0500 Subject: better Executor class for client tools --- src/lib/Bcfg2/Client/Tools/Action.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/lib/Bcfg2/Client/Tools/Action.py') diff --git a/src/lib/Bcfg2/Client/Tools/Action.py b/src/lib/Bcfg2/Client/Tools/Action.py index d5caf3231..7e8366928 100644 --- a/src/lib/Bcfg2/Client/Tools/Action.py +++ b/src/lib/Bcfg2/Client/Tools/Action.py @@ -48,14 +48,11 @@ class Action(Bcfg2.Client.Tools.Tool): "to build mode" % entry.get('command')) return False self.logger.debug("Running Action %s" % (entry.get('name'))) - rv = self.cmd.run(entry.get('command'))[0] + rv = self.cmd.run(entry.get('command')) self.logger.debug("Action: %s got return code %s" % - (entry.get('command'), rv)) - entry.set('rc', str(rv)) - if entry.get('status', 'check') == 'ignore': - return True - else: - return rv == 0 + (entry.get('command'), rv.retval)) + entry.set('rc', str(rv.retval)) + return entry.get('status', 'check') == 'ignore' or rv.success else: self.logger.debug("In dryrun mode: not running action: %s" % (entry.get('name'))) -- cgit v1.2.3-1-g7c22 From acb1dde9ba48b04d1ceb701ce849e96cef3d0070 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 21 Feb 2013 08:47:59 -0500 Subject: removed in-place modification of "states" dict in client tools --- src/lib/Bcfg2/Client/Tools/Action.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/lib/Bcfg2/Client/Tools/Action.py') diff --git a/src/lib/Bcfg2/Client/Tools/Action.py b/src/lib/Bcfg2/Client/Tools/Action.py index 7e8366928..7b62f61c7 100644 --- a/src/lib/Bcfg2/Client/Tools/Action.py +++ b/src/lib/Bcfg2/Client/Tools/Action.py @@ -68,19 +68,23 @@ class Action(Bcfg2.Client.Tools.Tool): return self.RunAction(entry) return True - def BundleUpdated(self, bundle, states): + def BundleUpdated(self, bundle): """Run postinstalls when bundles have been updated.""" + states = dict() for action in bundle.findall("Action"): if action.get('timing') in ['post', 'both']: if not self._action_allowed(action): continue states[action] = self.RunAction(action) + return states - def BundleNotUpdated(self, bundle, states): + def BundleNotUpdated(self, bundle): """Run Actions when bundles have not been updated.""" + states = dict() for action in bundle.findall("Action"): if (action.get('timing') in ['post', 'both'] and action.get('when') != 'modified'): if not self._action_allowed(action): continue states[action] = self.RunAction(action) + return states -- cgit v1.2.3-1-g7c22