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

[core] cleanup providers/services setup

This commit is contained in:
geemus 2011-02-04 11:17:30 -05:00
parent 11e85b60db
commit a1402c5faa
17 changed files with 39 additions and 45 deletions

View file

@ -10,7 +10,7 @@ end
require 'fog/bin' require 'fog/bin'
providers = Fog.providers.map{|provider| provider.to_s} providers = Fog.providers.map{|provider| provider.to_s.split('::').last}
providers = if providers.length > 1 providers = if providers.length > 1
providers[0...-1].join(', ') << ' and ' << providers[-1] providers[0...-1].join(', ') << ' and ' << providers[-1]
else else

View file

@ -3,24 +3,6 @@ require 'fog/core/credentials'
module Fog module Fog
class << self class << self
def providers
[
::AWS,
::Bluebox,
::Brightbox,
::GoGrid,
::Google,
::Linode,
::Local,
::NewServers,
::Rackspace,
::Slicehost,
::Terremark,
::TerremarkEcloud,
::Zerigo
].select {|provider| provider.available?}
end
def modules def modules
[ [
::Vcloud ::Vcloud

View file

@ -61,14 +61,14 @@ class AWS < Fog::Bin
when :storage when :storage
Fog::Storage.new(:provider => 'AWS') Fog::Storage.new(:provider => 'AWS')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services def services
[:cdn, :compute, :dns, :elb, :iam, :sdb, :ses, :storage] Fog::AWS.services
end end
end end

View file

@ -29,7 +29,7 @@ class Bluebox < Fog::Bin
end end
def services def services
[:compute] Fog::Bluebox.services
end end
end end

View file

@ -16,19 +16,19 @@ class Brightbox < Fog::Bin
when :compute when :compute
Fog::Compute.new(:provider => 'Brightbox') Fog::Compute.new(:provider => 'Brightbox')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services
[:compute]
end
def account def account
@@connections[:compute].account @@connections[:compute].account
end end
def services
Fog::Brightbox.services
end
end end
end end

View file

@ -22,14 +22,14 @@ class GoGrid < Fog::Bin
Formatador.display_line(warning) Formatador.display_line(warning)
Fog::Compute.new(:provider => 'GoGrid') Fog::Compute.new(:provider => 'GoGrid')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services def services
[:compute] Fog::GoGrid.services
end end
end end

View file

@ -16,14 +16,14 @@ class Google < Fog::Bin
when :storage when :storage
Fog::Storage.new(:provider => 'Google') Fog::Storage.new(:provider => 'Google')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services def services
[:storage] Fog::Google.services
end end
end end

View file

@ -26,14 +26,14 @@ class Linode < Fog::Bin
Formatador.display_line(warning) Formatador.display_line(warning)
Fog::Compute.new(:provider => 'Linode') Fog::Compute.new(:provider => 'Linode')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services def services
[:compute, :dns] Fog::Linode.services
end end
end end

View file

@ -22,14 +22,14 @@ class Local < Fog::Bin
when :storage when :storage
Fog::Storage.new(:provider => 'Local') Fog::Storage.new(:provider => 'Local')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services def services
[:storage] Fog::Local.services
end end
end end

View file

@ -22,14 +22,14 @@ class NewServers < Fog::Bin
Formatador.display_line(warning) Formatador.display_line(warning)
Fog::Compute.new(:provider => 'NewServers') Fog::Compute.new(:provider => 'NewServers')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services def services
[:compute] Fog::NewServers.services
end end
end end

View file

@ -38,14 +38,14 @@ class Rackspace < Fog::Bin
when :storage when :storage
Fog::Storage.new(:provider => 'Rackspace') Fog::Storage.new(:provider => 'Rackspace')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services def services
[:cdn, :compute, :storage] Fog::Rackspace.services
end end
end end

View file

@ -26,14 +26,14 @@ class Slicehost < Fog::Bin
when :dns when :dns
Fog::DNS.new(:provider => 'Slicehost') Fog::DNS.new(:provider => 'Slicehost')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services def services
[:compute, :dns] Fog::Slicehost.services
end end
end end

View file

@ -21,7 +21,7 @@ class TerremarkEcloud < Fog::Bin
end end
def services def services
[:compute] Fog::TerremarkEcloud.services
end end
end end

View file

@ -42,7 +42,7 @@ module Vcloud
_module_ = eval(credentials.delete(:module)) _module_ = eval(credentials.delete(:module))
hash[key] = _module_.new(credentials) hash[key] = _module_.new(credentials)
else else
raise ArgumentError.new("Unregistered service: :#{key}. Registered services are: #{Vcloud.registered_services}") raise ArgumentError.new("Unregistered service: #{key.inspect}. Registered services are: #{Vcloud.registered_services}")
end end
end end
@@connections[service] @@connections[service]

View file

@ -16,14 +16,14 @@ class Zerigo < Fog::Bin
when :dns when :dns
Fog::DNS.new(:provider => 'Zerigo') Fog::DNS.new(:provider => 'Zerigo')
else else
raise ArgumentError, "Unrecognized service: #{service}" raise ArgumentError, "Unrecognized service: #{key.inspect}"
end end
end end
@@connections[service] @@connections[service]
end end
def services def services
[:dns] Fog::Zerigo.services
end end
end end

View file

@ -1,6 +1,10 @@
module Fog module Fog
module Provider module Provider
def self.extended(base)
Fog.providers << base
end
def service(new_service, path) def service(new_service, path)
services << new_service services << new_service
require File.join('fog', path) require File.join('fog', path)

View file

@ -1,3 +1,11 @@
module Fog
def self.providers
@providers ||= []
end
end
require 'fog/providers/aws' require 'fog/providers/aws'
require 'fog/providers/bluebox' require 'fog/providers/bluebox'
require 'fog/providers/brightbox' require 'fog/providers/brightbox'