Make econe work with https

git-svn-id: http://svn.opennebula.org/one/trunk@856 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
Javier Fontán Muiños committed 2009-10-13 20:45:23 +00:00
1 parent 6dad1c0f1d
commit 4d0734894e
2 files changed
+24 -10

No files matched your search

+21 -7
View File
@@ -86,18 +86,32 @@ module EC2QueryClient
@uri = URI.parse(endpoint)
if !@uri.scheme or @uri.scheme != "http"
raise "Only http protocol supported"
elsif !@uri.host
raise "Wrong URI format, host not found"
end
#if !@uri.scheme or @uri.scheme != "http"
# raise "Only http protocol supported"
#elsif !@uri.host
# raise "Wrong URI format, host not found"
#end
@ec2_connection = AWS::EC2::Base.new(
:access_key_id => @access_key_id,
:secret_access_key => @access_key_secret,
:server => @uri.host,
:port => @uri.port,
:use_ssl => false)
:use_ssl => @uri.scheme == 'https')
end
# Starts an http connection and calls the block provided. SSL flag
# is set if needed.
def http_start(url, &block)
http = Net::HTTP.new(url.host, url.port)
if url.scheme=='https'
http.use_ssl = true
http.verify_mode=OpenSSL::SSL::VERIFY_NONE
end
http.start do |connection|
block.call(connection)
end
end
#######################################################################
@@ -195,7 +209,7 @@ module EC2QueryClient
'application/octet-stream', file_name)
req = Net::HTTP::Post::Multipart.new('/', params)
res = Net::HTTP.start(@uri.host, @uri.port) do |http|
res = http_start(@uri) do |http|
http.request(req)
end
+3 -3
View File
@@ -83,9 +83,9 @@ post '/' do
when 'TerminateInstances'
result,rc = $econe_server.terminate_instances(params)
end
if OpenNebula::is_error?(rc)
halt rc, result.message
if OpenNebula::is_error?(result)
halt rc, result.to_s
end
result