[core] pass connection_options through service init

closes #411
This commit is contained in:
geemus 2011-09-12 10:01:48 -05:00
parent 544ae281eb
commit ffd01e51dd
41 changed files with 256 additions and 194 deletions

View File

@ -75,6 +75,7 @@ module Fog
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
@connection_options = options[:connection_options] || {}
options[:region] ||= 'us-east-1'
@host = options[:host] || case options[:region]
when 'ap-northeast-1'
@ -90,10 +91,11 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@path = options[:path] || '/'
@port = options[:port] || 443
@persistent = options[:persistent] || false
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -84,16 +84,15 @@ module Fog
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)
@host = options[:host] || 'cloudfront.amazonaws.com'
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@version = options[:version] || '2010-11-01'
unless options.has_key?(:persistent)
options[:persistent] = true
end
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)
@host = options[:host] || 'cloudfront.amazonaws.com'
@path = options[:path] || '/'
@persistent = options[:persistent] || true
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@version = options[:version] || '2010-11-01'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -51,6 +51,7 @@ module Fog
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
@connection_options = options[:connection_options] || {}
options[:region] ||= 'us-east-1'
@host = options[:host] || case options[:region]
when 'ap-northeast-1'
@ -66,10 +67,11 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -52,6 +52,7 @@ module Fog
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
@connection_options = options[:connection_options] || {}
options[:region] ||= 'us-east-1'
@host = options[:host] || case options[:region]
when 'ap-northeast-1'
@ -67,10 +68,11 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -226,8 +226,9 @@ module Fog
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
@region = options[:region] ||= 'us-east-1'
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
@region = options[:region] ||= 'us-east-1'
if @endpoint = options[:endpoint]
endpoint = URI.parse(@endpoint)
@ -250,11 +251,12 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
end
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -80,18 +80,18 @@ module Fog
def initialize(options={})
require 'fog/core/parser'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)
@host = options[:host] || 'route53.amazonaws.com'
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@version = options[:version] || '2010-10-01'
unless options.has_key?(:persistent)
options[:persistent] = true
end
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)
@host = options[:host] || 'route53.amazonaws.com'
@path = options[:path] || '/'
@persistent = options[:persistent] || true
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@version = options[:version] || '2010-10-01'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -103,6 +103,7 @@ module Fog
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
options[:region] ||= 'us-east-1'
@ -120,10 +121,11 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -112,12 +112,14 @@ module Fog
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
@host = options[:host] || 'iam.amazonaws.com'
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@host = options[:host] || 'iam.amazonaws.com'
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -86,6 +86,7 @@ module Fog
def initialize(options={})
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
options[:region] ||= 'us-east-1'
@ -103,10 +104,11 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -49,6 +49,7 @@ module Fog
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
options[:region] ||= 'us-east-1'
@host = options[:host] || case options[:region]
@ -57,10 +58,11 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -70,6 +70,7 @@ module Fog
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
@nil_string = options[:nil_string]|| 'nil'
@ -88,10 +89,11 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
private

View File

@ -52,6 +52,7 @@ module Fog
require 'multi_json'
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
options[:region] ||= 'us-east-1'
@ -68,10 +69,11 @@ module Fog
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -48,6 +48,7 @@ module Fog
def initialize(options={})
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha256', @aws_secret_access_key)
options[:region] ||= 'us-east-1'
@host = options[:host] || case options[:region]
@ -62,10 +63,11 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@path = options[:path] || '/'
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -245,6 +245,7 @@ module Fog
@aws_access_key_id = options[:aws_access_key_id]
@aws_secret_access_key = options[:aws_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha1', @aws_secret_access_key)
if @endpoint = options[:endpoint]
endpoint = URI.parse(@endpoint)
@ -268,14 +269,12 @@ module Fog
else
raise ArgumentError, "Unknown region: #{options[:region].inspect}"
end
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
unless options.has_key?(:persistent)
options[:persistent] = true
end
@path = options[:path] || '/'
@persistent = options[:persistent] || true
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
end
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent])
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload
@ -368,7 +367,7 @@ DATA
rescue Excon::Errors::TemporaryRedirect => error
uri = URI.parse(error.response.headers['Location'])
Fog::Logger.warning("fog: followed redirect to #{uri.host}, connecting to the matching region will be more performant")
response = Fog::Connection.new("#{@scheme}://#{uri.host}:#{@port}", false).request(original_params, &block)
response = Fog::Connection.new("#{@scheme}://#{uri.host}:#{@port}", false, @connection_options).request(original_params, &block)
end
response

View File

