fog-core 1.31.1 → 1.32.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6225f60258e8f99e143c4f5e7328c08880ef8c0f
4
- data.tar.gz: 0baaf114b5b90e7be5a7f6fcad41208f52d09cd5
3
+ metadata.gz: cce0c130a1aade8f7c0b37686d8c4373108cdb96
4
+ data.tar.gz: d139b954306ca369a9ec3a27ef6a1b3534049f14
5
5
  SHA512:
6
- metadata.gz: 91ac73c15d8a602aadaca938bcf9d68245e1b0164bf9f7fe1cb39d4c4696aa35f3954510ade65d05b4bb095a686721175b6730547bc1a6f535d60134a2ecda4a
7
- data.tar.gz: b71ed95b9f7b69f933d35aaec4dc86a62766aa7b464d833210e8cfec54e4d2435a69d0be3b7a3705b6bf6e44ef965a64f32f91c9317d127f9cabdf7538b5e25a
6
+ metadata.gz: b42044e5b7f6ec5cb1c8d10b5f26d0cd18fbb311b406e1d710d25b32f7644b0780626a872b0bc91d5cef08035a1032f194a3d77aeb02e48bf37560b3d0030d80
7
+ data.tar.gz: 4ef2091abaac8996facfeceebaabadcc8f6ef661b75b4ee6dbeee145ddd5c04289be2aa0bfe38e3cf6dcb7cfbc6057cc272b182d7f0449ac94b1ff30544f8259
@@ -1,3 +1,8 @@
1
+ 1.32.0 07/02/2015
2
+ ==========================================================
3
+
4
+ fix/refactor service initializers
5
+
1
6
  1.31.1 06/17/2015
2
7
  ==========================================================
3
8
 
@@ -1,29 +1,16 @@
1
1
  module Fog
2
2
  module Account
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
3
+ extend Fog::ServicesMixin
6
4
 
7
- def self.new(attributes)
8
- attributes = attributes.dup
5
+ def self.new(orig_attributes)
6
+ attributes = orig_attributes.dup
9
7
  provider = attributes.delete(:provider).to_s.downcase.to_sym
10
8
 
11
9
  if provider == :stormondemand
12
10
  require "fog/account/storm_on_demand"
13
11
  Fog::Account::StormOnDemand.new(attributes)
14
- elsif providers.include?(provider)
15
- begin
16
- require "fog/#{provider}/account"
17
- begin
18
- Fog::Account.const_get(Fog.providers[provider])
19
- rescue
20
- Fog.const_get(Fog.providers[provider])::Account
21
- end.new(attributes)
22
- rescue
23
- raise ArgumentError, "#{provider} has no account service"
24
- end
25
12
  else
26
- raise ArgumentError, "#{provider} is not a recognized provider"
13
+ super(orig_attributes)
27
14
  end
28
15
  end
29
16
 
@@ -1,30 +1,5 @@
1
1
  module Fog
2
2
  module Baremetal
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
6
-
7
- def self.new(attributes)
8
- attributes = attributes.dup # Prevent delete from having side effects
9
- provider = attributes.delete(:provider).to_s.downcase.to_sym
10
- if providers.include?(provider)
11
- begin
12
- require "fog/#{provider}/baremetal"
13
- begin
14
- Fog::Baremetal.const_get(Fog.providers[provider])
15
- rescue
16
- Fog.const_get(Fog.providers[provider])::Baremetal
17
- end.new(attributes)
18
- rescue
19
- raise ArgumentError, "#{provider} has no baremetal service"
20
- end
21
- else
22
- raise ArgumentError, "#{provider} is not a recognized provider"
23
- end
24
- end
25
-
26
- def self.providers
27
- Fog.services[:baremetal]
28
- end
3
+ extend Fog::ServicesMixin
29
4
  end
30
5
  end
@@ -1,33 +1,16 @@
1
1
  module Fog
2
2
  module Billing
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
3
+ extend Fog::ServicesMixin
6
4
 
7
- def self.new(attributes)
8
- attributes = attributes.dup
5
+ def self.new(orig_attributes)
6
+ attributes = orig_attributes.dup
9
7
  provider = attributes.delete(:provider).to_s.downcase.to_sym
10
8
  if provider == :stormondemand
11
9
  require "fog/billing/storm_on_demand"
12
10
  Fog::Billing::StormOnDemand.new(attributes)
