Replace usage of uriescape
The uriescape function from puppetlabs-stdlib is no longer functional in Puppet 8, because the URI.escape, which is internally used by that function, is no longer available in Ruby 3+. This replaces the function by own function to avoid the failure in Puppet 8. Closes-Bug: #2057860 Change-Id: I7b4db4c1e64416e20d8470cbff0b8497c6a0cfc9
This commit is contained in:
parent
5eacb81147
commit
dff8bd9be2
|
@ -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 list.class != Hash
|
||||
raise Puppet::ParseError, "Syntax error: #{args[0]} is not a Hash"
|
||||
end
|
||||
|
||||
if queries.empty?
|
||||
return ''
|
||||
end
|
||||
return '?' + URI.encode_www_form(queries).gsub(/%/, '%%')
|
||||
end
|
||||
end
|
|
@ -233,13 +233,7 @@ class nova::migration::libvirt(
|
|||
$postfix = ''
|
||||
}
|
||||
|
||||
if empty($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'))
|
||||
}
|
||||
extra_params = encode_url_queries_for_python($client_extraparams)
|
||||
|
||||
$live_migration_uri = "qemu+${transport}://${prefix}%s${postfix}/system${extra_params}"
|
||||
|
||||
|
|
Loading…
Reference in New Issue