@ -61,10 +61,12 @@ module Fog
require 'multi_json'
@bluebox_api_key = options[:bluebox_api_key]
@bluebox_customer_id = options[:bluebox_customer_id]
@host = options[:bluebox_host] || "boxpanel.bluebox.net"
@port = options[:bluebox_port] || 443
@scheme = options[:bluebox_scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection_options = options[:connection_options] || {}
@host = options[:bluebox_host] || "boxpanel.bluebox.net"
@persistent = options[:persistent] || false
@port = options[:bluebox_port] || 443
@scheme = options[:bluebox_scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -55,11 +55,12 @@ module Fog
def initialize(options ={})
@bluebox_customer_id = options[:bluebox_customer_id]
@bluebox_api_key = options[:bluebox_api_key]
@host = options[:bluebox_host] || "boxpanel.bluebox.net"
@port = options[:bluebox_port] || 443
@scheme = options[:bluebox_scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection_options = options[:connection_options] || {}
@host = options[:bluebox_host] || "boxpanel.bluebox.net"
@persistent = options[:persistent] || false
@port = options[:bluebox_port] || 443
@scheme = options[:bluebox_scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -101,11 +101,13 @@ module Fog
def initialize(options)
require 'multi_json'
# Currently authentication and api endpoints are the same but may change
@auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL
@api_url = options[:brightbox_api_url] || Fog.credentials[:brightbox_api_url] || API_URL
@brightbox_client_id = options[:brightbox_client_id] || Fog.credentials[:brightbox_client_id]
@brightbox_secret = options[:brightbox_secret] || Fog.credentials[:brightbox_secret]
@connection = Fog::Connection.new(@api_url)
@auth_url = options[:brightbox_auth_url] || Fog.credentials[:brightbox_auth_url] || API_URL
@api_url = options[:brightbox_api_url] || Fog.credentials[:brightbox_api_url] || API_URL
@connection_options = options[:connection_options] || {}
@brightbox_client_id = options[:brightbox_client_id] || Fog.credentials[:brightbox_client_id]
@brightbox_secret = options[:brightbox_secret] || Fog.credentials[:brightbox_secret]
@persistent = options[:peristent] || false
@connection = Fog::Connection.new(@api_url, @persistent, @connection_options)
end
def request(method, url, expected_responses, options = nil)

View File

@ -59,16 +59,18 @@ module Fog
@dnsimple_email = options[:dnsimple_email]
@dnsimple_password = options[:dnsimple_password]
@connection_options = options[:connection_options] || {}
if options[:dnsimple_url]
uri = URI.parse(options[:dnsimple_url])
options[:host] = uri.host
options[:port] = uri.port
options[:scheme] = uri.scheme
end
@host = options[:host] || "dnsimple.com"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@host = options[:host] || "dnsimple.com"
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -84,13 +84,12 @@ module Fog
@dnsmadeeasy_api_key = options[:dnsmadeeasy_api_key]
@dnsmadeeasy_secret_key = options[:dnsmadeeasy_secret_key]
@host = options[:host] || 'api.dnsmadeeasy.com'
@port = options[:port] || 80 #443 Not yet
@scheme = options[:scheme] || 'http' #'https Not yet
unless options.has_key?(:persistent)
options[:persistent] = true
end
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection_options = options[:connection_options] || {}
@host = options[:host] || 'api.dnsmadeeasy.com'
@persistent = options[:persistent] || true
@port = options[:port] || 80 #443 Not yet
@scheme = options[:scheme] || 'http' #'https Not yet
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -64,12 +64,14 @@ module Fog
@dynect_username = options[:dynect_username]
@dynect_password = options[:dynect_password]
@host = "api2.dynect.net"
@port = options[:port] || 443
@path = options[:path] || '/REST'
@scheme = options[:scheme] || 'https'
@version = options[:version] || '2.3.1'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent] || true)
@connection_options = options[:connection_options] || {}
@host = "api2.dynect.net"
@port = options[:port] || 443
@path = options[:path] || '/REST'
@persistent = options[:persistent] || true
@scheme = options[:scheme] || 'https'
@version = options[:version] || '2.3.1'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def auth_token

View File

@ -1144,11 +1144,12 @@ module Fog
require 'fog/core/parser'
@connections = {}
@connection_options = options[:connection_options] || {}
@versions_uri = URI.parse(options[:ecloud_versions_uri])
@version = options[:ecloud_version]
@username = options[:ecloud_username]
@password = options[:ecloud_password]
@persistent = options[:persistent]
@version = options[:ecloud_version]
@username = options[:ecloud_username]
@password = options[:ecloud_password]
@persistent = options[:persistent] || false
end
def default_organization_uri
@ -1268,7 +1269,7 @@ module Fog
# Hash connections on the host_url ... There's nothing to say we won't get URI's that go to
# different hosts.
@connections[host_url] ||= Fog::Connection.new(host_url, @persistent)
@connections[host_url] ||= Fog::Connection.new(host_url, @persistent, @connection_options)
# Set headers to an empty hash if none are set.
headers = params[:headers] || {}

View File

@ -52,10 +52,12 @@ module Fog
require 'multi_json'
require 'base64'
@api_url = options[:glesys_api_url] || Fog.credentials[:glesys_api_url] || API_URL
@glesys_username = options[:glesys_username] || Fog.credentials[:glesys_api_key]
@glesys_api_key = options[:glesys_api_key] || Fog.credentials[:glesys_api_key]
@connection = Fog::Connection.new(@api_url)
@api_url = options[:glesys_api_url] || Fog.credentials[:glesys_api_url] || API_URL
@glesys_username = options[:glesys_username] || Fog.credentials[:glesys_api_key]
@glesys_api_key = options[:glesys_api_key] || Fog.credentials[:glesys_api_key]
@connection_options = options[:connection_options] || {}
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(@api_url, @persistent, @connection_options)
end
def request(method_name, options = {})

View File

@ -64,11 +64,13 @@ module Fog
require 'multi_json'
@go_grid_api_key = options[:go_grid_api_key]
@go_grid_shared_secret = options[:go_grid_shared_secret]
@host = options[:host] || "api.gogrid.com"
@path = options[:path] || "/api"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection_options = options[:connection_options] || {}
@host = options[:host] || "api.gogrid.com"
@path = options[:path] || "/api"
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -189,14 +189,13 @@ module Fog
@google_storage_access_key_id = options[:google_storage_access_key_id]
@google_storage_secret_access_key = options[:google_storage_secret_access_key]
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha1', @google_storage_secret_access_key)
@host = options[:host] || 'commondatastorage.googleapis.com'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
unless options.has_key?(:persistent)
options[:persistent] = true
end
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@persistent = options[:persistent] || true
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -54,11 +54,13 @@ module Fog
def initialize(options={})
require 'multi_json'
@connection_options = options[:connection_options] || {}
@host = options[:host] || "api.linode.com"
@linode_api_key = options[:linode_api_key]
@host = options[:host] || "api.linode.com"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -52,10 +52,12 @@ module Fog
@new_servers_password = options[:new_servers_password]
@new_servers_username = options[:new_servers_username]
@host = options[:host] || "noc.newservers.com"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection_options = options[:connection_options] || {}
@host = options[:host] || "noc.newservers.com"
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -68,7 +68,6 @@ module Fog
@api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL
@ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key]
@ninefold_compute_secret = options[:ninefold_compute_secret] || Fog.credentials[:ninefold_compute_secret]
@connection = Fog::Connection.new(@api_url)
end
def request(options)
@ -81,10 +80,12 @@ module Fog
def initialize(options)
require 'multi_json'
@api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL
@ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key]
@ninefold_compute_secret = options[:ninefold_compute_secret] || Fog.credentials[:ninefold_compute_secret]
@connection = Fog::Connection.new(@api_url)
@api_url = options[:ninefold_api_url] || Fog.credentials[:ninefold_api_url] || API_URL
@ninefold_compute_key = options[:ninefold_compute_key] || Fog.credentials[:ninefold_compute_key]
@ninefold_compute_secret = options[:ninefold_compute_secret] || Fog.credentials[:ninefold_compute_secret]
@connection_options = options[:connection_options] || {}
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(@api_url, @persistent, @connection_options)
end
def request(command, params, options)

