mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[fog] Cleanup: Use the service registry for requiring libs where possible
This commit is contained in:
parent
9dc15001ce
commit
eb0545b724
8 changed files with 42 additions and 153 deletions
|
@ -7,19 +7,12 @@ module Fog
|
||||||
|
|
||||||
def self.new(attributes)
|
def self.new(attributes)
|
||||||
attributes = attributes.dup # prevent delete from having side effects
|
attributes = attributes.dup # prevent delete from having side effects
|
||||||
case provider = attributes.delete(:provider).to_s.downcase.to_sym
|
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||||
when :aws
|
if self.providers.include?(provider)
|
||||||
require 'fog/aws/cdn'
|
require "fog/#{provider}/cdn"
|
||||||
Fog::CDN::AWS.new(attributes)
|
return Fog::CDN.const_get(Fog.providers[provider]).new(attributes)
|
||||||
when :hp
|
|
||||||
require 'fog/hp/cdn'
|
|
||||||
Fog::CDN::HP.new(attributes)
|
|
||||||
when :rackspace
|
|
||||||
require 'fog/rackspace/cdn'
|
|
||||||
Fog::CDN::Rackspace.new(attributes)
|
|
||||||
else
|
|
||||||
raise ArgumentError.new("#{provider} is not a recognized cdn provider")
|
|
||||||
end
|
end
|
||||||
|
raise ArgumentError.new("#{provider} is not a recognized cdn provider")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.providers
|
def self.providers
|
||||||
|
|
|
@ -9,46 +9,11 @@ module Fog
|
||||||
attributes = attributes.dup # prevent delete from having side effects
|
attributes = attributes.dup # prevent delete from having side effects
|
||||||
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||||
|
|
||||||
|
|
||||||
case provider
|
case provider
|
||||||
when :aws
|
|
||||||
require 'fog/aws/compute'
|
|
||||||
Fog::Compute::AWS.new(attributes)
|
|
||||||
when :bluebox
|
|
||||||
require 'fog/bluebox/compute'
|
|
||||||
Fog::Compute::Bluebox.new(attributes)
|
|
||||||
when :brightbox
|
|
||||||
require 'fog/brightbox/compute'
|
|
||||||
Fog::Compute::Brightbox.new(attributes)
|
|
||||||
when :cloudstack
|
|
||||||
require 'fog/cloudstack/compute'
|
|
||||||
Fog::Compute::Cloudstack.new(attributes)
|
|
||||||
when :clodo
|
|
||||||
require 'fog/clodo/compute'
|
|
||||||
Fog::Compute::Clodo.new(attributes)
|
|
||||||
when :ecloud
|
|
||||||
require 'fog/ecloud/compute'
|
|
||||||
Fog::Compute::Ecloud.new(attributes)
|
|
||||||
when :glesys
|
|
||||||
require 'fog/glesys/compute'
|
|
||||||
Fog::Compute::Glesys.new(attributes)
|
|
||||||
when :gogrid
|
when :gogrid
|
||||||
require 'fog/go_grid/compute'
|
require 'fog/go_grid/compute'
|
||||||
Fog::Compute::GoGrid.new(attributes)
|
Fog::Compute::GoGrid.new(attributes)
|
||||||
when :hp
|
|
||||||
require 'fog/hp/compute'
|
|
||||||
Fog::Compute::HP.new(attributes)
|
|
||||||
when :ibm
|
|
||||||
require 'fog/ibm/compute'
|
|
||||||
Fog::Compute::IBM.new(attributes)
|
|
||||||
when :joyent
|
|
||||||
require 'fog/joyent/compute'
|
|
||||||
Fog::Compute::Joyent.new(attributes)
|
|
||||||
when :libvirt
|
|
||||||
require 'fog/libvirt/compute'
|
|
||||||
Fog::Compute::Libvirt.new(attributes)
|
|
||||||
when :linode
|
|
||||||
require 'fog/linode/compute'
|
|
||||||
Fog::Compute::Linode.new(attributes)
|
|
||||||
when :new_servers
|
when :new_servers
|
||||||
require 'fog/bare_metal_cloud/compute'
|
require 'fog/bare_metal_cloud/compute'
|
||||||
Fog::Logger.deprecation "`new_servers` is deprecated. Please use `bare_metal_cloud` instead."
|
Fog::Logger.deprecation "`new_servers` is deprecated. Please use `bare_metal_cloud` instead."
|
||||||
|
@ -56,15 +21,6 @@ module Fog
|
||||||
when :baremetalcloud
|
when :baremetalcloud
|
||||||
require 'fog/bare_metal_cloud/compute'
|
require 'fog/bare_metal_cloud/compute'
|
||||||
Fog::Compute::BareMetalCloud.new(attributes)
|
Fog::Compute::BareMetalCloud.new(attributes)
|
||||||
when :ninefold
|
|
||||||
require 'fog/ninefold/compute'
|
|
||||||
Fog::Compute::Ninefold.new(attributes)
|
|
||||||
when :openstack
|
|
||||||
require 'fog/openstack/compute'
|
|
||||||
Fog::Compute::OpenStack.new(attributes)
|
|
||||||
when :ovirt
|
|
||||||
require 'fog/ovirt/compute'
|
|
||||||
Fog::Compute::Ovirt.new(attributes)
|
|
||||||
when :rackspace
|
when :rackspace
|
||||||
version = attributes.delete(:version)
|
version = attributes.delete(:version)
|
||||||
version = version.to_s.downcase.to_sym unless version.nil?
|
version = version.to_s.downcase.to_sym unless version.nil?
|
||||||
|
@ -76,31 +32,17 @@ module Fog
|
||||||
require 'fog/rackspace/compute'
|
require 'fog/rackspace/compute'
|
||||||
Fog::Compute::Rackspace.new(attributes)
|
Fog::Compute::Rackspace.new(attributes)
|
||||||
end
|
end
|
||||||
when :serverlove
|
|
||||||
require 'fog/serverlove/compute'
|
|
||||||
Fog::Compute::Serverlove.new(attributes)
|
|
||||||
when :stormondemand
|
when :stormondemand
|
||||||
require 'fog/storm_on_demand/compute'
|
require 'fog/storm_on_demand/compute'
|
||||||
Fog::Compute::StormOnDemand.new(attributes)
|
Fog::Compute::StormOnDemand.new(attributes)
|
||||||
when :vcloud
|
|
||||||
require 'fog/vcloud/compute'
|
|
||||||
Fog::Vcloud::Compute.new(attributes)
|
|
||||||
when :virtualbox
|
when :virtualbox
|
||||||
require 'fog/virtual_box/compute'
|
require 'fog/virtual_box/compute'
|
||||||
Fog::Compute::VirtualBox.new(attributes)
|
Fog::Compute::VirtualBox.new(attributes)
|
||||||
when :vmfusion
|
|
||||||
require 'fog/vmfusion/compute'
|
|
||||||
Fog::Compute::Vmfusion.new(attributes)
|
|
||||||
when :voxel
|
|
||||||
require 'fog/voxel/compute'
|
|
||||||
Fog::Compute::Voxel.new(attributes)
|
|
||||||
when :vsphere
|
|
||||||
require 'fog/vsphere/compute'
|
|
||||||
Fog::Compute::Vsphere.new(attributes)
|
|
||||||
when :xenserver
|
|
||||||
require 'fog/xenserver/compute'
|
|
||||||
Fog::Compute::XenServer.new(attributes)
|
|
||||||
else
|
else
|
||||||
|
if self.providers.include?(provider)
|
||||||
|
require "fog/#{provider}/compute"
|
||||||
|
return Fog::Compute.const_get(Fog.providers[provider]).new(attributes)
|
||||||
|
end
|
||||||
raise ArgumentError.new("#{provider} is not a recognized compute provider")
|
raise ArgumentError.new("#{provider} is not a recognized compute provider")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,37 +7,14 @@ module Fog
|
||||||
|
|
||||||
def self.new(attributes)
|
def self.new(attributes)
|
||||||
attributes = attributes.dup # prevent delete from having side effects
|
attributes = attributes.dup # prevent delete from having side effects
|
||||||
case provider = attributes.delete(:provider).to_s.downcase.to_sym
|
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||||
when :aws
|
|
||||||
require 'fog/aws/dns'
|
if self.providers.include?(provider)
|
||||||
Fog::DNS::AWS.new(attributes)
|
require "fog/#{provider}/dns"
|
||||||
when :bluebox
|
return Fog::DNS.const_get(Fog.providers[provider]).new(attributes)
|
||||||
require 'fog/bluebox/dns'
|
|
||||||
Fog::DNS::Bluebox.new(attributes)
|
|
||||||
when :dnsimple
|
|
||||||
require 'fog/dnsimple/dns'
|
|
||||||
Fog::DNS::DNSimple.new(attributes)
|
|
||||||
when :dnsmadeeasy
|
|
||||||
require 'fog/dnsmadeeasy/dns'
|
|
||||||
Fog::DNS::DNSMadeEasy.new(attributes)
|
|
||||||
when :dreamhost
|
|
||||||
require 'fog/dreamhost/dns'
|
|
||||||
Fog::DNS::Dreamhost.new(attributes)
|
|
||||||
when :dynect
|
|
||||||
require 'fog/dynect/dns'
|
|
||||||
Fog::DNS::Dynect.new(attributes)
|
|
||||||
when :linode
|
|
||||||
require 'fog/linode/dns'
|
|
||||||
Fog::DNS::Linode.new(attributes)
|
|
||||||
when :zerigo
|
|
||||||
require 'fog/zerigo/dns'
|
|
||||||
Fog::DNS::Zerigo.new(attributes)
|
|
||||||
when :rackspace
|
|
||||||
require 'fog/rackspace/dns'
|
|
||||||
Fog::DNS::Rackspace.new(attributes)
|
|
||||||
else
|
|
||||||
raise ArgumentError.new("#{provider} is not a recognized dns provider")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
raise ArgumentError.new("#{provider} is not a recognized dns provider")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.providers
|
def self.providers
|
||||||
|
|
|
@ -11,10 +11,11 @@ module Fog
|
||||||
when :rackspace
|
when :rackspace
|
||||||
require 'fog/rackspace/identity'
|
require 'fog/rackspace/identity'
|
||||||
Fog::Rackspace::Identity.new(attributes)
|
Fog::Rackspace::Identity.new(attributes)
|
||||||
when :openstack
|
|
||||||
require 'fog/openstack/identity'
|
|
||||||
Fog::Identity::OpenStack.new(attributes)
|
|
||||||
else
|
else
|
||||||
|
if self.providers.include?(provider)
|
||||||
|
require "fog/#{provider}/identity"
|
||||||
|
return Fog::Identity.const_get(Fog.providers[provider]).new(attributes)
|
||||||
|
end
|
||||||
raise ArgumentError.new("#{provider} has no identity service")
|
raise ArgumentError.new("#{provider} has no identity service")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,13 +7,12 @@ module Fog
|
||||||
|
|
||||||
def self.new(attributes)
|
def self.new(attributes)
|
||||||
attributes = attributes.dup # Prevent delete from having side effects
|
attributes = attributes.dup # Prevent delete from having side effects
|
||||||
case provider = attributes.delete(:provider).to_s.downcase.to_sym
|
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||||
when :openstack
|
if self.providers.include?(provider)
|
||||||
require 'fog/openstack/image'
|
require "fog/#{provider}/image"
|
||||||
Fog::Image::OpenStack.new(attributes)
|
return Fog::Image.const_get(Fog.providers[provider]).new(attributes)
|
||||||
else
|
|
||||||
raise ArgumentError.new("#{provider} has no identity service")
|
|
||||||
end
|
end
|
||||||
|
raise ArgumentError.new("#{provider} has no identity service")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.providers
|
def self.providers
|
||||||
|
|
|
@ -9,13 +9,12 @@ module Fog
|
||||||
attributes = attributes.dup # Prevent delete from having side effects
|
attributes = attributes.dup # Prevent delete from having side effects
|
||||||
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||||
|
|
||||||
case provider
|
if self.providers.include?(provider)
|
||||||
when :openstack
|
require "fog/#{provider}/network"
|
||||||
require 'fog/openstack/network'
|
return Fog::Network.const_get(Fog.providers[provider]).new(attributes)
|
||||||
Fog::Network::OpenStack.new(attributes)
|
|
||||||
else
|
|
||||||
raise ArgumentError.new("#{provider} has no network service")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
raise ArgumentError.new("#{provider} has no network service")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.providers
|
def self.providers
|
||||||
|
|
|
@ -8,37 +8,15 @@ module Fog
|
||||||
def self.new(attributes)
|
def self.new(attributes)
|
||||||
attributes = attributes.dup # prevent delete from having side effects
|
attributes = attributes.dup # prevent delete from having side effects
|
||||||
case provider = attributes.delete(:provider).to_s.downcase.to_sym
|
case provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||||
when :atmos
|
|
||||||
require 'fog/atmos/storage'
|
|
||||||
Fog::Storage::Atmos.new(attributes)
|
|
||||||
when :aws
|
|
||||||
require 'fog/aws/storage'
|
|
||||||
Fog::Storage::AWS.new(attributes)
|
|
||||||
when :google
|
|
||||||
require 'fog/google/storage'
|
|
||||||
Fog::Storage::Google.new(attributes)
|
|
||||||
when :hp
|
|
||||||
require 'fog/hp/storage'
|
|
||||||
Fog::Storage::HP.new(attributes)
|
|
||||||
when :ibm
|
|
||||||
require 'fog/ibm/storage'
|
|
||||||
Fog::Storage::IBM.new(attributes)
|
|
||||||
when :internetarchive
|
when :internetarchive
|
||||||
require 'fog/internet_archive/storage'
|
require 'fog/internet_archive/storage'
|
||||||
Fog::Storage::InternetArchive.new(attributes)
|
Fog::Storage::InternetArchive.new(attributes)
|
||||||
when :local
|
|
||||||
require 'fog/local/storage'
|
|
||||||
Fog::Storage::Local.new(attributes)
|
|
||||||
when :ninefold
|
|
||||||
require 'fog/ninefold/storage'
|
|
||||||
Fog::Storage::Ninefold.new(attributes)
|
|
||||||
when :rackspace
|
|
||||||
require 'fog/rackspace/storage'
|
|
||||||
Fog::Storage::Rackspace.new(attributes)
|
|
||||||
when :openstack
|
|
||||||
require 'fog/openstack/storage'
|
|
||||||
Fog::Storage::OpenStack.new(attributes)
|
|
||||||
else
|
else
|
||||||
|
if self.providers.include?(provider)
|
||||||
|
require "fog/#{provider}/storage"
|
||||||
|
return Fog::Storage.const_get(Fog.providers[provider]).new(attributes)
|
||||||
|
end
|
||||||
|
|
||||||
raise ArgumentError.new("#{provider} is not a recognized storage provider")
|
raise ArgumentError.new("#{provider} is not a recognized storage provider")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,13 +7,13 @@ module Fog
|
||||||
|
|
||||||
def self.new(attributes)
|
def self.new(attributes)
|
||||||
attributes = attributes.dup # Prevent delete from having side effects
|
attributes = attributes.dup # Prevent delete from having side effects
|
||||||
case provider = attributes.delete(:provider).to_s.downcase.to_sym
|
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||||
when :openstack
|
if self.providers.include?(provider)
|
||||||
require 'fog/openstack/volume'
|
require "fog/#{provider}/volume"
|
||||||
Fog::Volume::OpenStack.new(attributes)
|
return Fog::Volume.const_get(Fog.providers[provider]).new(attributes)
|
||||||
else
|
|
||||||
raise ArgumentError.new("#{provider} has no identity service")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
raise ArgumentError.new("#{provider} has no identity service")
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.providers
|
def self.providers
|
||||||
|
|
Loading…
Reference in a new issue