1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge branch 'master' of github.com:redzebra/fog into auto_scaling_20100801

This commit is contained in:
Nick Osborn 2011-06-22 21:40:29 +01:00
commit de4bc21ded
16 changed files with 49 additions and 25 deletions

View file

@ -127,7 +127,7 @@ module Fog
private
def authenticate
if @rackspace_must_reauthenticate or @rackspace_auth_token.empty?
if @rackspace_must_reauthenticate || @rackspace_auth_token.nil?
options = {
:rackspace_api_key => @rackspace_api_key,
:rackspace_username => @rackspace_username,

View file

@ -121,7 +121,7 @@ module Fog
response.body = JSON.parse(response.body)
end
if response.body.keys.include?('full_error')
raise(Fog::StormOnDemand::Compute::Error, response.body.inspect)
raise(Fog::Compute::StormOnDemand::Error, response.body.inspect)
end
response
end

View file

@ -98,7 +98,7 @@ module Fog
:path => "/version/1.0/"
)
unless data.body['stat'] == 'ok'
raise Fog::Voxel::Compute::Error, "#{data.body['err']['msg']}"
raise Fog::Compute::Voxel::Error, "#{data.body['err']['msg']}"
end
data
rescue Excon::Errors::HTTPStatusError => error

View file

@ -64,15 +64,22 @@ module Fog
end
def self.reset
providers = Fog.providers.map {|p| Fog.const_get(p) }
possible_service_constants = providers.map {|p| p.constants.map {|c| p.const_get(c) } }.flatten
# c.to_sym is 1.8.7 / 1.9.2 compat
services = possible_service_constants.select {|s| s.constants.map {|c| c.to_sym }.include?(:Mock) }
service_mocks = services.map {|s| s.const_get(:Mock) }
mocked_services = []
Fog.constants.map do |x|
x_const = Fog.const_get(x)
x_const.respond_to?(:constants) && x_const.constants.map do |y|
y_const = x_const.const_get(y)
y_const.respond_to?(:constants) && y_const.constants.map do |z|
if z.to_sym == :Mock
mocked_services << y_const.const_get(z)
end
end
end
end
service_mocks.each do |service_mock|
next unless service_mock.respond_to?(:reset)
service_mock.reset
for mocked_service in mocked_services
next unless mocked_service.respond_to?(:reset)
mocked_service.reset
end
end

View file

@ -19,7 +19,7 @@ module Fog
data = connection.get_domain(zone_id).body
data.merge!(:id => data['name'])
new(data)
rescue Excon::Errors::NotFound
rescue Fog::Service::NotFound
nil
end

View file

@ -1,6 +1,6 @@
module Fog
module Zerigo
class DNS
module DNS
class Zerigo
class Real
require 'fog/dns/parsers/zerigo/get_zone_stats'
@ -25,7 +25,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::DNS::GetZoneStats.new,
:parser => Fog::Parsers::DNS::Zerigo::GetZoneStats.new,
:path => "/api/1.1/zones/#{zone_id}/stats.xml"
)
end

View file

@ -1,6 +1,6 @@
module Fog
module Zerigo
class DNS
module DNS
class Zerigo
class Real
require 'fog/dns/parsers/zerigo/list_hosts'
@ -29,7 +29,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::DNS::ListHosts.new,
:parser => Fog::Parsers::DNS::Zerigo::ListHosts.new,
:path => "/api/1.1/zones/#{zone_id}/hosts.xml"
)
end

View file

@ -1,6 +1,6 @@
module Fog
module Zerigo
class DNS
module DNS
class Zerigo
class Real
require 'fog/dns/parsers/zerigo/list_zones'
@ -34,7 +34,7 @@ module Fog
request(
:expects => 200,
:method => 'GET',
:parser => Fog::Parsers::Zerigo::DNS::ListZones.new,
:parser => Fog::Parsers::DNS::Zerigo::ListZones.new,
:path => '/api/1.1/zones.xml'
)
end

View file

@ -14,9 +14,13 @@ module Fog
load(data)
end
# Supply the :cdn_cname option to use the Rackspace CDN CNAME functionality on the public_url.
#
# > fog.directories.get('video', :cdn_cname => 'http://cdn.lunenburg.org').files.first.public_url
# => 'http://cdn.lunenburg.org/hayley-dancing.mov'
def get(key, options = {})
data = connection.get_container(key, options)
directory = new(:key => key)
directory = new(:key => key, :cdn_cname => options[:cdn_cname])
for key, value in data.headers
if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key)
directory.merge_attributes(key => value)

View file

@ -11,6 +11,7 @@ module Fog
attribute :bytes, :aliases => 'X-Container-Bytes-Used'
attribute :count, :aliases => 'X-Container-Object-Count'
attribute :cdn_cname
def destroy
requires :key
@ -42,7 +43,7 @@ module Fog
if connection.rackspace_cdn_ssl == true
response.headers['X-CDN-SSL-URI']
else
response.headers['X-CDN-URI']
cdn_cname || response.headers['X-CDN-URI']
end
end
rescue Fog::Service::NotFound

View file

@ -1,6 +1,6 @@
for provider, config in compute_providers
next if [Voxel].include?(provider)
next if [:voxel].include?(provider)
Shindo.tests("Fog::Compute[:#{provider}] | flavors", [provider]) do

View file

@ -1,5 +1,8 @@
for provider, config in dns_providers
# FIXME: delay/timing breaks things :(
next if [:dnsmadeeasy].include?(provider)
Shindo.tests("Fog::DNS[:#{provider}] | record", [provider]) do
record_attributes = {

View file

@ -1,5 +1,8 @@
for provider, config in dns_providers
# FIXME: delay/timing breaks things :(
next if [:dnsmadeeasy].include?(provider)
Shindo.tests("Fog::DNS[:#{provider}] | records", [provider]) do
record_attributes = {

View file

@ -1,5 +1,8 @@
for provider, config in dns_providers
# FIXME: delay/timing breaks things :(
next if [:dnsmadeeasy].include?(provider)
Shindo.tests("Fog::DNS[:#{provider}] | zone", [provider]) do
zone_attributes = {

View file

@ -1,5 +1,8 @@
for provider, config in dns_providers
# FIXME: delay/timing breaks things :(
next if [:dnsmadeeasy].include?(provider)
Shindo.tests("Fog::DNS[:#{provider}] | zones", [provider]) do
zone_attributes = {

View file

@ -38,7 +38,7 @@ def collection_tests(collection, params = {}, mocks_implemented = true)
tests('failure') do
if !Fog.mocking? || mocks_implemented
@identity = @identity.to_s.gsub(/\w/, rand(10).to_s)
@identity = @identity.to_s.gsub(/\w/, Fog::Mock.random_letters(1))
end
tests("#get('#{@identity}')").returns(nil) do