Skip to content

Commit c52d1d5

Browse files
authored
Merge pull request #230 from fog/services
Deprecate wrong provider names
2 parents d7ff1c1 + 3a13d5a commit c52d1d5

File tree

10 files changed

+25
-122
lines changed

10 files changed

+25
-122
lines changed

lib/fog/account.rb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
module Fog
22
module Account
33
extend Fog::ServicesMixin
4-
5-
def self.new(orig_attributes)
6-
attributes = orig_attributes.dup
7-
provider = attributes.delete(:provider).to_s.downcase.to_sym
8-
9-
if provider == :stormondemand
10-
require "fog/account/storm_on_demand"
11-
Fog::Account::StormOnDemand.new(attributes)
12-
else
13-
super(orig_attributes)
14-
end
15-
end
16-
17-
def self.providers
18-
Fog.services[:account] || []
19-
end
204
end
215
end

lib/fog/billing.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
module Fog
22
module Billing
33
extend Fog::ServicesMixin
4-
5-
def self.new(orig_attributes)
6-
attributes = orig_attributes.dup
7-
provider = attributes.delete(:provider).to_s.downcase.to_sym
8-
if provider == :stormondemand
9-
require "fog/billing/storm_on_demand"
10-
Fog::Billing::StormOnDemand.new(attributes)
11-
else
12-
super(orig_attributes)
13-
end
14-
end
154
end
165
end

lib/fog/compute.rb

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ def self.new(orig_attributes)
77
provider = attributes.delete(:provider).to_s.downcase.to_sym
88

99
case provider
10-
when :gogrid
11-
require "fog/go_grid/compute"
12-
Fog::Compute::GoGrid.new(attributes)
13-
when :new_servers
14-
require "fog/bare_metal_cloud/compute"
15-
Fog::Logger.deprecation "`new_servers` is deprecated. Please use `bare_metal_cloud` instead."
16-
Fog::Compute::BareMetalCloud.new(attributes)
17-
when :baremetalcloud
18-
require "fog/bare_metal_cloud/compute"
19-
Fog::Compute::BareMetalCloud.new(attributes)
2010
when :rackspace
2111
version = attributes.delete(:version)
2212
version = version.to_s.downcase.to_sym unless version.nil?
@@ -38,18 +28,6 @@ def self.new(orig_attributes)
3828
require 'fog/digitalocean/compute'
3929
Fog::Compute::DigitalOcean.new(attributes)
4030
end
41-
when :stormondemand
42-
require "fog/compute/storm_on_demand"
43-
Fog::Compute::StormOnDemand.new(attributes)
44-
when :vcloud
45-
require "fog/vcloud/compute"
46-
Fog::Vcloud::Compute.new(attributes)
47-
when :vclouddirector
48-
require "fog/vcloud_director/compute"
49-
Fog::Compute::VcloudDirector.new(attributes)
50-
when :cloudatcost
51-
require "fog/cloudatcost/compute"
52-
Fog::Compute::CloudAtCost.new(attributes)
5331
else
5432
super(orig_attributes)
5533
end

lib/fog/core/services_mixin.rb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def [](provider)
66

77
def new(attributes)
88
attributes = attributes.dup # Prevent delete from having side effects
9-
provider = attributes.delete(:provider).to_s.downcase.to_sym
9+
provider = check_provider_alias(attributes.delete(:provider).to_s.downcase.to_sym)
1010
provider_name = Fog.providers[provider]
1111

