2009-05-18 03:13:06 -04:00
|
|
|
require 'spec'
|
2009-10-03 18:43:19 -04:00
|
|
|
require 'open-uri'
|
2009-05-18 03:13:06 -04:00
|
|
|
|
2009-07-15 14:53:32 -04:00
|
|
|
current_directory = File.dirname(__FILE__)
|
2009-08-10 11:30:28 -04:00
|
|
|
require "#{current_directory}/../lib/fog"
|
2010-02-20 16:40:46 -05:00
|
|
|
require "#{current_directory}/../lib/fog/bin"
|
2010-04-26 19:03:55 -04:00
|
|
|
|
|
|
|
if ENV["FOG_MOCK"] == "true"
|
|
|
|
Fog.mock!
|
|
|
|
end
|
2009-05-19 02:06:49 -04:00
|
|
|
|
2010-05-03 00:46:43 -04:00
|
|
|
require "#{current_directory}/../lib/fog/vcloud/bin"
|
|
|
|
|
2010-01-23 15:35:16 -05:00
|
|
|
module AWS
|
|
|
|
class << self
|
|
|
|
def [](service)
|
|
|
|
@@connections ||= Hash.new do |hash, key|
|
2010-01-26 01:46:18 -05:00
|
|
|
credentials = Fog.credentials.reject do |k, v|
|
2010-01-23 15:35:16 -05:00
|
|
|
![:aws_access_key_id, :aws_secret_access_key].include?(k)
|
|
|
|
end
|
|
|
|
hash[key] = case key
|
|
|
|
when :ec2
|
|
|
|
Fog::AWS::EC2.new(credentials)
|
|
|
|
when :eu_s3
|
|
|
|
Fog::AWS::S3.new(credentials.merge!(:host => 's3-external-3.amazonaws.com'))
|
|
|
|
when :sdb
|
|
|
|
Fog::AWS::SimpleDB.new(credentials)
|
|
|
|
when :s3
|
|
|
|
Fog::AWS::S3.new(credentials)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
end
|
|
|
|
end
|
2009-10-11 16:37:25 -04:00
|
|
|
end
|
|
|
|
|
2010-01-23 15:35:16 -05:00
|
|
|
module Rackspace
|
|
|
|
class << self
|
|
|
|
def [](service)
|
|
|
|
@@connections ||= Hash.new do |hash, key|
|
2010-01-26 01:46:18 -05:00
|
|
|
credentials = Fog.credentials.reject do |k, v|
|
2010-01-23 15:35:16 -05:00
|
|
|
![:rackspace_api_key, :rackspace_username].include?(k)
|
|
|
|
end
|
|
|
|
hash[key] = case key
|
|
|
|
when :files
|
|
|
|
Fog::Rackspace::Files.new(credentials)
|
|
|
|
when :servers
|
|
|
|
Fog::Rackspace::Servers.new(credentials)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
end
|
|
|
|
end
|
2009-08-18 01:39:44 -04:00
|
|
|
end
|
2009-08-12 00:40:59 -04:00
|
|
|
|
2010-01-23 15:35:16 -05:00
|
|
|
module Slicehost
|
|
|
|
class << self
|
|
|
|
def [](service)
|
|
|
|
@@connections ||= Hash.new do |hash, key|
|
2010-01-26 01:46:18 -05:00
|
|
|
credentials = Fog.credentials.reject do |k, v|
|
2010-01-23 15:35:16 -05:00
|
|
|
![:slicehost_password].include?(k)
|
|
|
|
end
|
|
|
|
hash[key] = case key
|
|
|
|
when :slices
|
|
|
|
Fog::Slicehost.new(credentials)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@@connections[service]
|
|
|
|
end
|
|
|
|
end
|
2009-11-27 00:04:49 -05:00
|
|
|
end
|
|
|
|
|
2009-10-10 22:05:17 -04:00
|
|
|
|
2009-05-19 02:06:49 -04:00
|
|
|
|
2009-07-25 21:05:49 -04:00
|
|
|
def eventually(max_delay = 16, &block)
|
|
|
|
delays = [0]
|
|
|
|
delay_step = 1
|
|
|
|
total = 0
|
|
|
|
while true
|
|
|
|
delay = 1
|
|
|
|
delay_step.times do
|
|
|
|
delay *= 2
|
|
|
|
end
|
|
|
|
delays << delay
|
|
|
|
delay_step += 1
|
|
|
|
break if delay >= max_delay
|
|
|
|
end
|
|
|
|
delays.each do |delay|
|
2009-07-16 02:37:22 -04:00
|
|
|
begin
|
|
|
|
sleep(delay)
|
|
|
|
yield
|
|
|
|
break
|
2010-01-09 15:22:45 -05:00
|
|
|
rescue => error
|
2009-07-25 21:05:49 -04:00
|
|
|
raise error if delay >= max_delay
|
2009-07-16 02:37:22 -04:00
|
|
|
end
|
2009-05-19 02:06:49 -04:00
|
|
|
end
|
2009-10-22 12:42:02 -04:00
|
|
|
end
|
|
|
|
|
2009-10-23 15:11:58 -04:00
|
|
|
unless defined?(GENTOO_AMI)
|
|
|
|
GENTOO_AMI = 'ami-5ee70037'
|
|
|
|
end
|
2009-11-05 12:19:48 -05:00
|
|
|
|
|
|
|
def lorem_file
|
|
|
|
File.open(File.dirname(__FILE__) + '/lorem.txt', 'r')
|
2010-05-03 00:46:43 -04:00
|
|
|
end
|