Fix the argument order for openstack client

If there are --xxx argument placed for openstack clients such as
nova, glance, keystone etc, these arguments need to be placed before
the actual command line. Otherwise, the client will raise unrecognized
arguments exception which will make the command execution fail.

Change-Id: I1568f9332accffdfa3a34d8bbd842f707b1a340e
Closes-Bug: #1388147
This commit is contained in:
ZHU ZHU
2014-10-31 10:30:15 -05:00
parent e02675369b
commit 0655583c91
3 changed files with 4 additions and 3 deletions

View File

@@ -54,10 +54,11 @@ module ::Openstack # rubocop:disable Documentation
# array into [cmd]. This is done to accomdate cmd + options like:
# keystone user-list
# glance image-show <id|name>
openstackcmd = [cmd].concat(options.split)
openstackcmd = [cmd]
args.each do |key, val|
openstackcmd << "--#{key}" << val.to_s
end
openstackcmd = openstackcmd.concat(options.split)
Chef::Log.debug("Running openstack command: #{openstackcmd} with environment: #{env}")
result = shell_out(openstackcmd, env: env)
fail "#{result.stderr} (#{result.exitstatus})" if result.exitstatus != 0