1212
raise ArgumentError, "#{provider} is not a recognized provider" unless providers.include?(provider)
@@ -43,5 +43,29 @@ def const_get_args(*args)
4343
def service_name
4444
name.split("Fog::").last
4545
end
46+
47+
def check_provider_alias(provider)
48+
case provider
49+
when :baremetalcloud
50+
Fog::Logger.deprecation(':baremetalcloud is deprecated. Use :bare_metal_cloud instead!')
51+
:bare_metal_cloud
52+
when :gogrid
53+
Fog::Logger.deprecation(':gogrid is deprecated. Use :go_grid instead!')
54+
:go_grid
55+
when :internetarchive
56+
Fog::Logger.deprecation(':internetarchive is deprecated. Use :internet_archive instead!')
57+
:internet_archive
58+
when :new_servers
59+
Fog::Logger.deprecation(':new_servers is deprecated. Use :bare_metal_cloud instead!')
60+
:bare_metal_cloud
61+
when :stormondemand
62+
Fog::Logger.deprecation(':stormondemand is deprecated. Use :storm_on_demand instead!')
63+
:storm_on_demand
64+
when :vclouddirector
65+
Fog::Logger.deprecation(':vclouddirector is deprecated. Use :vcloud_director instead!')
66+
:vcloud_director
67+
else provider
68+
end
69+
end
4670
end
4771
end

lib/fog/dns.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ module Fog
22
module DNS
33
extend Fog::ServicesMixin
44

5-
def self.new(orig_attributes)
6-
attributes = orig_attributes.dup # prevent delete from having side effects
7-
case attributes.delete(:provider).to_s.downcase.to_sym
8-
when :stormondemand
9-
require "fog/dns/storm_on_demand"
10-
Fog::DNS::StormOnDemand.new(attributes)
11-
else
12-
super(orig_attributes)
13-
end
14-
end
15-
165
def self.zones
176
zones = []
187
providers.each do |provider|

lib/fog/monitoring.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
module Fog
22
module Monitoring
33
extend Fog::ServicesMixin
4-
5-
def self.new(orig_attributes)
6-
attributes = orig_attributes.dup
7-
provider = attributes.delete(:provider).to_s.downcase.to_sym
8-
if provider == :stormondemand
9-
require "fog/monitoring/storm_on_demand"
10-
Fog::Monitoring::StormOnDemand.new(attributes)
11-
else
12-
super(orig_attributes)
13-
end
14-
end
154
end
165
end

lib/fog/network.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
module Fog
22
module Network
33
extend Fog::ServicesMixin
4-
5-
def self.new(orig_attributes)
6-
attributes = orig_attributes.dup # Prevent delete from having side effects
7-
provider = attributes.delete(:provider).to_s.downcase.to_sym
8-
9-
if provider == :stormondemand
10-
require "fog/network/storm_on_demand"
11-
return Fog::Network::StormOnDemand.new(attributes)
12-
else
13-
super(orig_attributes)
14-
end
15-
end
164
end
175
end

lib/fog/storage.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,6 @@ module Fog
99
module Storage
1010
extend Fog::ServicesMixin
1111

12-
def self.new(orig_attributes)
13-
attributes = orig_attributes.dup # prevent delete from having side effects
14-
case attributes.delete(:provider).to_s.downcase.to_sym
15-
when :internetarchive
16-
require "fog/internet_archive/storage"
17-
Fog::Storage::InternetArchive.new(attributes)
18-
when :stormondemand
19-
require "fog/storage/storm_on_demand"
20-
Fog::Storage::StormOnDemand.new(attributes)
21-
else
22-
super(orig_attributes)
23-
end
24-
end
25-
2612
def self.directories
2713
directories = []
2814
providers.each do |provider|

lib/fog/support.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
module Fog
22
module Support
33
extend Fog::ServicesMixin
4-
5-
def self.new(orig_attributes)
6-
attributes = orig_attributes.dup
7-
provider = attributes.delete(:provider).to_s.downcase.to_sym
8-
9-
if provider == :stormondemand
10-
require "fog/support/storm_on_demand"
11-
Fog::Support::StormOnDemand.new(attributes)
12-
else
13-
super(orig_attributes)
14-
end
15-
end
164
end
175
end

lib/fog/vpn.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
module Fog
22
module VPN
33
extend Fog::ServicesMixin
4-
5-
def self.new(orig_attributes)
6-
attributes = orig_attributes.dup
7-
provider = attributes.delete(:provider).to_s.downcase.to_sym
8-
9-
if provider == :stormondemand
10-
require "fog/vpn/storm_on_demand"
11-
Fog::VPN::StormOnDemand.new(attributes)
12-
else
13-
super(orig_attributes)
14-
end
15-
end
164
end
175
end

0 commit comments

Comments
 (0)