13
- elsif providers.include?(provider)
14
- begin
15
- require "fog/#{provider}/billing"
16
- begin
17
- Fog::Account.const_get(Fog.providers[provider])
18
- rescue
19
- Fog.const_get(Fog.providers[provider])::Account
20
- end.new(attributes)
21
- rescue
22
- raise ArgumentError, "#{provider} has no billing service"
23
- end
24
11
  else
25
- raise ArgumentError, "#{provider} is not a recognized provider"
12
+ super(orig_attributes)
26
13
  end
27
14
  end
28
-
29
- def self.providers
30
- Fog.services[:billing]
31
- end
32
15
  end
33
16
  end
@@ -1,30 +1,5 @@
1
1
  module Fog
2
2
  module CDN
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
6
-
7
- def self.new(attributes)
8
- attributes = attributes.dup # prevent delete from having side effects
9
- provider = attributes.delete(:provider).to_s.downcase.to_sym
10
- if providers.include?(provider)
11
- begin
12
- require "fog/#{provider}/cdn"
13
- begin
14
- Fog::CDN.const_get(Fog.providers[provider])
15
- rescue
16
- Fog.const_get(Fog.providers[provider])::CDN
17
- end.new(attributes)
18
- rescue
19
- raise ArgumentError, "#{provider} has no cdn service"
20
- end
21
- else
22
- raise ArgumentError, "#{provider} is not a recognized provider"
23
- end
24
- end
25
-
26
- def self.providers
27
- Fog.services[:cdn]
28
- end
3
+ extend Fog::ServicesMixin
29
4
  end
30
5
  end
@@ -1,11 +1,9 @@
1
1
  module Fog
2
2
  module Compute
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
3
+ extend Fog::ServicesMixin
6
4
 
7
- def self.new(attributes)
8
- attributes = attributes.dup # prevent delete from having side effects
5
+ def self.new(orig_attributes)
6
+ attributes = orig_attributes.dup # prevent delete from having side effects
9
7
  provider = attributes.delete(:provider).to_s.downcase.to_sym
10
8
 
11
9
  case provider
@@ -61,27 +59,10 @@ module Fog
61
59
  require "fog/vcloud_director/compute"
62
60
  Fog::Compute::VcloudDirector.new(attributes)
63
61
  else
64
- if providers.include?(provider)
65
- begin
66
- require "fog/#{provider}/compute"
67
- rescue LoadError
68
- require "fog/compute/#{provider}"
69
- end
70
- begin
71
- Fog::Compute.const_get(Fog.providers[provider])
72
- rescue
73
- Fog.const_get(Fog.providers[provider])::Compute
74
- end.new(attributes)
75
- else
76
- raise ArgumentError, "#{provider} is not a recognized compute provider"
77
- end
62
+ super(orig_attributes)
78
63
  end
79
64
  end
80
65
 
81
- def self.providers
82
- Fog.services[:compute]
83
- end
84
-
85
66
  def self.servers
86
67
  servers = []
87
68
  providers.each do |provider|
@@ -13,6 +13,9 @@ require "ipaddr"
13
13
  # internal core dependencies
14
14
  require File.expand_path('../core/version', __FILE__)
15
15
 
16
+ # Mixins
17
+ require File.expand_path('../core/services_mixin', __FILE__)
18
+
16
19
  require File.expand_path('../core/attributes', __FILE__)
17
20
  require File.expand_path('../core/attributes/default', __FILE__)
18
21
  require File.expand_path('../core/attributes/array', __FILE__)
@@ -0,0 +1,43 @@
1
+ module Fog
2
+ module ServicesMixin
3
+ def [](provider)
4
+ new(:provider => provider)
5
+ end
6
+
7
+ def new(attributes)
8
+ attributes = attributes.dup # Prevent delete from having side effects
9
+ provider = attributes.delete(:provider).to_s.downcase.to_sym
10
+ provider_name = Fog.providers[provider]
11
+
12
+ raise ArgumentError, "#{provider} is not a recognized provider" unless providers.include?(provider)
13
+
14
+ require_service_provider_library(service_name.downcase, provider)
15
+ spc = service_provider_constant(service_name, provider_name)
16
+ spc.new(attributes)
17
+ rescue LoadError, NameError # Only rescue errors in finding the libraries, allow connection errors through to the caller
18
+ raise ArgumentError, "#{provider} has no #{service_name.downcase} service"
19
+ end
20
+
21
+ def providers
22
+ Fog.services[service_name.downcase.to_sym] || []
23
+ end
24
+
25
+ private
26
+
27
+ def require_service_provider_library(service, provider)
28
+ require "fog/#{provider}/#{service}"
29
+ rescue LoadError # Try to require the service provider in an alternate location
30
+ require "fog/#{service}/#{provider}"
31
+ end
32
+
33
+ def service_provider_constant(service_name, provider_name)
34
+ Fog.const_get(service_name).const_get(provider_name)
35
+ rescue NameError # Try to find the constant from in an alternate location
36
+ Fog.const_get(provider_name).const_get(service_name)
37
+ end
38
+
39
+ def service_name
40
+ name.split("Fog::").last
41
+ end
42
+ end
43
+ end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Core
3
- VERSION = "1.31.1"
3
+ VERSION = "1.32.0"
4
4
  end
