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:
parent
11e85b60db
commit
a1402c5faa
17 changed files with 39 additions and 45 deletions
2
bin/fog
2
bin/fog
|
@ -10,7 +10,7 @@ end
|
|||
|
||||
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[0...-1].join(', ') << ' and ' << providers[-1]
|
||||
else
|
||||
|
|
|
@ -3,24 +3,6 @@ require 'fog/core/credentials'
|
|||
module Fog
|
||||
class << self
|
||||
|
||||
def providers
|
||||
[
|
||||
::AWS,
|
||||
::Bluebox,
|
||||
::Brightbox,
|
||||
::GoGrid,
|
||||
::Google,
|
||||
::Linode,
|
||||
::Local,
|
||||
::NewServers,
|
||||
::Rackspace,
|
||||
::Slicehost,
|
||||
::Terremark,
|
||||
::TerremarkEcloud,
|
||||
::Zerigo
|
||||
].select {|provider| provider.available?}
|
||||
end
|
||||
|
||||
def modules
|
||||
[
|
||||
::Vcloud
|
||||
|
|
|
@ -61,14 +61,14 @@ class AWS < Fog::Bin
|
|||
when :storage
|
||||
Fog::Storage.new(:provider => 'AWS')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:cdn, :compute, :dns, :elb, :iam, :sdb, :ses, :storage]
|
||||
Fog::AWS.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -29,7 +29,7 @@ class Bluebox < Fog::Bin
|
|||
end
|
||||
|
||||
def services
|
||||
[:compute]
|
||||
Fog::Bluebox.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -16,19 +16,19 @@ class Brightbox < Fog::Bin
|
|||
when :compute
|
||||
Fog::Compute.new(:provider => 'Brightbox')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:compute]
|
||||
end
|
||||
|
||||
def account
|
||||
@@connections[:compute].account
|
||||
end
|
||||
|
||||
def services
|
||||
Fog::Brightbox.services
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,14 +22,14 @@ class GoGrid < Fog::Bin
|
|||
Formatador.display_line(warning)
|
||||
Fog::Compute.new(:provider => 'GoGrid')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:compute]
|
||||
Fog::GoGrid.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -16,14 +16,14 @@ class Google < Fog::Bin
|
|||
when :storage
|
||||
Fog::Storage.new(:provider => 'Google')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:storage]
|
||||
Fog::Google.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -26,14 +26,14 @@ class Linode < Fog::Bin
|
|||
Formatador.display_line(warning)
|
||||
Fog::Compute.new(:provider => 'Linode')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:compute, :dns]
|
||||
Fog::Linode.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -22,14 +22,14 @@ class Local < Fog::Bin
|
|||
when :storage
|
||||
Fog::Storage.new(:provider => 'Local')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:storage]
|
||||
Fog::Local.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -22,14 +22,14 @@ class NewServers < Fog::Bin
|
|||
Formatador.display_line(warning)
|
||||
Fog::Compute.new(:provider => 'NewServers')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:compute]
|
||||
Fog::NewServers.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -38,14 +38,14 @@ class Rackspace < Fog::Bin
|
|||
when :storage
|
||||
Fog::Storage.new(:provider => 'Rackspace')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:cdn, :compute, :storage]
|
||||
Fog::Rackspace.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -26,14 +26,14 @@ class Slicehost < Fog::Bin
|
|||
when :dns
|
||||
Fog::DNS.new(:provider => 'Slicehost')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:compute, :dns]
|
||||
Fog::Slicehost.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -21,7 +21,7 @@ class TerremarkEcloud < Fog::Bin
|
|||
end
|
||||
|
||||
def services
|
||||
[:compute]
|
||||
Fog::TerremarkEcloud.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -42,7 +42,7 @@ module Vcloud
|
|||
_module_ = eval(credentials.delete(:module))
|
||||
hash[key] = _module_.new(credentials)
|
||||
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
|
||||
@@connections[service]
|
||||
|
|
|
@ -16,14 +16,14 @@ class Zerigo < Fog::Bin
|
|||
when :dns
|
||||
Fog::DNS.new(:provider => 'Zerigo')
|
||||
else
|
||||
raise ArgumentError, "Unrecognized service: #{service}"
|
||||
raise ArgumentError, "Unrecognized service: #{key.inspect}"
|
||||
end
|
||||
end
|
||||
@@connections[service]
|
||||
end
|
||||
|
||||
def services
|
||||
[:dns]
|
||||
Fog::Zerigo.services
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
module Fog
|
||||
module Provider
|
||||
|
||||
def self.extended(base)
|
||||
Fog.providers << base
|
||||
end
|
||||
|
||||
def service(new_service, path)
|
||||
services << new_service
|
||||
require File.join('fog', path)
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
module Fog
|
||||
|
||||
def self.providers
|
||||
@providers ||= []
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
require 'fog/providers/aws'
|
||||
require 'fog/providers/bluebox'
|
||||
require 'fog/providers/brightbox'
|
||||
|
|
Loading…
Reference in a new issue