View File

@ -51,10 +51,11 @@ module Fog
@ninefold_storage_secret = options[:ninefold_storage_secret]
@ninefold_storage_secret_decoded = Base64.decode64( @ninefold_storage_secret )
@hmac = Fog::HMAC.new('sha1', @ninefold_storage_secret_decoded)
@connection_options = options[:connection_options] || {}
@hmac = Fog::HMAC.new('sha1', @ninefold_storage_secret_decoded)
@persistent = options[:persistent] || true
Excon.ssl_verify_peer = false if options[:rackspace_servicenet] == true
@connection = Fog::Connection.new("#{Fog::Storage::Ninefold::STORAGE_SCHEME}://#{Fog::Storage::Ninefold::STORAGE_HOST}:#{Fog::Storage::Ninefold::STORAGE_PORT}", true) # persistent
@connection = Fog::Connection.new("#{Fog::Storage::Ninefold::STORAGE_SCHEME}://#{Fog::Storage::Ninefold::STORAGE_HOST}:#{Fog::Storage::Ninefold::STORAGE_PORT}", @persistent, @connection_options)
end
def uid

View File

@ -48,12 +48,12 @@ module Fog
service(:storage, 'rackspace/storage')
service(:load_balancers, 'rackspace/load_balancers')
def self.authenticate(options)
def self.authenticate(options, connection_options = {})
rackspace_auth_url = options[:rackspace_auth_url] || "auth.api.rackspacecloud.com"
url = rackspace_auth_url.match(/^https?:/) ? \
rackspace_auth_url : 'https://' + rackspace_auth_url
uri = URI.parse(url)
connection = Fog::Connection.new(url)
connection = Fog::Connection.new(url, false, connection_options)
@rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username]
response = connection.request({

View File

@ -46,9 +46,11 @@ module Fog
def initialize(options={})
require 'multi_json'
credentials = Fog::Rackspace.authenticate(options)
@connection_options = options[:connection_options] || {}
credentials = Fog::Rackspace.authenticate(options, @connection_options)
@auth_token = credentials['X-Auth-Token']
@enabled = false
@persistent = options[:persistent] || false
if credentials['X-CDN-Management-Url']
uri = URI.parse(credentials['X-CDN-Management-Url'])
@ -56,7 +58,7 @@ module Fog
@path = uri.path
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@enabled = true
end
end

View File

@ -86,9 +86,11 @@ module Fog
@rackspace_auth_token = options[:rackspace_auth_token]
@rackspace_management_url = options[:rackspace_management_url]
@rackspace_must_reauthenticate = false
@connection_options = options[:connection_options] || {}
authenticate
Excon.ssl_verify_peer = false if options[:rackspace_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
@ -137,7 +139,7 @@ module Fog
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
}
credentials = Fog::Rackspace.authenticate(options)
credentials = Fog::Rackspace.authenticate(options, @connection_options)
@auth_token = credentials['X-Auth-Token']
uri = URI.parse(credentials['X-Server-Management-Url'])
else

View File

@ -44,13 +44,17 @@ module Fog
@rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username]
@rackspace_auth_url = options[:rackspace_auth_url]
@connection_options = options[:connection_options] || {}
uri = URI.parse(options[:rackspace_dns_endpoint] || US_ENDPOINT)
@auth_token, @account_id = *authenticate
@path = "#{uri.path}/#{@account_id}"
headers = { 'Content-Type' => 'application/json', 'X-Auth-Token' => @auth_token }
@persistent = options[:persistent] || false
@path = "#{uri.path}/#{@account_id}"
@connection = Fog::Connection.new(uri.to_s, options[:persistent], { :headers => headers})
@connection_options[:headers] ||= {}
@connection_options[:headers].merge!({ 'Content-Type' => 'application/json', 'X-Auth-Token' => @auth_token })
@connection = Fog::Connection.new(uri.to_s, @persistent, @connection_options)
end
private
@ -82,7 +86,7 @@ module Fog
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
}
credentials = Fog::Rackspace.authenticate(options)
credentials = Fog::Rackspace.authenticate(options, @connection_options)
auth_token = credentials['X-Auth-Token']
account_id = credentials['X-Server-Management-Url'].match(/.*\/([\d]+)$/)[1]
[auth_token, account_id]