5
5
  end
@@ -1,33 +1,18 @@
1
1
  module Fog
2
2
  module DNS
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
3
+ extend Fog::ServicesMixin
6
4
 
7
- def self.new(attributes)
8
- attributes = attributes.dup # prevent delete from having side effects
5
+ def self.new(orig_attributes)
6
+ attributes = orig_attributes.dup # prevent delete from having side effects
9
7
  case provider = attributes.delete(:provider).to_s.downcase.to_sym
10
8
  when :stormondemand
11
9
  require "fog/dns/storm_on_demand"
12
10
  Fog::DNS::StormOnDemand.new(attributes)
13
11
  else
14
- if providers.include?(provider)
15
- require "fog/#{provider}/dns"
16
- begin
17
- Fog::DNS.const_get(Fog.providers[provider])
18
- rescue
19
- Fog.const_get(Fog.providers[provider])::DNS
20
- end.new(attributes)
21
- else
22
- raise ArgumentError, "#{provider} is not a recognized dns provider"
23
- end
12
+ super(orig_attributes)
24
13
  end
25
14
  end
26
15
 
27
- def self.providers
28
- Fog.services[:dns]
29
- end
30
-
31
16
  def self.zones
32
17
  zones = []
33
18
  providers.each do |provider|
@@ -1,27 +1,5 @@
1
1
  module Fog
2
2
  module Identity
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
6
-
7
- def self.new(attributes)
8
- attributes = attributes.dup # Prevent delete from having side effects
9
- provider = attributes.delete(:provider).to_s.downcase.to_sym
10
-
11
- unless providers.include?(provider)
12
- raise ArgumentError, "#{provider} has no identity service"
13
- end
14
-
15
- require "fog/#{provider}/identity"
16
- begin
17
- Fog::Identity.const_get(Fog.providers[provider])
18
- rescue
19
- Fog.const_get(Fog.providers[provider])::Identity
20
- end.new(attributes)
21
- end
22
-
23
- def self.providers
24
- Fog.services[:identity]
25
- end
3
+ extend Fog::ServicesMixin
26
4
  end
27
5
  end
@@ -1,30 +1,5 @@
1
1
  module Fog
2
2
  module Image
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
6
-
7
- def self.new(attributes)
8
- attributes = attributes.dup # Prevent delete from having side effects
9
- provider = attributes.delete(:provider).to_s.downcase.to_sym
10
- if providers.include?(provider)
11
- begin
12
- require "fog/#{provider}/image"
13
- begin
14
- Fog::Image.const_get(Fog.providers[provider])
15
- rescue
16
- Fog.const_get(Fog.providers[provider])::Image
17
- end.new(attributes)
18
- rescue
19
- raise ArgumentError, "#{provider} has no image service"
20
- end
21
- else
22
- raise ArgumentError, "#{provider} is not a recognized provider"
23
- end
24
- end
25
-
26
- def self.providers
27
- Fog.services[:image]
28
- end
3
+ extend Fog::ServicesMixin
29
4
  end
30
5
  end
@@ -1,30 +1,5 @@
1
1
  module Fog
2
2
  module Metering
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
6
-
7
- def self.new(attributes)
8
- attributes = attributes.dup # Prevent delete from having side effects
9
- provider = attributes.delete(:provider).to_s.downcase.to_sym
10
- if providers.include?(provider)
11
- begin
12
- require "fog/#{provider}/metering"
13
- begin
14
- Fog::Metering.const_get(Fog.providers[provider])
15
- rescue
16
- Fog.const_get(Fog.providers[provider])::Metering
17
- end.new(attributes)
18
- rescue
19
- raise ArgumentError, "#{provider} has no metering service"
20
- end
21
- else
22
- raise ArgumentError, "#{provider} is not a recognized provider"
23
- end
24
- end
25
-
26
- def self.providers
27
- Fog.services[:metering]
28
- end
3
+ extend Fog::ServicesMixin
29
4
  end
