summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJUN JIE NAN <nanjj@cn.ibm.com>2013-08-13 11:19:38 +0800
committerJUN JIE NAN <nanjj@cn.ibm.com>2013-08-19 10:55:02 +0800
commit2044ef239d59ba8b3c29172ffca99cb3070a6359 (patch)
treed7b89e574cbe75c17859f35b87cc4130d474fcaa
parent5b83c132a325538c8eae283074d7bbf6e80fb5fe (diff)
downloadheat-cfntools-2044ef239d59ba8b3c29172ffca99cb3070a6359.tar.gz
Support array values in command
Description of command in CFN User Guide: Either an array or a string specifying the command to run. If you use an array, you do not need to escape space characters or enclose command parameters in quotes. So we escape double quote first, and enclose each array value in double quote. Fixes bug #1211605 Change-Id: I28ecdb0d4b8a12690dddeac4e2398264c6d6f212
-rw-r--r--heat_cfntools/cfntools/cfn_helper.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/heat_cfntools/cfntools/cfn_helper.py b/heat_cfntools/cfntools/cfn_helper.py
index 7ed2166..282a1b0 100644
--- a/heat_cfntools/cfntools/cfn_helper.py
+++ b/heat_cfntools/cfntools/cfn_helper.py
@@ -872,9 +872,11 @@ class CommandsHandler(object):
if "command" in properties:
try:
- # TODO(pfreund) aws doc : "Either an array or a string
- # specifying the command to run" Need the array.
- command = CommandRunner(properties["command"])
+ command = properties["command"]
+ if isinstance(command, list):
+ escape = lambda x: '"%s"' % x.replace('"', '\\"')
+ command = ' '.join(map(escape, command))
+ command = CommandRunner(command)
command.run('root', cwd, env)
command_status = command.status
except OSError as e: