summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Client/Tools
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-06-14 20:28:42 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-06-14 20:28:42 +0200
commitde0af523ce59bd1e4c53e10a873fcd961f8f2b30 (patch)
tree7457ea57f0c12d5f28521a80ba1dd0e2d46d4c36 /src/lib/Bcfg2/Client/Tools
parentabd9d823bd46f13ff8553dddb9eabb31cbf0b2e0 (diff)
downloadbcfg2-de0af523ce59bd1e4c53e10a873fcd961f8f2b30.tar.gz
bcfg2-de0af523ce59bd1e4c53e10a873fcd961f8f2b30.tar.bz2
bcfg2-de0af523ce59bd1e4c53e10a873fcd961f8f2b30.zip
Client/Tools/Action: add shell attribute
Add an option to specify whether a command should be executed within a shell to enable flow control and other shell-specific syntax.
Diffstat (limited to 'src/lib/Bcfg2/Client/Tools')
-rw-r--r--src/lib/Bcfg2/Client/Tools/Action.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/lib/Bcfg2/Client/Tools/Action.py b/src/lib/Bcfg2/Client/Tools/Action.py
index da4412b1d..0166e4c00 100644
--- a/src/lib/Bcfg2/Client/Tools/Action.py
+++ b/src/lib/Bcfg2/Client/Tools/Action.py
@@ -32,10 +32,17 @@ class Action(Bcfg2.Client.Tools.Tool):
def RunAction(self, entry):
"""This method handles command execution and status return."""
+ shell = False
+ shell_string = ''
+ if entry.get('shell', 'false') == 'true':
+ shell = True
+ shell_string = '(in shell) '
+
if not self.setup['dryrun']:
if self.setup['interactive']:
- prompt = ('Run Action %s, %s: (y/N): ' %
- (entry.get('name'), entry.get('command')))
+ prompt = ('Run Action %s%s, %s: (y/N): ' %
+ (shell_string, entry.get('name'),
+ entry.get('command')))
# flush input buffer
while len(select.select([sys.stdin.fileno()], [], [],
0.0)[0]) > 0:
@@ -48,8 +55,9 @@ class Action(Bcfg2.Client.Tools.Tool):
self.logger.debug("Action: Deferring execution of %s due "
"to build mode" % entry.get('command'))
return False
- self.logger.debug("Running Action %s" % (entry.get('name')))
- rv = self.cmd.run(entry.get('command'))
+ self.logger.debug("Running Action %s %s" %
+ (shell_string, entry.get('name')))
+ rv = self.cmd.run(entry.get('command'), shell=shell)
self.logger.debug("Action: %s got return code %s" %
(entry.get('command'), rv.retval))
entry.set('rc', str(rv.retval))