Skip to content

Instantly share code, notes, and snippets.

@krames
Last active December 14, 2015 09:39
Show Gist options
  • Save krames/5066149 to your computer and use it in GitHub Desktop.
Save krames/5066149 to your computer and use it in GitHub Desktop.
This gist contains a patch to fix Rackspace Database support in Fog 1.9.0. Please refer to https://github.com/fog/fog/pull/1615 for more information.
if Fog::VERSION == "1.9.0"
Fog::Logger.warning "PATCHING Fog::Rackspace::Databases to include latest endpoints and fix request issue"
require 'rubygems'
require 'fog'
Fog::Rackspace::Databases.send :remove_const, :DFW_ENDPOINT
Fog::Rackspace::Databases.send :remove_const, :LON_ENDPOINT
Fog::Rackspace::Databases.send :remove_const, :ORD_ENDPOINT
module Fog
module Rackspace
class Databases < Fog::Service
DFW_ENDPOINT = 'https://dfw.databases.api.rackspacecloud.com/v1.0'
LON_ENDPOINT = 'https://lon.databases.api.rackspacecloud.com/v1.0'
ORD_ENDPOINT = 'https://ord.databases.api.rackspacecloud.com/v1.0'
class Real
def request(params)
begin
response = @connection.request(params.merge!({
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'X-Auth-Token' => @auth_token
}.merge!(params[:headers] || {}),
:host => @host,
:path => "#{@path}/#{params[:path]}"
}))
rescue Excon::Errors::NotFound => error
raise NotFound.slurp error
rescue Excon::Errors::BadRequest => error
raise BadRequest.slurp error
rescue Excon::Errors::InternalServerError => error
raise InternalServerError.slurp error
rescue Excon::Errors::HTTPStatusError => error
raise ServiceError.slurp error
end
unless response.body.empty?
response.body = Fog::JSON.decode(response.body)
end
response
end
end
end
end
end
else
Fog::Logger.warning "PATCHING Fog::Rackspace::Databases - does not apply for #{Fog::VERSION}. Please remove it."
end
@krames
Copy link
Author

krames commented Mar 5, 2013

This patch is no longer necessary with Fog 1.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment