fog-core 2.1.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/FUNDING.yml +2 -0
- data/.github/dependabot.yml +10 -0
- data/.github/workflows/ci.yml +32 -0
- data/.rubocop.yml +16 -12
- data/.rubocop_todo.yml +724 -0
- data/CONTRIBUTING.md +5 -1
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/Rakefile +2 -14
- data/SECURITY.md +6 -0
- data/changelog.md +241 -141
- data/fog-core.gemspec +13 -9
- data/lib/fog/account.rb +0 -16
- data/lib/fog/billing.rb +0 -11
- data/lib/fog/compute/models/server.rb +7 -3
- data/lib/fog/compute.rb +3 -25
- data/lib/fog/core/association.rb +1 -0
- data/lib/fog/core/attributes/default.rb +7 -0
- data/lib/fog/core/attributes.rb +42 -5
- data/lib/fog/core/cache.rb +58 -55
- data/lib/fog/core/collection.rb +9 -3
- data/lib/fog/core/connection.rb +4 -6
- data/lib/fog/core/current_machine.rb +1 -1
- data/lib/fog/core/errors.rb +1 -1
- data/lib/fog/core/logger.rb +5 -2
- data/lib/fog/core/mock.rb +7 -2
- data/lib/fog/core/model.rb +34 -5
- data/lib/fog/core/provider.rb +37 -4
- data/lib/fog/core/scp.rb +16 -11
- data/lib/fog/core/service.rb +5 -5
- data/lib/fog/core/services_mixin.rb +62 -10
- data/lib/fog/core/ssh.rb +49 -25
- data/lib/fog/core/stringify_keys.rb +0 -2
- data/lib/fog/core/time.rb +2 -2
- data/lib/fog/core/uuid.rb +2 -8
- data/lib/fog/core/version.rb +3 -1
- data/lib/fog/core/wait_for.rb +2 -1
- data/lib/fog/core/wait_for_defaults.rb +2 -0
- data/lib/fog/core.rb +57 -59
- data/lib/fog/dns.rb +0 -11
- data/lib/fog/formatador.rb +9 -8
- data/lib/fog/monitoring.rb +0 -11
- data/lib/fog/network.rb +0 -12
- data/lib/fog/schema/data_validator.rb +1 -0
- data/lib/fog/storage.rb +15 -30
- data/lib/fog/support.rb +0 -12
- data/lib/fog/test_helpers/collection_helper.rb +2 -0
- data/lib/fog/test_helpers/formats_helper.rb +2 -2
- data/lib/fog/test_helpers/helper.rb +3 -3
- data/lib/fog/test_helpers/minitest/assertions.rb +1 -1
- data/lib/fog/test_helpers/minitest/expectations.rb +1 -1
- data/lib/fog/test_helpers/mock_helper.rb +84 -84
- data/lib/fog/test_helpers/succeeds_helper.rb +2 -2
- data/lib/fog/test_helpers/types_helper.rb +1 -0
- data/lib/fog/vpn.rb +0 -12
- data/lib/tasks/test_task.rb +4 -5
- metadata +58 -85
- data/.travis.yml +0 -39
- data/spec/compute/models/server_spec.rb +0 -229
- data/spec/compute_spec.rb +0 -95
- data/spec/connection_spec.rb +0 -105
- data/spec/core/cache_spec.rb +0 -191
- data/spec/core/model_spec.rb +0 -36
- data/spec/core/stringify_keys_spec.rb +0 -38
- data/spec/core/whitelist_keys_spec.rb +0 -36
- data/spec/credentials_spec.rb +0 -88
- data/spec/current_machine_spec.rb +0 -36
- data/spec/fake_app/fake_service.rb +0 -18
- data/spec/fake_app/models/collection.rb +0 -5
- data/spec/fake_app/models/model.rb +0 -2
- data/spec/fake_app/requests/request.rb +0 -11
- data/spec/fog_attribute_spec.rb +0 -549
- data/spec/formatador_spec.rb +0 -154
- data/spec/identity_spec.rb +0 -95
- data/spec/mocking_spec.rb +0 -84
- data/spec/service_spec.rb +0 -201
- data/spec/spec_helper.rb +0 -19
- data/spec/storage_spec.rb +0 -114
- data/spec/test_helpers/formats_helper_spec.rb +0 -121
- data/spec/test_helpers/schema_validator_spec.rb +0 -101
- data/spec/timeout_spec.rb +0 -20
- data/spec/utils_spec.rb +0 -29
- data/spec/uuid_spec.rb +0 -11
- data/spec/wait_for_spec.rb +0 -30
data/lib/fog/core/provider.rb
CHANGED
@@ -8,9 +8,22 @@ module Fog
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module Provider
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
class << self
|
12
|
+
def extended(base)
|
13
|
+
provider = base.to_s.split("::").last
|
14
|
+
Fog.providers[provider.downcase.to_sym] = provider
|
15
|
+
Fog.providers[underscore_name(provider).to_sym] = provider
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def underscore_name(string)
|
21
|
+
string.gsub("::", "/")
|
22
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
23
|
+
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
|
24
|
+
.tr("-", "_")
|
25
|
+
.downcase
|
26
|
+
end
|
14
27
|
end
|
15
28
|
|
16
29
|
def [](service_key)
|
@@ -21,11 +34,31 @@ module Fog
|
|
21
34
|
Fog.services[new_service] ||= []
|
22
35
|
Fog.services[new_service] |= [to_s.split("::").last.downcase.to_sym]
|
23
36
|
@services_registry ||= {}
|
24
|
-
@services_registry[new_service] =
|
37
|
+
@services_registry[new_service] = service_klass(constant_string)
|
25
38
|
end
|
26
39
|
|
27
40
|
def services
|
28
41
|
@services_registry.keys
|
29
42
|
end
|
43
|
+
|
44
|
+
# Returns service constant path, with provider, as string. If
|
45
|
+
# "provider::service" is defined (the preferred format) then it returns that
|
46
|
+
# string, otherwise it returns the deprecated string "service::provider".
|
47
|
+
def service_klass(constant_string)
|
48
|
+
if const_defined?([to_s, constant_string].join("::"))
|
49
|
+
[to_s, constant_string].join("::")
|
50
|
+
else
|
51
|
+
provider = to_s.split("::").last
|
52
|
+
Fog::Logger.deprecation("Unable to load #{[to_s, constant_string].join('::')}")
|
53
|
+
Fog::Logger.deprecation(
|
54
|
+
format(
|
55
|
+
Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,
|
56
|
+
service: constant_string,
|
57
|
+
provider: provider
|
58
|
+
)
|
59
|
+
)
|
60
|
+
["Fog", constant_string, provider].join("::")
|
61
|
+
end
|
62
|
+
end
|
30
63
|
end
|
31
64
|
end
|
data/lib/fog/core/scp.rb
CHANGED
@@ -22,19 +22,23 @@ module Fog
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def upload(local_path, remote_path, upload_options = {})
|
25
|
-
self.class.data[@address] << {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
self.class.data[@address] << {
|
26
|
+
username: @username,
|
27
|
+
options: @options,
|
28
|
+
local_path: local_path,
|
29
|
+
remote_path: remote_path,
|
30
|
+
upload_options: upload_options
|
31
|
+
}
|
30
32
|
end
|
31
33
|
|
32
34
|
def download(remote_path, local_path, download_options = {})
|
33
|
-
self.class.data[@address] << {
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
self.class.data[@address] << {
|
36
|
+
username: @username,
|
37
|
+
options: @options,
|
38
|
+
remote_path: remote_path,
|
39
|
+
local_path: local_path,
|
40
|
+
download_options: download_options
|
41
|
+
}
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
@@ -64,8 +68,9 @@ module Fog
|
|
64
68
|
|
65
69
|
@address = address
|
66
70
|
@username = username
|
67
|
-
@options = { :
|
71
|
+
@options = { paranoid: false, verify_host_key: :never }.merge(options)
|
68
72
|
@options.delete(:paranoid) if Net::SSH::VALID_OPTIONS.include? :verify_host_key
|
73
|
+
@options[:verify_host_key] = false unless Net::SSH::Verifiers.const_defined?(:Never)
|
69
74
|
end
|
70
75
|
|
71
76
|
def upload(local_path, remote_path, upload_options = {}, &block)
|
data/lib/fog/core/service.rb
CHANGED
@@ -11,7 +11,7 @@ module Fog
|
|
11
11
|
|
12
12
|
module NoLeakInspector
|
13
13
|
def inspect
|
14
|
-
"#<#{self.class}:#{object_id} #{(instance_variables - service.secrets).map { |iv| [iv, instance_variable_get(iv).inspect].join(
|
14
|
+
"#<#{self.class}:#{object_id} #{(instance_variables - service.secrets).map { |iv| [iv, instance_variable_get(iv).inspect].join('=') }.join(' ')}>"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -119,7 +119,7 @@ module Fog
|
|
119
119
|
# @deprecated
|
120
120
|
def fetch_credentials(_options)
|
121
121
|
# attempt to load credentials from config file
|
122
|
-
Fog.credentials.
|
122
|
+
Fog.credentials.select { |key, _value| (recognized | requirements).include?(key) }
|
123
123
|
rescue ::Fog::Errors::LoadError
|
124
124
|
# if there are no configured credentials, do nothing
|
125
125
|
{}
|
@@ -212,7 +212,7 @@ module Fog
|
|
212
212
|
@secrets ||= []
|
213
213
|
else
|
214
214
|
args.reduce(secrets) do |secrets, secret|
|
215
|
-
secrets << "@#{secret}"
|
215
|
+
secrets << :"@#{secret}"
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
@@ -241,13 +241,13 @@ module Fog
|
|
241
241
|
missing = requirements - keys
|
242
242
|
|
243
243
|
unless missing.empty?
|
244
|
-
raise ArgumentError, "Missing required arguments: #{missing.join(
|
244
|
+
raise ArgumentError, "Missing required arguments: #{missing.join(', ')}"
|
245
245
|
end
|
246
246
|
|
247
247
|
unless recognizes.empty?
|
248
248
|
unrecognized = options.keys - requirements - recognized
|
249
249
|
unless unrecognized.empty?
|
250
|
-
Fog::Logger.warning("Unrecognized arguments: #{unrecognized.join(
|
250
|
+
Fog::Logger.warning("Unrecognized arguments: #{unrecognized.join(', ')}")
|
251
251
|
end
|
252
252
|
end
|
253
253
|
end
|
@@ -1,21 +1,37 @@
|
|
1
1
|
module Fog
|
2
2
|
module ServicesMixin
|
3
|
+
E_SERVICE_PROVIDER_CONSTANT = <<-EOS.gsub(/\s+/, " ").strip.freeze
|
4
|
+
Falling back to deprecated constant Fog::%<service>s::%<provider>s. The
|
5
|
+
preferred format of service provider constants has changed from
|
6
|
+
service::provider to provider::service. Please update this service
|
7
|
+
provider to use the preferred format.
|
8
|
+
EOS
|
9
|
+
E_SERVICE_PROVIDER_PATH = <<-EOS.gsub(/\s+/, " ").strip.freeze
|
10
|
+
Falling back to deprecated path fog/%<service>s/%<provider>s. The
|
11
|
+
preferred file path format has changed from service/provider to
|
12
|
+
provider/service. Please update this service provider to use the preferred
|
13
|
+
format.
|
14
|
+
EOS
|
15
|
+
|
3
16
|
def [](provider)
|
4
|
-
new(:
|
17
|
+
new(provider: provider)
|
5
18
|
end
|
6
19
|
|
7
20
|
def new(attributes)
|
8
|
-
attributes
|
9
|
-
provider
|
10
|
-
|
21
|
+
attributes = attributes.dup # Prevent delete from having side effects
|
22
|
+
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
23
|
+
provider_alias = check_provider_alias(provider)
|
24
|
+
provider_name = Fog.providers[provider_alias]
|
11
25
|
|
12
|
-
raise ArgumentError, "#{
|
26
|
+
raise ArgumentError, "#{provider_alias} is not a recognized provider" unless providers.include?(provider) || providers.include?(provider_alias)
|
13
27
|
|
14
|
-
require_service_provider_library(service_name.downcase,
|
28
|
+
require_service_provider_library(service_name.downcase, provider_alias)
|
15
29
|
spc = service_provider_constant(service_name, provider_name)
|
16
30
|
spc.new(attributes)
|
17
|
-
rescue LoadError, NameError # Only rescue errors in finding the libraries, allow connection errors through to the caller
|
18
|
-
|
31
|
+
rescue LoadError, NameError => e # Only rescue errors in finding the libraries, allow connection errors through to the caller
|
32
|
+
Fog::Logger.warning("Error while loading provider #{provider_alias}: #{e.message}")
|
33
|
+
Fog::Logger.debug("backtrace: #{e.backtrace.join("\n")}")
|
34
|
+
raise Fog::Service::NotFound, "#{provider_alias} has no #{service_name.downcase} service"
|
19
35
|
end
|
20
36
|
|
21
37
|
def providers
|
@@ -24,16 +40,28 @@ module Fog
|
|
24
40
|
|
25
41
|
private
|
26
42
|
|
43
|
+
# This method should be removed once all providers are extracted.
|
44
|
+
# Bundler will correctly require all dependencies automatically and thus
|
45
|
+
# fog-core wont need to know any specifics providers. Each provider will
|
46
|
+
# have to load its dependencies.
|
27
47
|
def require_service_provider_library(service, provider)
|
28
48
|
require "fog/#{provider}/#{service}"
|
29
49
|
rescue LoadError # Try to require the service provider in an alternate location
|
50
|
+
Fog::Logger.deprecation("Unable to require fog/#{provider}/#{service}")
|
51
|
+
Fog::Logger.deprecation(
|
52
|
+
format(E_SERVICE_PROVIDER_PATH, service: service, provider: provider)
|
53
|
+
)
|
30
54
|
require "fog/#{service}/#{provider}"
|
31
55
|
end
|
32
56
|
|
33
57
|
def service_provider_constant(service_name, provider_name)
|
34
|
-
Fog.const_get(service_name).const_get(*const_get_args(provider_name))
|
35
|
-
rescue NameError # Try to find the constant from in an alternate location
|
36
58
|
Fog.const_get(provider_name).const_get(*const_get_args(service_name))
|
59
|
+
rescue NameError # Try to find the constant from in an alternate location
|
60
|
+
Fog::Logger.deprecation("Unable to load Fog::#{provider_name}::#{service_name}")
|
61
|
+
Fog::Logger.deprecation(
|
62
|
+
format(E_SERVICE_PROVIDER_CONSTANT, service: service_name, provider: provider_name)
|
63
|
+
)
|
64
|
+
Fog.const_get(service_name).const_get(*const_get_args(provider_name))
|
37
65
|
end
|
38
66
|
|
39
67
|
def const_get_args(*args)
|
@@ -43,5 +71,29 @@ module Fog
|
|
43
71
|
def service_name
|
44
72
|
name.split("Fog::").last
|
45
73
|
end
|
74
|
+
|
75
|
+
def check_provider_alias(provider)
|
76
|
+
case provider
|
77
|
+
when :baremetalcloud
|
78
|
+
Fog::Logger.deprecation(":baremetalcloud is deprecated. Use :bare_metal_cloud instead!")
|
79
|
+
:bare_metal_cloud
|
80
|
+
when :gogrid
|
81
|
+
Fog::Logger.deprecation(":gogrid is deprecated. Use :go_grid instead!")
|
82
|
+
:go_grid
|
83
|
+
when :internetarchive
|
84
|
+
Fog::Logger.deprecation(":internetarchive is deprecated. Use :internet_archive instead!")
|
85
|
+
:internet_archive
|
86
|
+
when :new_servers
|
87
|
+
Fog::Logger.deprecation(":new_servers is deprecated. Use :bare_metal_cloud instead!")
|
88
|
+
:bare_metal_cloud
|
89
|
+
when :stormondemand
|
90
|
+
Fog::Logger.deprecation(":stormondemand is deprecated. Use :storm_on_demand instead!")
|
91
|
+
:storm_on_demand
|
92
|
+
when :vclouddirector
|
93
|
+
Fog::Logger.deprecation(":vclouddirector is deprecated. Use :vcloud_director instead!")
|
94
|
+
:vcloud_director
|
95
|
+
else provider
|
96
|
+
end
|
97
|
+
end
|
46
98
|
end
|
47
99
|
end
|
data/lib/fog/core/ssh.rb
CHANGED
@@ -28,38 +28,16 @@ module Fog
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def run(commands, &_blk)
|
31
|
-
self.class.data[@address] << { :
|
31
|
+
self.class.data[@address] << { commands: commands, username: @username, options: @options }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
class Real
|
36
36
|
def initialize(address, username, options)
|
37
|
-
|
38
|
-
require "net/ssh"
|
39
|
-
rescue LoadError
|
40
|
-
Fog::Logger.warning("'net/ssh' missing, please install and try again.")
|
41
|
-
exit(1)
|
42
|
-
end
|
43
|
-
|
44
|
-
key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)
|
45
|
-
|
46
|
-
unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent
|
47
|
-
raise ArgumentError, ":key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH"
|
48
|
-
end
|
49
|
-
|
50
|
-
options[:timeout] ||= 30
|
51
|
-
if options[:key_data] || options[:keys]
|
52
|
-
options[:keys_only] = true
|
53
|
-
# Explicitly set these so net-ssh doesn"t add the default keys
|
54
|
-
# as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146
|
55
|
-
options[:keys] = [] unless options[:keys]
|
56
|
-
options[:key_data] = [] unless options[:key_data]
|
57
|
-
end
|
58
|
-
|
37
|
+
assert_net_ssh_loaded
|
59
38
|
@address = address
|
60
39
|
@username = username
|
61
|
-
@options
|
62
|
-
@options.delete(:paranoid) if Net::SSH::VALID_OPTIONS.include? :verify_host_key
|
40
|
+
@options = build_options(options)
|
63
41
|
end
|
64
42
|
|
65
43
|
def run(commands, &blk)
|
@@ -83,6 +61,7 @@ module Fog
|
|
83
61
|
|
84
62
|
channel.on_extended_data do |_ch, type, data|
|
85
63
|
next unless type == 1
|
64
|
+
|
86
65
|
result.stderr << data
|
87
66
|
yield ["", data] if blk
|
88
67
|
end
|
@@ -107,6 +86,51 @@ module Fog
|
|
107
86
|
end
|
108
87
|
results
|
109
88
|
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def assert_net_ssh_loaded
|
93
|
+
begin
|
94
|
+
require "net/ssh"
|
95
|
+
rescue LoadError
|
96
|
+
Fog::Logger.warning("'net/ssh' missing, please install and try again.")
|
97
|
+
exit(1)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Modifies the given `options` hash AND returns a new hash.
|
102
|
+
# TODO: Probably shouldn't modify the given hash.
|
103
|
+
def build_options(options)
|
104
|
+
validate_options(options)
|
105
|
+
merge_default_options_into(options)
|
106
|
+
end
|
107
|
+
|
108
|
+
def merge_default_options_into(options)
|
109
|
+
options[:timeout] ||= 30
|
110
|
+
if options[:key_data] || options[:keys]
|
111
|
+
options[:keys_only] = true
|
112
|
+
# Explicitly set these so net-ssh doesn"t add the default keys
|
113
|
+
# as seen at https://github.com/net-ssh/net-ssh/blob/master/lib/net/ssh/authentication/session.rb#L131-146
|
114
|
+
options[:keys] = [] unless options[:keys]
|
115
|
+
options[:key_data] = [] unless options[:key_data]
|
116
|
+
end
|
117
|
+
|
118
|
+
# net-ssh has deprecated :paranoid in favor of :verify_host_key
|
119
|
+
# https://github.com/net-ssh/net-ssh/pull/524
|
120
|
+
opts = { paranoid: false, verify_host_key: :never }.merge(options)
|
121
|
+
if Net::SSH::VALID_OPTIONS.include? :verify_host_key
|
122
|
+
opts.delete(:paranoid)
|
123
|
+
end
|
124
|
+
opts[:verify_host_key] = false unless Net::SSH::Verifiers.const_defined?(:Never)
|
125
|
+
opts
|
126
|
+
end
|
127
|
+
|
128
|
+
def validate_options(options)
|
129
|
+
key_manager = Net::SSH::Authentication::KeyManager.new(nil, options)
|
130
|
+
unless options[:key_data] || options[:keys] || options[:password] || key_manager.agent
|
131
|
+
raise ArgumentError, ":key_data, :keys, :password or a loaded ssh-agent is required to initialize SSH"
|
132
|
+
end
|
133
|
+
end
|
110
134
|
end
|
111
135
|
|
112
136
|
class Result
|
data/lib/fog/core/time.rb
CHANGED
@@ -2,8 +2,8 @@ require "time"
|
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
class Time < ::Time
|
5
|
-
DAYS = %w(Sun Mon Tue Wed Thu Fri Sat)
|
6
|
-
MONTHS = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
|
5
|
+
DAYS = %w(Sun Mon Tue Wed Thu Fri Sat).freeze
|
6
|
+
MONTHS = %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec).freeze
|
7
7
|
|
8
8
|
def self.now
|
9
9
|
at(::Time.now - offset)
|
data/lib/fog/core/uuid.rb
CHANGED
@@ -4,16 +4,10 @@ module Fog
|
|
4
4
|
class UUID
|
5
5
|
class << self
|
6
6
|
def uuid
|
7
|
-
|
8
|
-
SecureRandom.uuid
|
9
|
-
else
|
10
|
-
ary = SecureRandom.random_bytes(16).unpack("NnnnnN")
|
11
|
-
ary[2] = (ary[2] & 0x0fff) | 0x4000
|
12
|
-
ary[3] = (ary[3] & 0x3fff) | 0x8000
|
13
|
-
"%08x-%04x-%04x-%04x-%04x%08x" % ary
|
14
|
-
end
|
7
|
+
SecureRandom.uuid
|
15
8
|
end
|
16
9
|
|
10
|
+
# :nodoc: This method is used by other plugins, so preserve it for the compatibility
|
17
11
|
def supported?
|
18
12
|
SecureRandom.respond_to?(:uuid)
|
19
13
|
end
|
data/lib/fog/core/version.rb
CHANGED
data/lib/fog/core/wait_for.rb
CHANGED
@@ -8,9 +8,10 @@ module Fog
|
|
8
8
|
if duration > timeout
|
9
9
|
raise Errors::TimeoutError, "The specified wait_for timeout (#{timeout} seconds) was exceeded"
|
10
10
|
end
|
11
|
+
|
11
12
|
sleep(interval.respond_to?(:call) ? interval.call(retries += 1).to_f : interval.to_f)
|
12
13
|
duration = Time.now - start
|
13
14
|
end
|
14
|
-
{ :
|
15
|
+
{ duration: duration }
|
15
16
|
end
|
16
17
|
end
|
@@ -22,6 +22,7 @@ module Fog
|
|
22
22
|
|
23
23
|
def self.timeout=(timeout)
|
24
24
|
raise ArgumentError, "timeout must be non-negative" unless timeout >= 0
|
25
|
+
|
25
26
|
@timeout = timeout
|
26
27
|
end
|
27
28
|
|
@@ -33,6 +34,7 @@ module Fog
|
|
33
34
|
|
34
35
|
def self.max_interval=(interval)
|
35
36
|
raise ArgumentError, "interval must be non-negative" unless interval >= 0
|
37
|
+
|
36
38
|
@max_interval = interval
|
37
39
|
end
|
38
40
|
end
|
data/lib/fog/core.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# external core dependencies
|
2
|
-
require "base64"
|
3
2
|
require "cgi"
|
4
3
|
require "uri"
|
5
4
|
require "excon"
|
@@ -11,67 +10,66 @@ require "timeout"
|
|
11
10
|
require "ipaddr"
|
12
11
|
|
13
12
|
# internal core dependencies
|
14
|
-
require File.expand_path(
|
13
|
+
require File.expand_path("core/version", __dir__)
|
15
14
|
|
16
15
|
# Mixins
|
17
|
-
require File.expand_path(
|
16
|
+
require File.expand_path("core/services_mixin", __dir__)
|
18
17
|
|
19
|
-
require File.expand_path(
|
20
|
-
require File.expand_path(
|
21
|
-
require File.expand_path(
|
22
|
-
require File.expand_path(
|
23
|
-
require File.expand_path(
|
24
|
-
require File.expand_path(
|
25
|
-
require File.expand_path(
|
26
|
-
require File.expand_path(
|
27
|
-
require File.expand_path(
|
28
|
-
require File.expand_path(
|
29
|
-
require File.expand_path(
|
30
|
-
require File.expand_path(
|
31
|
-
require File.expand_path(
|
32
|
-
require File.expand_path(
|
33
|
-
require File.expand_path(
|
34
|
-
require File.expand_path(
|
35
|
-
require File.expand_path(
|
36
|
-
require File.expand_path(
|
37
|
-
require File.expand_path(
|
38
|
-
require File.expand_path(
|
39
|
-
require File.expand_path(
|
40
|
-
require File.expand_path(
|
41
|
-
require File.expand_path(
|
42
|
-
require File.expand_path(
|
43
|
-
require File.expand_path(
|
44
|
-
require File.expand_path(
|
45
|
-
require File.expand_path(
|
46
|
-
require File.expand_path(
|
47
|
-
require File.expand_path(
|
48
|
-
require File.expand_path(
|
49
|
-
require File.expand_path(
|
50
|
-
require File.expand_path(
|
51
|
-
require File.expand_path(
|
52
|
-
require File.expand_path(
|
53
|
-
require File.expand_path(
|
54
|
-
require File.expand_path(
|
55
|
-
|
56
|
-
require File.expand_path('../account', __FILE__)
|
57
|
-
require File.expand_path('../baremetal', __FILE__)
|
58
|
-
require File.expand_path('../billing', __FILE__)
|
59
|
-
require File.expand_path('../cdn', __FILE__)
|
60
|
-
require File.expand_path('../compute', __FILE__)
|
61
|
-
require File.expand_path('../dns', __FILE__)
|
62
|
-
require File.expand_path('../identity', __FILE__)
|
63
|
-
require File.expand_path('../image', __FILE__)
|
64
|
-
require File.expand_path('../introspection', __FILE__)
|
65
|
-
require File.expand_path('../metering', __FILE__)
|
66
|
-
require File.expand_path('../monitoring', __FILE__)
|
67
|
-
require File.expand_path('../nfv', __FILE__)
|
68
|
-
require File.expand_path('../network', __FILE__)
|
69
|
-
require File.expand_path('../orchestration', __FILE__)
|
70
|
-
require File.expand_path('../storage', __FILE__)
|
71
|
-
require File.expand_path('../support', __FILE__)
|
72
|
-
require File.expand_path('../volume', __FILE__)
|
73
|
-
require File.expand_path('../vpn', __FILE__)
|
18
|
+
require File.expand_path("core/attributes", __dir__)
|
19
|
+
require File.expand_path("core/attributes/default", __dir__)
|
20
|
+
require File.expand_path("core/attributes/array", __dir__)
|
21
|
+
require File.expand_path("core/attributes/boolean", __dir__)
|
22
|
+
require File.expand_path("core/attributes/float", __dir__)
|
23
|
+
require File.expand_path("core/attributes/integer", __dir__)
|
24
|
+
require File.expand_path("core/attributes/string", __dir__)
|
25
|
+
require File.expand_path("core/attributes/time", __dir__)
|
26
|
+
require File.expand_path("core/attributes/timestamp", __dir__)
|
27
|
+
require File.expand_path("core/associations/default", __dir__)
|
28
|
+
require File.expand_path("core/associations/many_identities", __dir__)
|
29
|
+
require File.expand_path("core/associations/many_models", __dir__)
|
30
|
+
require File.expand_path("core/associations/one_model", __dir__)
|
31
|
+
require File.expand_path("core/associations/one_identity", __dir__)
|
32
|
+
require File.expand_path("core/collection", __dir__)
|
33
|
+
require File.expand_path("core/association", __dir__)
|
34
|
+
require File.expand_path("core/connection", __dir__)
|
35
|
+
require File.expand_path("core/credentials", __dir__)
|
36
|
+
require File.expand_path("core/current_machine", __dir__)
|
37
|
+
require File.expand_path("core/deprecation", __dir__)
|
38
|
+
require File.expand_path("core/errors", __dir__)
|
39
|
+
require File.expand_path("core/hmac", __dir__)
|
40
|
+
require File.expand_path("core/logger", __dir__)
|
41
|
+
require File.expand_path("core/model", __dir__)
|
42
|
+
require File.expand_path("core/mock", __dir__)
|
43
|
+
require File.expand_path("core/provider", __dir__)
|
44
|
+
require File.expand_path("core/service", __dir__)
|
45
|
+
require File.expand_path("core/ssh", __dir__)
|
46
|
+
require File.expand_path("core/scp", __dir__)
|
47
|
+
require File.expand_path("core/time", __dir__)
|
48
|
+
require File.expand_path("core/utils", __dir__)
|
49
|
+
require File.expand_path("core/wait_for", __dir__)
|
50
|
+
require File.expand_path("core/wait_for_defaults", __dir__)
|
51
|
+
require File.expand_path("core/uuid", __dir__)
|
52
|
+
require File.expand_path("core/stringify_keys", __dir__)
|
53
|
+
require File.expand_path("core/whitelist_keys", __dir__)
|
74
54
|
|
55
|
+
require File.expand_path("account", __dir__)
|
56
|
+
require File.expand_path("baremetal", __dir__)
|
57
|
+
require File.expand_path("billing", __dir__)
|
58
|
+
require File.expand_path("cdn", __dir__)
|
59
|
+
require File.expand_path("compute", __dir__)
|
60
|
+
require File.expand_path("dns", __dir__)
|
61
|
+
require File.expand_path("identity", __dir__)
|
62
|
+
require File.expand_path("image", __dir__)
|
63
|
+
require File.expand_path("introspection", __dir__)
|
64
|
+
require File.expand_path("metering", __dir__)
|
65
|
+
require File.expand_path("monitoring", __dir__)
|
66
|
+
require File.expand_path("nfv", __dir__)
|
67
|
+
require File.expand_path("network", __dir__)
|
68
|
+
require File.expand_path("orchestration", __dir__)
|
69
|
+
require File.expand_path("storage", __dir__)
|
70
|
+
require File.expand_path("support", __dir__)
|
71
|
+
require File.expand_path("volume", __dir__)
|
72
|
+
require File.expand_path("vpn", __dir__)
|
75
73
|
|
76
74
|
# Utility
|
77
|
-
require File.expand_path(
|
75
|
+
require File.expand_path("formatador", __dir__)
|
data/lib/fog/dns.rb
CHANGED
@@ -2,17 +2,6 @@ module Fog
|
|
2
2
|
module DNS
|
3
3
|
extend Fog::ServicesMixin
|
4
4
|
|
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
|
-
|
16
5
|
def self.zones
|
17
6
|
zones = []
|
18
7
|
providers.each do |provider|
|
data/lib/fog/formatador.rb
CHANGED
@@ -9,8 +9,8 @@ module Fog
|
|
9
9
|
Thread.current[:formatador] ||= ::Formatador.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def self.format(object, opts = { :
|
13
|
-
string = init_string(object)
|
12
|
+
def self.format(object, opts = { include_nested: true })
|
13
|
+
string = +init_string(object)
|
14
14
|
indent { string << object_string(object, opts) }
|
15
15
|
string << "#{indentation}>"
|
16
16
|
end
|
@@ -32,11 +32,9 @@ module Fog
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.redisplay_progressbar(current, total, options = {})
|
35
|
-
::Formatador.redisplay_progressbar(current, total, options
|
35
|
+
::Formatador.redisplay_progressbar(current, total, options)
|
36
36
|
end
|
37
37
|
|
38
|
-
private
|
39
|
-
|
40
38
|
def self.indent(&block)
|
41
39
|
formatador.indent(&block)
|
42
40
|
end
|
@@ -50,13 +48,14 @@ module Fog
|
|
50
48
|
end
|
51
49
|
|
52
50
|
def self.object_string(object, opts)
|
53
|
-
string =
|
54
|
-
string <<
|
51
|
+
string = +attribute_string(object).to_s
|
52
|
+
string << nested_objects_string(object).to_s if opts[:include_nested]
|
55
53
|
string
|
56
54
|
end
|
57
55
|
|
58
56
|
def self.attribute_string(object)
|
59
57
|
return "" unless object.class.respond_to?(:attributes)
|
58
|
+
|
60
59
|
if object.class.attributes.empty?
|
61
60
|
""
|
62
61
|
else
|
@@ -68,7 +67,8 @@ module Fog
|
|
68
67
|
nested = ""
|
69
68
|
return nested if object.respond_to?(:empty) and object.empty?
|
70
69
|
return nested unless object.is_a?(Enumerable)
|
71
|
-
|
70
|
+
|
71
|
+
nested = +"#{indentation}[\n"
|
72
72
|
indent { nested << indentation + inspect_object(object) }
|
73
73
|
nested << "#{indentation}\n#{indentation}]\n"
|
74
74
|
end
|
@@ -82,6 +82,7 @@ module Fog
|
|
82
82
|
|
83
83
|
def self.inspect_object(object)
|
84
84
|
return "" unless object.is_a?(Enumerable)
|
85
|
+
|
85
86
|
object.map { |o| indentation + o.inspect }.join(", \n#{indentation}")
|
86
87
|
end
|
87
88
|
end
|