Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GH105] Use generic code for service abstraction
Clearing out the copypasta, and handling the two require and two class name combinations allows us to eliminate most of the provider specific rubbish. Version abstraction options have also been disabled. The remaining errors appear to be related to providers who changed the form of their names. To compensate there is a little look up table to correct this for the moment.
- Loading branch information
Showing
15 changed files
with
0 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
module Fog | ||
module Account | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
|
||
if provider == :stormondemand | ||
require "fog/account/storm_on_demand" | ||
Fog::Account::StormOnDemand.new(attributes) | ||
else | ||
raise ArgumentError, "#{provider} has no account service" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,5 @@ | ||
module Fog | ||
module Billing | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
if provider == :stormondemand | ||
require "fog/billing/storm_on_demand" | ||
Fog::Billing::StormOnDemand.new(attributes) | ||
else | ||
raise ArgumentError, "#{provider} has no billing service" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
module Fog | ||
module CDN | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup # prevent delete from having side effects | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
if providers.include?(provider) | ||
require "fog/#{provider}/cdn" | ||
return Fog::CDN.const_get(Fog.providers[provider]).new(attributes) | ||
end | ||
raise ArgumentError, "#{provider} is not a recognized cdn provider" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,5 @@ | ||
module Fog | ||
module Identity | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup # Prevent delete from having side effects | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
|
||
unless providers.include?(provider) | ||
raise ArgumentError, "#{provider} has no identity service" | ||
end | ||
|
||
require "fog/#{provider}/identity" | ||
begin | ||
Fog::Identity.const_get(Fog.providers[provider]) | ||
rescue | ||
Fog.const_get(Fog.providers[provider])::Identity | ||
end.new(attributes) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
module Fog | ||
module Image | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup # Prevent delete from having side effects | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
if providers.include?(provider) | ||
require "fog/#{provider}/image" | ||
return Fog::Image.const_get(Fog.providers[provider]).new(attributes) | ||
end | ||
raise ArgumentError, "#{provider} has no image service" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,5 @@ | ||
module Fog | ||
module Metering | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup # Prevent delete from having side effects | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
if providers.include?(provider) | ||
require "fog/#{provider}/metering" | ||
return Fog::Metering.const_get(Fog.providers[provider]).new(attributes) | ||
end | ||
|
||
raise ArgumentError, "#{provider} has no identity service" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,5 @@ | ||
module Fog | ||
module Monitoring | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
if provider == :stormondemand | ||
require "fog/monitoring/storm_on_demand" | ||
Fog::Monitoring::StormOnDemand.new(attributes) | ||
else | ||
raise ArgumentError, "#{provider} has no monitoring service" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,5 @@ | ||
module Fog | ||
module Network | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup # Prevent delete from having side effects | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
|
||
if provider == :stormondemand | ||
require "fog/network/storm_on_demand" | ||
return Fog::Network::StormOnDemand.new(attributes) | ||
elsif providers.include?(provider) | ||
require "fog/#{provider}/network" | ||
return Fog::Network.const_get(Fog.providers[provider]).new(attributes) | ||
end | ||
|
||
raise ArgumentError, "#{provider} has no network service" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
module Fog | ||
module Orchestration | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup # Prevent delete from having side effects | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
|
||
if providers.include?(provider) | ||
require "fog/#{provider}/orchestration" | ||
return Fog::Orchestration.const_get(Fog.providers[provider]).new(attributes) | ||
end | ||
|
||
raise ArgumentError, "#{provider} has no orchestration service" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
module Fog | ||
module Support | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
|
||
if provider == :stormondemand | ||
require "fog/support/storm_on_demand" | ||
Fog::Support::StormOnDemand.new(attributes) | ||
else | ||
raise ArgumentError, "#{provider} has no support service" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,5 @@ | ||
module Fog | ||
module Volume | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup # Prevent delete from having side effects | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
if providers.include?(provider) | ||
require "fog/#{provider}/volume" | ||
return Fog::Volume.const_get(Fog.providers[provider]).new(attributes) | ||
end | ||
|
||
raise ArgumentError, "#{provider} has no identity service" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,5 @@ | ||
module Fog | ||
module VPN | ||
extend Fog::Core::ServiceAbstraction | ||
|
||
def self.new(attributes) | ||
attributes = attributes.dup | ||
provider = attributes.delete(:provider).to_s.downcase.to_sym | ||
|
||
if provider == :stormondemand | ||
require "fog/vpn/storm_on_demand" | ||
Fog::VPN::StormOnDemand.new(attributes) | ||
else | ||
raise ArgumentError, "#{provider} has no vpn service" | ||
end | ||
end | ||
end | ||
end |