mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-19 03:12:55 +09:00
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:
1 parent
6dad1c0f1d
commit
4d0734894e
2 files changed
+24
-10
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user