Merge pull request #2711 from fog/connection_deprecation_warning

[core] Deprecate Fog::Connection
This commit is contained in:
Paul Thornthwaite 2014-02-27 22:24:54 +00:00
commit 7a152a2dc9
94 changed files with 156 additions and 112 deletions

View File

@ -83,7 +83,7 @@ module Fog
@hmac = Fog::HMAC.new('sha1', @storage_secret_decoded)
@persistent = options.fetch(:persistent, false)
@connection = Fog::Connection.new("#{@prefix}://#{@storage_host}:#{@storage_port}",
@connection = Fog::XML::Connection.new("#{@prefix}://#{@storage_host}:#{@storage_port}",
@persistent, @connection_options)
end

View File

@ -104,7 +104,7 @@ module Fog
@port = options[:port] || 443
@persistent = options[:persistent] || false
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -78,7 +78,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -154,7 +154,7 @@ EOF
@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)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -60,7 +60,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -104,7 +104,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -399,7 +399,7 @@ module Fog
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
end
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -62,7 +62,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
setup_credentials(options)
end

View File

@ -99,7 +99,7 @@ module Fog
@scheme = options[:scheme] || 'https'
@version = options[:version] || '2012-02-29'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -88,7 +88,7 @@ module Fog
@port = options[:port] || '443'
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
private

View File

@ -62,7 +62,7 @@ module Fog
@path = options[:path] || '/'
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new(
@connection = Fog::XML::Connection.new(
"#{@scheme}://#{@host}:#{@port}#{@path}", options[:persistent]
)
end

View File

@ -139,7 +139,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -73,7 +73,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@region = options[:region]
end

View File

@ -134,7 +134,7 @@ module Fog
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end

View File

@ -170,7 +170,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -168,7 +168,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@version = options[:version] || '2013-05-15'
end

View File

@ -90,7 +90,7 @@ module Fog
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end

View File

@ -62,7 +62,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -89,7 +89,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
private

View File

@ -61,7 +61,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -89,7 +89,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -523,7 +523,7 @@ DATA
else
@connection = nil
end
@connection ||= Fog::Connection.new(uri, @persistent, @connection_options)
@connection ||= Fog::XML::Connection.new(uri, @persistent, @connection_options)
end
def request(params, &block)
@ -550,7 +550,7 @@ DATA
headers = (error.response.is_a?(Hash) ? error.response[:headers] : error.response.headers)
uri = URI.parse(headers['Location'])
Fog::Logger.warning("fog: followed redirect to #{uri.host}, connecting to the matching region will be more performant")
response = Fog::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, @connection_options).request(original_params, &block)
response = Fog::XML::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, @connection_options).request(original_params, &block)
end
response

View File

@ -83,7 +83,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload

View File

@ -58,7 +58,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -50,7 +50,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:bluebox_port] || 443
@scheme = options[:bluebox_scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -68,7 +68,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:bluebox_port] || 443
@scheme = options[:bluebox_scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -59,7 +59,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:bluebox_port] || 443
@scheme = options[:bluebox_scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -84,7 +84,7 @@ module Fog
@clodo_must_reauthenticate = false
authenticate
Excon.ssl_verify_peer = false if options[:clodo_servicenet] == true
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
end
def reload

View File

@ -13,7 +13,7 @@ module Fog
url = clodo_auth_url.match(/^https?:/) ? \
clodo_auth_url : 'https://' + clodo_auth_url
uri = URI.parse(url)
connection = Fog::Connection.new(url)
connection = Fog::XML::Connection.new(url)
@clodo_api_key = options[:clodo_api_key]
@clodo_username = options[:clodo_username]
response = connection.request({

View File

@ -37,7 +37,7 @@ module Fog
@api_version = options[:cloudsigma_api_version] || '2.0'
@path_prefix = "#{@api_path_prefix}/#{@api_version}/"
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def request(params)

View File

@ -149,7 +149,7 @@ module Fog
@path = options[:cloudstack_path] || '/client/api'
@port = options[:cloudstack_port] || 443
@scheme = options[:cloudstack_scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:cloudstack_persistent], {:ssl_verify_peer => false})
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", options[:cloudstack_persistent], {:ssl_verify_peer => false})
end
def reload

View File

@ -12,13 +12,14 @@ module Fog
#
# @see https://github.com/geemus/excon/blob/master/lib/excon/connection.rb
#
class Connection < Fog::XML::SAXParserConnection
class Connection < Fog::XML::Connection
def request(params, &block)
if (parser = params.delete(:parser))
super(parser, params)
if params.key?(:parser)
Fog::Logger.deprecation("Fog::XML::Connection is deprecated use Fog::XML::Connection instead [light_black](#{caller.first})[/]")
else
original_request(params)
Fog::Logger.deprecation("Fog::XML::Connection is deprecated use Fog::Core::Connection instead [light_black](#{caller.first})[/]")
end
super(params)
end
end
end

View File

@ -77,7 +77,7 @@ module Fog
@digitalocean_client_id = options[:digitalocean_client_id]
@digitalocean_api_url = options[:digitalocean_api_url] || \
"https://api.digitalocean.com"
@connection = Fog::Connection.new(@digitalocean_api_url)
@connection = Fog::XML::Connection.new(@digitalocean_api_url)
end
def reload

View File

@ -70,7 +70,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -87,7 +87,7 @@ module Fog
@persistent = options.fetch(: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)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -57,7 +57,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent)
end
def reload

View File

@ -72,7 +72,7 @@ module Fog
@persistent = options[:persistent] || false
@scheme = options[:scheme] || 'https'
@version = options[:version] || '3.5.2'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def auth_token

View File

@ -317,7 +317,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, @connection_options)
@connections[host_url] ||= Fog::XML::Connection.new(host_url, @persistent, @connection_options)
# Set headers to an empty hash if none are set.
headers = set_extra_headers_for(params) || set_extra_headers_for({})