30
5
  end
@@ -1,33 +1,16 @@
1
1
  module Fog
2
2
  module Monitoring
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
3
+ extend Fog::ServicesMixin
6
4
 
7
- def self.new(attributes)
8
- attributes = attributes.dup
5
+ def self.new(orig_attributes)
6
+ attributes = orig_attributes.dup
9
7
  provider = attributes.delete(:provider).to_s.downcase.to_sym
10
8
  if provider == :stormondemand
11
9
  require "fog/monitoring/storm_on_demand"
12
10
  Fog::Monitoring::StormOnDemand.new(attributes)
13
- elsif providers.include?(provider)
14
- begin
15
- require "fog/#{provider}/monitoring"
16
- begin
17
- Fog::Monitoring.const_get(Fog.providers[provider])
18
- rescue
19
- Fog.const_get(Fog.providers[provider])::Monitoring
20
- end.new(attributes)
21
- rescue
22
- raise ArgumentError, "#{provider} has no monitoring service"
23
- end
24
11
  else
25
- raise ArgumentError, "#{provider} is not a recognized provider"
12
+ super(orig_attributes)
26
13
  end
27
14
  end
28
-
29
- def self.providers
30
- Fog.services[:monitoring]
31
- end
32
15
  end
33
16
  end
@@ -1,34 +1,17 @@
1
1
  module Fog
2
2
  module Network
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
3
+ extend Fog::ServicesMixin
6
4
 
7
- def self.new(attributes)
8
- attributes = attributes.dup # Prevent delete from having side effects
5
+ def self.new(orig_attributes)
6
+ attributes = orig_attributes.dup # Prevent delete from having side effects
9
7
  provider = attributes.delete(:provider).to_s.downcase.to_sym
10
8
 
11
9
  if provider == :stormondemand
12
10
  require "fog/network/storm_on_demand"
13
11
  return Fog::Network::StormOnDemand.new(attributes)
14
- elsif providers.include?(provider)
15
- begin
16
- require "fog/#{provider}/network"
17
- begin
18
- Fog::Network.const_get(Fog.providers[provider])
19
- rescue
20
- Fog.const_get(Fog.providers[provider])::Network
21
- end.new(attributes)
22
- rescue
23
- raise ArgumentError, "#{provider} has no network service"
24
- end
25
12
  else
26
- raise ArgumentError, "#{provider} is not a recognized provider"
13
+ super(orig_attributes)
27
14
  end
28
15
  end
29
-
30
- def self.providers
31
- Fog.services[:network]
32
- end
33
16
  end
34
17
  end
@@ -1,30 +1,5 @@
1
1
  module Fog
2
2
  module Orchestration
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
6
-
7
- def self.new(attributes)
8
- attributes = attributes.dup # Prevent delete from having side effects
9
- provider = attributes.delete(:provider).to_s.downcase.to_sym
10
- if providers.include?(provider)
11
- begin
12
- require "fog/#{provider}/orchestration"
13
- begin
14
- Fog::Orchestration.const_get(Fog.providers[provider])
15
- rescue
16
- Fog.const_get(Fog.providers[provider])::Orchestration
17
- end.new(attributes)
18
- rescue
19
- raise ArgumentError, "#{provider} has no orchestration service"
20
- end
21
- else
22
- raise ArgumentError, "#{provider} is not a recognized provider"
23
- end
24
- end
25
-
26
- def self.providers
27
- Fog.services[:orchestration]
28
- end
3
+ extend Fog::ServicesMixin
29
4
  end
30
5
  end
@@ -7,12 +7,10 @@ end
7
7
 
8
8
  module Fog
9
9
  module Storage
10
- def self.[](provider)
11
- new(:provider => provider)
12
- end
10
+ extend Fog::ServicesMixin
13
11
 
14
- def self.new(attributes)
15
- attributes = attributes.dup # prevent delete from having side effects
12
+ def self.new(orig_attributes)
13
+ attributes = orig_attributes.dup # prevent delete from having side effects
16
14
  case provider = attributes.delete(:provider).to_s.downcase.to_sym
17
15
  when :internetarchive
18
16
  require "fog/internet_archive/storage"
@@ -21,16 +19,7 @@ module Fog
21
19
  require "fog/storage/storm_on_demand"
22
20
  Fog::Storage::StormOnDemand.new(attributes)
23
21
  else
