2010-09-29 16:22:30 -04:00
|
|
|
require 'fog/core/credentials'
|
2010-06-23 20:22:44 -04:00
|
|
|
|
2010-02-12 00:41:37 -05:00
|
|
|
module Fog
|
|
|
|
class << self
|
|
|
|
|
2010-09-21 14:11:15 -04:00
|
|
|
def providers
|
2010-09-03 18:32:30 -04:00
|
|
|
[
|
|
|
|
::AWS,
|
2010-09-14 13:40:02 -04:00
|
|
|
::Bluebox,
|
2010-11-08 07:21:31 -05:00
|
|
|
::Brightbox,
|
2010-09-03 18:32:30 -04:00
|
|
|
::GoGrid,
|
2010-09-18 13:40:48 -04:00
|
|
|
::Google,
|
2010-09-03 18:32:30 -04:00
|
|
|
::Linode,
|
|
|
|
::Local,
|
|
|
|
::NewServers,
|
|
|
|
::Rackspace,
|
|
|
|
::Slicehost,
|
2010-12-15 17:56:46 -05:00
|
|
|
::Terremark,
|
|
|
|
::Zerigo
|
2010-09-21 14:11:15 -04:00
|
|
|
].select {|provider| provider.available?}
|
|
|
|
end
|
|
|
|
|
|
|
|
def modules
|
|
|
|
[
|
2010-09-14 13:40:02 -04:00
|
|
|
::Vcloud
|
2010-09-03 18:32:30 -04:00
|
|
|
].select {|_module_| _module_.initialized?}
|
2010-02-12 00:41:37 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2010-09-21 14:11:15 -04:00
|
|
|
|
|
|
|
class Bin
|
|
|
|
class << self
|
|
|
|
|
|
|
|
def available?
|
|
|
|
availability = true
|
|
|
|
for service in services
|
|
|
|
begin
|
2010-12-06 22:49:58 -05:00
|
|
|
service = self.class_for(service)
|
|
|
|
availability &&= service.requirements.all? { |requirement| Fog.credentials.include?(requirement) }
|
|
|
|
rescue ArgumentError => e
|
|
|
|
warning = "[yellow][WARN] #{e.message}[/]"
|
|
|
|
Formatador.display_line(warning)
|
|
|
|
availability = false
|
|
|
|
rescue => e
|
2010-09-21 14:11:15 -04:00
|
|
|
availability = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if availability
|
|
|
|
for service in services
|
2010-12-06 22:49:58 -05:00
|
|
|
for collection in self.class_for(service).collections
|
2010-09-21 18:57:27 -04:00
|
|
|
unless self.respond_to?(collection)
|
|
|
|
self.class_eval <<-EOS, __FILE__, __LINE__
|
|
|
|
def self.#{collection}
|
|
|
|
self[:#{service}].#{collection}
|
|
|
|
end
|
|
|
|
EOS
|
|
|
|
end
|
2010-09-21 14:11:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
availability
|
|
|
|
end
|
|
|
|
|
|
|
|
def collections
|
|
|
|
services.map {|service| self[service].collections}.flatten.sort_by {|service| service.to_s}
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-04-03 03:29:42 -04:00
|
|
|
end
|
2010-09-21 14:11:15 -04:00
|
|
|
|
2011-01-07 18:41:51 -05:00
|
|
|
require 'fog/bin/aws'
|
|
|
|
require 'fog/bin/bluebox'
|
|
|
|
require 'fog/bin/brightbox'
|
|
|
|
require 'fog/bin/go_grid'
|
|
|
|
require 'fog/bin/google'
|
|
|
|
require 'fog/bin/linode'
|
|
|
|
require 'fog/bin/local'
|
|
|
|
require 'fog/bin/new_servers'
|
|
|
|
require 'fog/bin/rackspace'
|
|
|
|
require 'fog/bin/slicehost'
|
|
|
|
require 'fog/bin/terremark'
|
|
|
|
require 'fog/bin/vcloud'
|
|
|
|
require 'fog/bin/zerigo'
|