View File

@ -79,7 +79,7 @@ module Fog
@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)
@connection = Fog::XML::Connection.new(@api_url, @persistent, @connection_options)
end
def request(method_name, options = {})

View File

@ -68,7 +68,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -283,7 +283,7 @@ DATA
else
@connection = nil
end
@connection ||= Fog::Connection.new(uri, @persistent, @connection_options)
@connection ||= Fog::XML::Connection.new(uri, @persistent, @connection_options)
end
private

View File

@ -138,7 +138,7 @@ module Fog
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -127,7 +127,7 @@ module Fog
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -115,7 +115,7 @@ module Fog
@path = uri.path.chomp("/")
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@enabled = true
end
end

View File

@ -220,7 +220,7 @@ module Fog
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -274,7 +274,7 @@ module Fog
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -82,7 +82,7 @@ module Fog
# Set the User-Agent
@user_agent = options[:user_agent]
set_user_agent_header(connection_options, "fog/#{Fog::VERSION}", @user_agent)
connection = Fog::Connection.new(service_url, false, connection_options)
connection = Fog::XML::Connection.new(service_url, false, connection_options)
@hp_access_key = options[:hp_access_key]
@hp_secret_key = options[:hp_secret_key]
response = connection.request({
@ -158,7 +158,7 @@ module Fog
# Set the User-Agent. If the caller sets a user_agent, use it.
@user_agent = options[:user_agent]
set_user_agent_header(connection_options, "fog/#{Fog::VERSION}", @user_agent)
connection = Fog::Connection.new(service_url, false, connection_options)
connection = Fog::XML::Connection.new(service_url, false, connection_options)
### Implement HP Control Services Authentication services ###
# Get the style of auth credentials passed, defaults to access/secret key style

View File

@ -97,7 +97,7 @@ module Fog
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -132,7 +132,7 @@ module Fog
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -155,7 +155,7 @@ module Fog
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -351,7 +351,7 @@ module Fog
@port = uri.port
@scheme = uri.scheme
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -16,7 +16,7 @@ module Fog
1800
end
class Connection < Fog::Connection
class Connection < Fog::XML::Connection
def initialize(user, password)
@user = user

View File

@ -269,7 +269,7 @@ module Fog
@port = options[:port] || 80
@scheme = options[:scheme] || 'http'
end
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
end
def reload
@ -376,7 +376,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, @connection_options).request(original_params, &block)
response = Fog::XML::Connection.new("#{@scheme}://#{uri.host}:#{@port}", false, @connection_options).request(original_params, &block)
end
response

View File

@ -188,7 +188,7 @@ module Fog
raise ArgumentError, "Must provide either a joyent_password or joyent_keyname and joyent_keyfile pair"
end
@connection = Fog::Connection.new(
@connection = Fog::XML::Connection.new(
@joyent_url,
@persistent,
@connection_options

View File

@ -158,7 +158,7 @@ module Fog
raise ArgumentError, "Must provide either a joyent_password or joyent_keyname and joyent_keyfile pair"
end
@connection = Fog::Connection.new(
@connection = Fog::XML::Connection.new(
@joyent_url,
@persistent,
@connection_options

View File

@ -83,7 +83,7 @@ module Fog
@host = options[:host] || "api.linode.com"
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent])
end
def reload

View File

@ -58,7 +58,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -89,7 +89,7 @@ module Fog
@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)
@connection = Fog::XML::Connection.new(@api_url, @persistent, @connection_options)
end
def request(command, params, options)

View File

@ -320,7 +320,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def credentials
@ -422,7 +422,7 @@ module Fog
# Not all implementations have identity service in the catalog
if @openstack_identity_public_endpoint || @openstack_management_url
@identity_connection = Fog::Connection.new(
@identity_connection = Fog::XML::Connection.new(
@openstack_identity_public_endpoint || @openstack_management_url,
false, @connection_options)
end

View File

@ -63,7 +63,7 @@ module Fog
# legacy v1.0 style auth
def self.authenticate_v1(options, connection_options = {})
uri = options[:openstack_auth_uri]
connection = Fog::Connection.new(uri.to_s, false, connection_options)
connection = Fog::XML::Connection.new(uri.to_s, false, connection_options)
@openstack_api_key = options[:openstack_api_key]
@openstack_username = options[:openstack_username]
@ -102,7 +102,7 @@ module Fog
unless service
unless tenant_name
response = Fog::Connection.new(
response = Fog::XML::Connection.new(
"#{uri.scheme}://#{uri.host}:#{uri.port}/v2.0/tenants", false, connection_options).request({
:expects => [200, 204],
:headers => {'Content-Type' => 'application/json',
@ -186,7 +186,7 @@ module Fog
auth_token = options[:openstack_auth_token] || options[:unscoped_token]
uri = options[:openstack_auth_uri]
connection = Fog::Connection.new(uri.to_s, false, connection_options)
connection = Fog::XML::Connection.new(uri.to_s, false, connection_options)
request_body = {:auth => Hash.new}
if auth_token
@ -213,7 +213,7 @@ module Fog
end
def self.get_supported_version(supported_versions, uri, auth_token, connection_options = {})
connection = Fog::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, connection_options)
connection = Fog::XML::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, connection_options)
response = connection.request({
:expects => [200, 204, 300],
:headers => {'Content-Type' => 'application/json',

View File

@ -200,7 +200,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def credentials

View File

@ -122,7 +122,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def credentials

View File

@ -116,7 +116,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def credentials

View File

@ -256,7 +256,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def credentials

View File

@ -114,7 +114,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def credentials
@ -214,7 +214,7 @@ module Fog
# Not all implementations have identity service in the catalog
if @openstack_identity_public_endpoint || @openstack_management_url
@identity_connection = Fog::Connection.new(
@identity_connection = Fog::XML::Connection.new(
@openstack_identity_public_endpoint || @openstack_management_url,
false, @connection_options)
end

View File

@ -92,7 +92,7 @@ module Fog
@openstack_temp_url_key = options[:openstack_temp_url_key]
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -136,7 +136,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def credentials

View File

@ -96,7 +96,7 @@ module Fog
authenticate
@connection = Fog::Connection.new(endpoint_uri.to_s, @options[:persistent], @options[:connection_options])
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @options[:persistent], @options[:connection_options])
end
def request(params, parse_json = true, &block)

View File

@ -82,7 +82,7 @@ module Fog
deprecation_warnings(options)
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true)

View File

@ -143,7 +143,7 @@ module Fog
@persistent = options[:persistent] || false
if endpoint_uri
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@enabled = true
end
end

View File

@ -197,7 +197,7 @@ module Fog
authenticate
Excon.defaults[:ssl_verify_peer] = false if service_net?
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def reload

View File

@ -145,7 +145,7 @@ module Fog
deprecation_warnings(options)
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true)

View File

@ -104,7 +104,7 @@ module Fog
url = rackspace_auth_url.match(/^https?:/) ? \
rackspace_auth_url : 'https://' + rackspace_auth_url
uri = URI.parse(url)
connection = Fog::Connection.new(url, false, connection_options)
connection = Fog::XML::Connection.new(url, false, connection_options)
@rackspace_api_key = options[:rackspace_api_key]
@rackspace_username = options[:rackspace_username]
response = connection.request({

View File

@ -82,7 +82,7 @@ module Fog
deprecation_warnings(options)
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true)

View File

@ -101,7 +101,7 @@ module Fog
deprecation_warnings(options)
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def endpoint_uri(service_endpoint_url=nil)

View File

@ -74,7 +74,7 @@ module Fog
def initialize(options={})
apply_options(options)
@connection = Fog::Connection.new(@uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(@uri.to_s, @persistent, @connection_options)
authenticate
end

View File

@ -119,7 +119,7 @@ module Fog
deprecation_warnings(options)
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true)

View File

@ -140,7 +140,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def reload

View File

@ -378,7 +378,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
def request(params, parse_json = true, &block)

View File

@ -419,7 +419,7 @@ module Fog
authenticate
@persistent = options[:persistent] || false
Excon.defaults[:ssl_verify_peer] = false if service_net?
@connection = Fog::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
@connection = Fog::XML::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end
# Using SSL?

View File

@ -48,7 +48,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 443
@scheme = options[:scheme] || 'https'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -53,7 +53,7 @@ module Fog
@connection_options = options[:connection_options] || {}
@persistent = options[:persistent] || false
@raw_connection = Fog::Connection.new(riakcs_uri, @persistent, @connection_options)
@raw_connection = Fog::XML::Connection.new(riakcs_uri, @persistent, @connection_options)
@s3_connection = Fog::Storage.new(
:provider => 'AWS',

View File

@ -59,7 +59,7 @@ module Fog
@api_key = options[:serverlove_api_key] || Fog.credentials[:serverlove_api_key]
@api_host = options[:serverlove_api_url] || Fog.credentials[:serverlove_api_url] || API_HOST
@connection = Fog::Connection.new("https://#{@api_uuid}:#{@api_key}@#{@api_host}")
@connection = Fog::XML::Connection.new("https://#{@api_uuid}:#{@api_key}@#{@api_host}")
end
def request(params)

View File

@ -15,7 +15,7 @@ module Fog
@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}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -46,7 +46,7 @@ module Fog
@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)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def default_vdc_id

View File

@ -319,7 +319,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, @connection_options)
@connections[host_url] ||= Fog::XML::Connection.new(host_url, @persistent, @connection_options)
# Set headers to an empty hash if none are set.
headers = params[:headers] || {}

View File

@ -335,7 +335,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || Fog::Compute::VcloudDirector::Defaults::PORT
@scheme = options[:scheme] || Fog::Compute::VcloudDirector::Defaults::SCHEME
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@end_point = "#{@scheme}://#{@host}#{@path}/"
@api_version = options[:vcloud_director_api_version] || Fog::Compute::VcloudDirector::Defaults::API_VERSION
@show_progress = options[:vcloud_director_show_progress]
@ -670,7 +670,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || Fog::Compute::VcloudDirector::Defaults::PORT
@scheme = options[:scheme] || Fog::Compute::VcloudDirector::Defaults::SCHEME
#@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
#@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@end_point = "#{@scheme}://#{@host}#{@path}/"
@api_version = options[:vcloud_director_api_version] || Fog::Compute::VcloudDirector::Defaults::API_VERSION
end

View File

@ -86,7 +86,7 @@ module Fog
@connection_options[:ssl_verify_peer] = false
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def request(method_name, options = {})

View File

@ -164,7 +164,7 @@ module Fog
@host = options[:xenserver_pool_master]
@username = options[:xenserver_username]
@password = options[:xenserver_password]
@connection = Fog::Connection.new(@host)
@connection = Fog::XML::Connection.new(@host)
@connection.authenticate(@username, @password)
end

View File

@ -1,5 +1,6 @@
require "nokogiri"
require "fog/core/parser"
require "fog/xml/sax_parser_connection"
module Fog
@ -15,7 +16,14 @@ module Fog
# its services
#
module XML
class Connection < Fog::XML::SAXParserConnection
def request(params, &block)
if (parser = params.delete(:parser))
super(parser, params)
else
original_request(params)
end
end
end
end
end
require "fog/xml/sax_parser_connection"

13
lib/fog/xml/connection.rb Normal file
View File

@ -0,0 +1,13 @@
module Fog
module XML
class Connection < SAXParserConnection
def request(params, &block)
if (parser = params.delete(:parser))
super(parser, params)
else
original_request(params)
end
end
end
end
end

View File

@ -79,7 +79,7 @@ module Fog
@persistent = options[:persistent] || false
@port = options[:port] || 80
@scheme = options[:scheme] || 'http'
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
def reload

View File

@ -0,0 +1,30 @@
require "minitest/autorun"
require "fog"
# Note this is going to be part of fog-xml eventually
class TestFogXMLConnection < MiniTest::Unit::TestCase
def setup
@connection = Fog::XML::Connection.new("http://localhost")
end
def teardown
Excon.stubs.clear
end
def test_respond_to_request
assert_respond_to @connection, :request
end
def test_request_with_parser
@parser = Fog::ToHashDocument.new
Excon.stub({}, { :status => 200, :body => "<xml></xml>" })
response = @connection.request(:parser => @parser, :mock => true)
assert_equal({ :xml => "" }, response.body)
end
def test_request_without_parser
Excon.stub({}, { :status => 200, :body => "<xml></xml>" })
response = @connection.request(:mock => true)
assert_equal("<xml></xml>", response.body)
end
end

View File

@ -1,8 +0,0 @@
require "minitest/autorun"
class HelloWorldTest < Minitest::Test
# This is a placeholder to ensure minitest is being picked up by rake
def test_truth
assert true
end
end