From 2331ba06e364736e3e9968dc6e927defe9c4a931 Mon Sep 17 00:00:00 2001 From: Lukas Bezdicka Date: Fri, 13 Mar 2015 13:10:38 +0100 Subject: [PATCH] Fix ipv6 support There is issue with ipv6 where address has to be in brackets, this causes the underlying ruby TCPSocket to fail. Net::HTTP.new will fail without brackets on joining the ipv6 address with :port or passing brackets to TCPSocket. It was found that if we use Net::HTTP.start with url.hostname the incriminated code won't be hit. Change-Id: Ia70e05098b52121d12b035bdab59685b086523db Closes-Bug: rhbz#1185652 --- lib/puppet/provider/heat_domain_id_setter/ruby.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/heat_domain_id_setter/ruby.rb b/lib/puppet/provider/heat_domain_id_setter/ruby.rb index ed1d34db..e48691fd 100644 --- a/lib/puppet/provider/heat_domain_id_setter/ruby.rb +++ b/lib/puppet/provider/heat_domain_id_setter/ruby.rb @@ -30,7 +30,13 @@ end # A parsed URL (returned from URI.parse) def handle_request(req, url) begin - res = Net::HTTP.start(url.host, url.port) {|http| + # There is issue with ipv6 where address has to be in brackets, this causes the + # underlying ruby TCPSocket to fail. Net::HTTP.new will fail without brackets on + # joining the ipv6 address with :port or passing brackets to TCPSocket. It was + # found that if we use Net::HTTP.start with url.hostname the incriminated code + # won't be hit. + use_ssl = url.scheme == "https" ? true : false + res = Net::HTTP.start(url.hostname, url.port, {:use_ssl => use_ssl}) {|http| http.request(req) }