View File

@ -98,15 +98,17 @@ module Fog
@rackspace_username = options[:rackspace_username]
@rackspace_auth_url = options[:rackspace_auth_url]
@rackspace_must_reauthenticate = false
@connection_options = options[:connection_options] || {}
uri = URI.parse(options[:rackspace_lb_endpoint] || DFW_ENDPOINT)
@host = uri.host
@path = uri.path
@port = uri.port
@scheme = uri.scheme
@host = uri.host
@persistent = options[:persistent] || false
@path = uri.path
@port = uri.port
@scheme = uri.scheme
authenticate
@connection = Fog::Connection.new(uri.to_s, options[:persistent])
@connection = Fog::Connection.new(uri.to_s, @persistent, @connection_options)
end
def request(params)
@ -141,7 +143,7 @@ module Fog
:rackspace_username => @rackspace_username,
:rackspace_auth_url => @rackspace_auth_url
}
credentials = Fog::Rackspace.authenticate(options)
credentials = Fog::Rackspace.authenticate(options, @connection_options)
@auth_token = credentials['X-Auth-Token']
account_id = credentials['X-Server-Management-Url'].match(/.*\/([\d]+)$/)[1]
@path = "#{@path}/#{account_id}"

View File

@ -83,16 +83,18 @@ module Fog
@rackspace_username = options[:rackspace_username]
@rackspace_cdn_ssl = options[:rackspace_cdn_ssl]
@rackspace_auth_url = options[:rackspace_auth_url]
credentials = Fog::Rackspace.authenticate(options)
@connection_options = options[:connection_options] || {}
credentials = Fog::Rackspace.authenticate(options, @connection_options)
@auth_token = credentials['X-Auth-Token']
uri = URI.parse(credentials['X-Storage-Url'])
@host = options[:rackspace_servicenet] == true ? "snet-#{uri.host}" : uri.host
@path = uri.path
@port = uri.port
@scheme = uri.scheme
@host = options[:rackspace_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[:rackspace_servicenet] == true
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -60,10 +60,12 @@ module Fog
require 'fog/core/parser'
@slicehost_password = options[:slicehost_password]
@host = options[:host] || "api.slicehost.com"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection_options = options[:connection_options] || {}
@host = options[:host] || "api.slicehost.com"
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -56,10 +56,12 @@ module Fog
require 'fog/core/parser'
@slicehost_password = options[:slicehost_password]
@host = options[:host] || "api.slicehost.com"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection_options = options[:connection_options] || {}
@host = options[:host] || "api.slicehost.com"
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -87,13 +87,15 @@ module Fog
def initialize(options={})
require 'multi_json'
uri = URI.parse(options[:storm_on_demand_auth_url] ||= API_URL)
@host = uri.host
@path = uri.path
@port = uri.port
@scheme = uri.scheme
@connection_options = options[:connection_options] || {}
@host = uri.host
@path = uri.path
@persistent = options[:persistent] || false
@port = uri.port
@scheme = uri.scheme
@storm_on_demand_username = options[:storm_on_demand_username]
@storm_on_demand_password = options[:storm_on_demand_password]
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -39,11 +39,13 @@ module Fog
def initialize(options={})
@terremark_password = options[:terremark_vcloud_password]
@terremark_username = options[:terremark_vcloud_username]
@host = options[:host] || Fog::Terremark::Vcloud::Defaults::HOST
@path = options[:path] || Fog::Terremark::Vcloud::Defaults::PATH
@port = options[:port] || Fog::Terremark::Vcloud::Defaults::PORT
@scheme = options[:scheme] || Fog::Terremark::Vcloud::Defaults::SCHEME
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection_options = options[:connection_options] || {}
@host = options[:host] || Fog::Terremark::Vcloud::Defaults::HOST
@path = options[:path] || Fog::Terremark::Vcloud::Defaults::PATH
@persistent = options[:persistent] || false
@port = options[:port] || Fog::Terremark::Vcloud::Defaults::PORT
@scheme = options[:scheme] || Fog::Terremark::Vcloud::Defaults::SCHEME
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def default_vdc_id

View File

@ -162,6 +162,7 @@ module Fog
require 'fog/core/parser'
@connections = {}
@connection_options = options[:connection_options] || {}
@persistent = options[:persistent]
@username = options[:vcloud_username]
@ -268,7 +269,7 @@ module Fog
# Hash connections on the host_url ... There's nothing to say we won't get URI's that go to
# different hosts.
@connections[host_url] ||= Fog::Connection.new(host_url, @persistent)
@connections[host_url] ||= Fog::Connection.new(host_url, @persistent, @connection_options)
# Set headers to an empty hash if none are set.
headers = params[:headers] || {}

View File

@ -79,14 +79,15 @@ module Fog
@voxel_api_key = options[:voxel_api_key]
@voxel_api_secret = options[:voxel_api_secret]
@host = options[:host] || "api.voxel.net"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@persistent = options[:persistent] || false
@connection_options = options[:connection_options] || {}
@host = options[:host] || "api.voxel.net"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@persistent = options[:persistent] || false
Excon.ssl_verify_peer = false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent)
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def request(method_name, options = {})

View File

@ -64,10 +64,12 @@ module Fog
@zerigo_email = options[:zerigo_email]
@zerigo_token = options[:zerigo_token]
@host = options[:host] || "ns.zerigo.com"
@port = options[:port] || 80
@scheme = options[:scheme] || 'http'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection_options = options[:connection_options] || {}
@host = options[:host] || "ns.zerigo.com"
@persistent = options[:persistent] || false
@port = options[:port] || 80
@scheme = options[:scheme] || 'http'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload