Commit 67f20d57 authored by MARGERY David's avatar MARGERY David
Browse files

Implement support for tls options (bug #8379)

This is a v3 specific part of the patch, for the thin layer sitting
between g5k-api and kadpeloy's internal API, not present on the 4.x
branch (master)
parent 2e1192bf
......@@ -72,6 +72,7 @@ class DeploymentsController < ApplicationController
dpl = find_item(params[:id])
authorize!(dpl.user_uid)
dpl.base_uri = api_path()
dpl.tls_options=tls_options_for(dpl.base_uri, :out)
dpl.user = @credentials[:cn]
begin
......@@ -102,6 +103,7 @@ class DeploymentsController < ApplicationController
dpl.site_uid = Rails.whoami
dpl.user = @credentials[:cn]
dpl.base_uri = api_path()
dpl.tls_options=tls_options_for(dpl.base_uri, :out)
Rails.logger.info "Received deployment = #{dpl.inspect}"
raise BadRequest, "The deployment you are trying to submit is not valid: #{dpl.errors.to_a.join("; ")}" unless dpl.valid?
......@@ -143,6 +145,7 @@ class DeploymentsController < ApplicationController
def update
dpl = find_item(params[:id])
dpl.base_uri = api_path()
dpl.tls_options=tls_options_for(dpl.base_uri, :out)
dpl.user = 'root' # Ugly hack since no auth is needed for this method on theg5k API
begin
......
......@@ -20,7 +20,7 @@ module Grid5000
class Deployment < ActiveRecord::Base
attr_accessor :links
# Ugly hack to make the communication between the controller and the model possible
attr_accessor :base_uri, :user
attr_accessor :base_uri, :user, :tls_options
SERIALIZED_ATTRIBUTES = [:nodes, :notifications, :result]
......@@ -132,7 +132,8 @@ module Grid5000
:head => {
#'Accept' => '*/*',
'X-Remote-Ident' => user,
}
},
:tls => tls_options
)
http.errback{ error("Unable to contact #{File.join(base_uri,uid)}"); raise self.output+"\n" }
......@@ -155,7 +156,8 @@ module Grid5000
case scheme
when 'http','https'
begin
http = EM::HttpRequest.new(environment).get(:timeout=>10)
http = EM::HttpRequest.new(environment).get(:timeout=>10,
:tls => tls_options)
params['environment'] = YAML.load(http.response)
params['environment']['kind'] = 'anonymous'
rescue Exception => e
......@@ -176,7 +178,8 @@ module Grid5000
'Content-Type' => Mime::Type.lookup_by_extension(:json).to_s,
'Accept' => Mime::Type.lookup_by_extension(:json).to_s,
'X-Remote-Ident' => user,
}
},
:tls => tls_options
)
http.errback{ error("Unable to contact #{base_uri}"); raise self.output+"\n" }
......@@ -197,7 +200,8 @@ module Grid5000
:head => {
'Accept' => Mime::Type.lookup_by_extension(:json).to_s,
'X-Remote-Ident' => user,
}
},
:tls => tls_options
)
http.errback{ error("Unable to contact #{File.join(base_uri,uid)}"); raise self.output+"\n" }
......@@ -210,7 +214,8 @@ module Grid5000
:head => {
'Accept' => Mime::Type.lookup_by_extension(:json).to_s,
'X-Remote-Ident' => user,
}
},
:tls => tls_options
)
http.errback{ error("Unable to contact #{File.join(base_uri,uid,'state')}"); raise self.output+"\n" }
res = JSON.parse(http.response)
......@@ -225,7 +230,8 @@ module Grid5000
:head => {
#'Accept' => '*/*',
'X-Remote-Ident' => user,
}
},
:tls => tls_options
)
error(get_kaerror(http.response,http.response_header))
http.errback{ error("Unable to contact #{File.join(base_uri,uid,'error')}"); raise self.output+"\n" }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment