Extend openstack_command
This patch extends openstack_command to accept an array in addition to a
string as an argument.
This allows the use of openstack_command in cases where an argument
contains protected spaces.
Examples:
mistral execution-create my_workflow \
'{"names": ["John", "Mistral", "Ivan", "Crystal"]}'
barbican secret list --name chef_test_secret --format value -c"Secret href"
Without this patch, all arguments have to be passed as a single string
which openstack_command splits on white space regardless of any
quotation marks. Therefore, the examples above will fail.
Change-Id: I0419a1526beb103839a3cf235eba6c41d9d946d5
Closes-Bug: #1723949
This commit is contained in:
@@ -63,7 +63,10 @@ module ::Openstack
|
||||
openstackcmd << "--#{key}"
|
||||
openstackcmd << val.to_s unless val.to_s.empty?
|
||||
end
|
||||
openstackcmd = openstackcmd.concat(options.split)
|
||||
# If options is a string, split on whitespace into array; otherwise, assume
|
||||
# it is an array already and leave it untouched.
|
||||
options = options.split if options.instance_of? String
|
||||
openstackcmd = openstackcmd.concat(options)
|
||||
Chef::Log.debug("Running openstack command: #{openstackcmd} with environment: #{env}")
|
||||
result = shell_out(openstackcmd, env: env)
|
||||
Chef::Log.debug("Output for command: #{cmd}:\n#{result.stdout}\n#{result.stderr}")
|
||||
|
||||
Reference in New Issue
Block a user