Merge "Replace usage of uriescape"
This commit is contained in:
commit
f211a97cbd
|
@ -0,0 +1,19 @@
|
||||||
|
Puppet::Functions.create_function(:encode_url_queries_for_python) do
|
||||||
|
|
||||||
|
def encode_url_queries_for_python(*args)
|
||||||
|
require 'uri'
|
||||||
|
|
||||||
|
if (args.size != 1) then
|
||||||
|
raise Puppet::ParseError, 'encode_url_queries_for_python(): Wrong number of arguments'
|
||||||
|
end
|
||||||
|
queries = args[0]
|
||||||
|
if queries.class != Hash
|
||||||
|
raise Puppet::ParseError, "encode_url_queries_for_python(): Requires a Hash, got #{queries.class}"
|
||||||
|
end
|
||||||
|
|
||||||
|
if queries.empty?
|
||||||
|
return ''
|
||||||
|
end
|
||||||
|
return '?' + URI.encode_www_form(queries).gsub(/%/, '%%')
|
||||||
|
end
|
||||||
|
end
|
|
@ -233,13 +233,7 @@ class nova::migration::libvirt(
|
||||||
$postfix = ''
|
$postfix = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
if empty($client_extraparams) {
|
$extra_params = encode_url_queries_for_python($client_extraparams)
|
||||||
$extra_params =''
|
|
||||||
} else {
|
|
||||||
$extra_params_before_python_escape = join(uriescape(join_keys_to_values($client_extraparams, '=')), '&')
|
|
||||||
# Must escape % as nova interprets it incorrectly.
|
|
||||||
$extra_params = sprintf('?%s', regsubst($extra_params_before_python_escape, '%', '%%', 'G'))
|
|
||||||
}
|
|
||||||
|
|
||||||
$live_migration_uri = "qemu+${transport}://${prefix}%s${postfix}/system${extra_params}"
|
$live_migration_uri = "qemu+${transport}://${prefix}%s${postfix}/system${extra_params}"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require 'puppet'
|
||||||
|
|
||||||
|
describe 'encode_url_queries_for_python', :type => :puppet_function do
|
||||||
|
|
||||||
|
it { is_expected.to run.with_params({}).and_return('') }
|
||||||
|
it { is_expected.to run.with_params({'a' => 1, 'b' => 2}).and_return('?a=1&b=2') }
|
||||||
|
it { is_expected.to run.with_params({'a' => 'b%c'}).and_return('?a=b%%25c') }
|
||||||
|
end
|
Loading…
Reference in New Issue