24
- if providers.include?(provider)
25
- require "fog/#{provider}/storage"
26
- begin
27
- Fog::Storage.const_get(Fog.providers[provider])
28
- rescue
29
- Fog.const_get(Fog.providers[provider])::Storage
30
- end.new(attributes)
31
- else
32
- raise ArgumentError, "#{provider} is not a recognized storage provider"
33
- end
22
+ super(orig_attributes)
34
23
  end
35
24
  end
36
25
 
@@ -87,9 +76,5 @@ module Fog
87
76
  }
88
77
  }
89
78
  end
90
-
91
- def self.providers
92
- Fog.services[:storage]
93
- end
94
79
  end
95
80
  end
@@ -1,34 +1,17 @@
1
1
  module Fog
2
2
  module Support
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
3
+ extend Fog::ServicesMixin
6
4
 
7
- def self.new(attributes)
8
- attributes = attributes.dup
5
+ def self.new(orig_attributes)
6
+ attributes = orig_attributes.dup
9
7
  provider = attributes.delete(:provider).to_s.downcase.to_sym
10
8
 
11
9
  if provider == :stormondemand
12
10
  require "fog/support/storm_on_demand"
13
11
  Fog::Support::StormOnDemand.new(attributes)
14
- elsif providers.include?(provider)
15
- begin
16
- require "fog/#{provider}/support"
17
- begin
18
- Fog::Support.const_get(Fog.providers[provider])
19
- rescue
20
- Fog.const_get(Fog.providers[provider])::Support
21
- end.new(attributes)
22
- rescue
23
- raise ArgumentError, "#{provider} has no support service"
24
- end
25
12
  else
26
- raise ArgumentError, "#{provider} is not a recognized provider"
13
+ super(orig_attributes)
27
14
  end
28
15
  end
29
-
30
- def self.providers
31
- Fog.services[:support]
32
- end
33
16
  end
34
17
  end
@@ -1,30 +1,5 @@
1
1
  module Fog
2
2
  module Volume
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
6
-
7
- def self.new(attributes)
8
- attributes = attributes.dup # Prevent delete from having side effects
9
- provider = attributes.delete(:provider).to_s.downcase.to_sym
10
- if providers.include?(provider)
11
- begin
12
- require "fog/#{provider}/volume"
13
- begin
14
- Fog::Volume.const_get(Fog.providers[provider])
15
- rescue
16
- Fog.const_get(Fog.providers[provider])::Volume
17
- end.new(attributes)
18
- rescue
19
- raise ArgumentError, "#{provider} has no volume service"
20
- end
21
- else
22
- raise ArgumentError, "#{provider} is not a recognized provider"
23
- end
24
- end
25
-
26
- def self.providers
27
- Fog.services[:volume]
28
- end
3
+ extend Fog::ServicesMixin
29
4
  end
30
5
  end
@@ -1,34 +1,17 @@
1
1
  module Fog
2
2
  module VPN
3
- def self.[](provider)
4
- new(:provider => provider)
5
- end
3
+ extend Fog::ServicesMixin
6
4
 
7
- def self.new(attributes)
8
- attributes = attributes.dup
5
+ def self.new(orig_attributes)
6
+ attributes = orig_attributes.dup
9
7
  provider = attributes.delete(:provider).to_s.downcase.to_sym
10
8
 
11
9
  if provider == :stormondemand
12
10
  require "fog/vpn/storm_on_demand"
13
11
  Fog::VPN::StormOnDemand.new(attributes)
14
- elsif providers.include?(provider)
15
- begin
16
- require "fog/#{provider}/vpn"
17
- begin
18
- Fog::VPN.const_get(Fog.providers[provider])
19
- rescue
20
- Fog.const_get(Fog.providers[provider])::VPN
21
- end.new(attributes)
22
- rescue
23
- raise ArgumentError, "#{provider} has no vpn service"
24
- end
25
12
  else
26
- raise ArgumentError, "#{provider} is not a recognized provider"
13
+ super(orig_attributes)
27
14
  end
28
15
  end
29
-
30
- def self.providers
31
- Fog.services[:vpn]
32
- end
33
16
  end
34
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.31.1
4
+ version: 1.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Light
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-17 00:00:00.000000000 Z
12
+ date: 2015-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -263,6 +263,7 @@ files:
263
263
  - lib/fog/core/provider.rb
264
264
  - lib/fog/core/scp.rb
265
265
  - lib/fog/core/service.rb
266
+ - lib/fog/core/services_mixin.rb
266
267
  - lib/fog/core/ssh.rb
267
268
  - lib/fog/core/stringify_keys.rb
268
269
  - lib/fog/core/time.rb