mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add connection options param to the HP provider for Storage and Compute services that can be used to customize various connection related timeouts and other options.
This commit is contained in:
parent
3c6af7ab2a
commit
78a45b0a56
3 changed files with 14 additions and 10 deletions
|
@ -8,11 +8,11 @@ module Fog
|
|||
service(:compute, 'hp/compute', 'Compute')
|
||||
service(:storage, 'hp/storage', 'Storage')
|
||||
|
||||
def self.authenticate(options)
|
||||
hp_auth_uri = options[:hp_auth_uri] || "http://agpa-ge1.csbu.hpl.hp.com/auth/v1.0"
|
||||
def self.authenticate(options, connection_options = {})
|
||||
hp_auth_uri = options[:hp_auth_uri] || "https://region-a.geo-1.objects.hpcloudsvc.com/auth/v1.0/"
|
||||
endpoint = URI.parse(hp_auth_uri)
|
||||
@scheme = endpoint.scheme || "http"
|
||||
@host = endpoint.host || "agpa-ge1.csbu.hpl.hp.com"
|
||||
@host = endpoint.host || "region-a.geo-1.objects.hpcloudsvc.com"
|
||||
@port = endpoint.port.to_s || "80"
|
||||
if (endpoint.path)
|
||||
@auth_path = endpoint.path.slice(1, endpoint.path.length) # remove the leading slash
|
||||
|
@ -20,7 +20,7 @@ module Fog
|
|||
@auth_path = "auth/v1.0"
|
||||
end
|
||||
service_url = "#{@scheme}://#{@host}:#{@port}"
|
||||
connection = Fog::Connection.new(service_url)
|
||||
connection = Fog::Connection.new(service_url, false, connection_options)
|
||||
@hp_account_id = options[:hp_account_id]
|
||||
@hp_secret_key = options[:hp_secret_key]
|
||||
response = connection.request({
|
||||
|
|
|
@ -6,7 +6,7 @@ module Fog
|
|||
class HP < Fog::Service
|
||||
|
||||
requires :hp_secret_key, :hp_account_id
|
||||
recognizes :hp_auth_uri, :hp_servicenet, :persistent
|
||||
recognizes :hp_auth_uri, :hp_servicenet, :persistent, :connection_options
|
||||
recognizes :provider # remove post deprecation
|
||||
|
||||
model_path 'fog/hp/models/compute'
|
||||
|
@ -82,9 +82,11 @@ module Fog
|
|||
@hp_account_id = options[:hp_account_id]
|
||||
@hp_auth_uri = options[:hp_auth_uri]
|
||||
@hp_servicenet = options[:hp_servicenet]
|
||||
@connection_options = options[:connection_options] || {}
|
||||
authenticate
|
||||
Excon.ssl_verify_peer = false if options[:hp_servicenet] == true
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
@persistent = options[:persistent] || false
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
||||
end
|
||||
|
||||
def reload
|
||||
|
@ -135,7 +137,7 @@ module Fog
|
|||
:hp_account_id => @hp_account_id,
|
||||
:hp_auth_uri => @hp_auth_uri,
|
||||
}
|
||||
credentials = Fog::HP.authenticate(options)
|
||||
credentials = Fog::HP.authenticate(options, @connection_options)
|
||||
@auth_token = credentials['X-Auth-Token']
|
||||
uri = URI.parse(credentials['X-Server-Management-Url'])
|
||||
@host = @hp_servicenet == true ? "snet-#{uri.host}" : uri.host
|
||||
|
|
|
@ -6,7 +6,7 @@ module Fog
|
|||
class HP < Fog::Service
|
||||
|
||||
requires :hp_secret_key, :hp_account_id
|
||||
recognizes :hp_auth_uri, :hp_servicenet, :hp_cdn_ssl, :persistent
|
||||
recognizes :hp_auth_uri, :hp_servicenet, :hp_cdn_ssl, :persistent, :connection_options
|
||||
recognizes :provider # remove post deprecation
|
||||
|
||||
model_path 'fog/hp/models/storage'
|
||||
|
@ -134,16 +134,18 @@ module Fog
|
|||
@hp_secret_key = options[:hp_secret_key]
|
||||
@hp_account_id = options[:hp_account_id]
|
||||
@hp_cdn_ssl = options[:hp_cdn_ssl]
|
||||
credentials = Fog::HP.authenticate(options)
|
||||
@connection_options = options[:connection_options] || {}
|
||||
credentials = Fog::HP.authenticate(options, @connection_options)
|
||||
@auth_token = credentials['X-Auth-Token']
|
||||
|
||||
uri = URI.parse(credentials['X-Storage-Url'])
|
||||
@host = options[:hp_servicenet] == true ? "snet-#{uri.host}" : uri.host
|
||||
@path = uri.path
|
||||
@persistent = options[:persistent] || false
|
||||
@port = uri.port
|
||||
@scheme = uri.scheme
|
||||
Excon.ssl_verify_peer = false if options[:hp_servicenet] == true
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
||||
end
|
||||
|
||||
def reload
|
||||
|
|
Loading…
Add table
Reference in a new issue