fog-core 2.1.2 → 2.5.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 +4 -4
- 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/Gemfile +1 -1
- data/README.md +2 -1
- data/Rakefile +2 -14
- data/SECURITY.md +6 -0
- data/changelog.md +80 -6
- data/fog-core.gemspec +12 -9
- data/lib/fog/compute/models/server.rb +7 -3
- data/lib/fog/compute.rb +3 -3
- data/lib/fog/core/association.rb +1 -0
- data/lib/fog/core/attributes/default.rb +7 -0
- data/lib/fog/core/attributes.rb +28 -3
- data/lib/fog/core/cache.rb +58 -55
- data/lib/fog/core/collection.rb +9 -3
- data/lib/fog/core/connection.rb +1 -1
- 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 +33 -10
- data/lib/fog/core/scp.rb +16 -11
- data/lib/fog/core/service.rb +5 -5
- data/lib/fog/core/services_mixin.rb +36 -16
- data/lib/fog/core/ssh.rb +4 -2
- 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 +1 -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/formatador.rb +9 -8
- data/lib/fog/schema/data_validator.rb +1 -0
- data/lib/fog/storage.rb +15 -16
- 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/tasks/test_task.rb +4 -5
- metadata +57 -86
- data/.github/stale.yml +0 -17
- 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 -112
- 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/mock.rb
CHANGED
@@ -25,6 +25,7 @@ module Fog
|
|
25
25
|
|
26
26
|
def self.delay=(new_delay)
|
27
27
|
raise ArgumentError, "delay must be non-negative" unless new_delay >= 0
|
28
|
+
|
28
29
|
@delay = new_delay
|
29
30
|
end
|
30
31
|
|
@@ -32,7 +33,7 @@ module Fog
|
|
32
33
|
raise Fog::Errors::MockNotImplemented, message
|
33
34
|
end
|
34
35
|
|
35
|
-
def self.random_ip(opts = { :
|
36
|
+
def self.random_ip(opts = { version: :v4 })
|
36
37
|
version = opts[:version]
|
37
38
|
if version == :v6
|
38
39
|
bit_length = 128
|
@@ -80,7 +81,7 @@ module Fog
|
|
80
81
|
end
|
81
82
|
|
82
83
|
def self.random_selection(characters, length)
|
83
|
-
selection = ""
|
84
|
+
selection = +""
|
84
85
|
length.times do
|
85
86
|
position = rand(characters.length)
|
86
87
|
selection << characters[position..position]
|
@@ -92,12 +93,15 @@ module Fog
|
|
92
93
|
mocked_services = []
|
93
94
|
Fog.constants.map do |x|
|
94
95
|
next if Fog.autoload?(x)
|
96
|
+
|
95
97
|
x_const = Fog.const_get(x)
|
96
98
|
x_const.respond_to?(:constants) && x_const.constants.map do |y|
|
97
99
|
next if x_const.autoload?(y)
|
100
|
+
|
98
101
|
y_const = x_const.const_get(y)
|
99
102
|
y_const.respond_to?(:constants) && y_const.constants.map do |z|
|
100
103
|
next if y_const.autoload?(z)
|
104
|
+
|
101
105
|
mocked_services << y_const.const_get(z) if z.to_sym == :Mock
|
102
106
|
end
|
103
107
|
end
|
@@ -105,6 +109,7 @@ module Fog
|
|
105
109
|
|
106
110
|
mocked_services.each do |mocked_service|
|
107
111
|
next unless mocked_service.respond_to?(:reset)
|
112
|
+
|
108
113
|
mocked_service.reset
|
109
114
|
end
|
110
115
|
end
|
data/lib/fog/core/model.rb
CHANGED
@@ -21,6 +21,33 @@ module Fog
|
|
21
21
|
merge_attributes(attribs)
|
22
22
|
end
|
23
23
|
|
24
|
+
# Creates new or updates existing model
|
25
|
+
# @return [self]
|
26
|
+
def save
|
27
|
+
persisted? ? update : create
|
28
|
+
end
|
29
|
+
|
30
|
+
# Creates new entity from model
|
31
|
+
# @raise [Fog::Errors::NotImplemented] you must implement #create method in child class and return self
|
32
|
+
# @return [self]
|
33
|
+
def create
|
34
|
+
raise Fog::Errors::NotImplemented, "Implement method #create for #{self.class}. Method must return self"
|
35
|
+
end
|
36
|
+
|
37
|
+
# Updates new entity with model
|
38
|
+
# @raise [Fog::Errors::NotImplemented] you must implement #update method in child class and return self
|
39
|
+
# @return [self]
|
40
|
+
def update
|
41
|
+
raise Fog::Errors::NotImplemented, "Implement method #update for #{self.class}. Method must return self"
|
42
|
+
end
|
43
|
+
|
44
|
+
# Destroys entity by model identity
|
45
|
+
# @raise [Fog::Errors::NotImplemented] you must implement #destroy method in child class and return self
|
46
|
+
# @return [self]
|
47
|
+
def destroy
|
48
|
+
raise Fog::Errors::NotImplemented, "Implement method #destroy for #{self.class}. Method must return self"
|
49
|
+
end
|
50
|
+
|
24
51
|
def cache
|
25
52
|
Fog::Cache.new(self)
|
26
53
|
end
|
@@ -41,6 +68,8 @@ module Fog
|
|
41
68
|
end
|
42
69
|
end
|
43
70
|
|
71
|
+
# @return [self] if model successfully reloaded
|
72
|
+
# @return [nil] if something went wrong or model was not found
|
44
73
|
def reload
|
45
74
|
requires :identity
|
46
75
|
|
@@ -61,6 +90,7 @@ module Fog
|
|
61
90
|
|
62
91
|
def symbolize_keys(hash)
|
63
92
|
return nil if hash.nil?
|
93
|
+
|
64
94
|
hash.reduce({}) do |options, (key, value)|
|
65
95
|
options[(key.to_sym rescue key) || key] = value
|
66
96
|
options
|
@@ -69,6 +99,7 @@ module Fog
|
|
69
99
|
|
70
100
|
def wait_for(timeout = Fog.timeout, interval = Fog.interval, &block)
|
71
101
|
reload_has_succeeded = false
|
102
|
+
|
72
103
|
duration = Fog.wait_for(timeout, interval) do # Note that duration = false if it times out
|
73
104
|
if reload
|
74
105
|
reload_has_succeeded = true
|
@@ -77,11 +108,9 @@ module Fog
|
|
77
108
|
false
|
78
109
|
end
|
79
110
|
end
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
raise Fog::Errors::Error, "Reload failed, #{self.class} #{identity} not present."
|
84
|
-
end
|
111
|
+
raise Fog::Errors::Error, "Reload failed, #{self.class} #{identity} not present." unless reload_has_succeeded
|
112
|
+
|
113
|
+
duration # false if timeout; otherwise {:duration => elapsed time }
|
85
114
|
end
|
86
115
|
end
|
87
116
|
end
|
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)
|
@@ -28,14 +41,24 @@ module Fog
|
|
28
41
|
@services_registry.keys
|
29
42
|
end
|
30
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".
|
31
47
|
def service_klass(constant_string)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
39
62
|
end
|
40
63
|
end
|
41
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
|
@@ -32,7 +48,9 @@ module Fog
|
|
32
48
|
require "fog/#{provider}/#{service}"
|
33
49
|
rescue LoadError # Try to require the service provider in an alternate location
|
34
50
|
Fog::Logger.deprecation("Unable to require fog/#{provider}/#{service}")
|
35
|
-
Fog::Logger.deprecation(
|
51
|
+
Fog::Logger.deprecation(
|
52
|
+
format(E_SERVICE_PROVIDER_PATH, service: service, provider: provider)
|
53
|
+
)
|
36
54
|
require "fog/#{service}/#{provider}"
|
37
55
|
end
|
38
56
|
|
@@ -40,7 +58,9 @@ module Fog
|
|
40
58
|
Fog.const_get(provider_name).const_get(*const_get_args(service_name))
|
41
59
|
rescue NameError # Try to find the constant from in an alternate location
|
42
60
|
Fog::Logger.deprecation("Unable to load Fog::#{provider_name}::#{service_name}")
|
43
|
-
Fog::Logger.deprecation(
|
61
|
+
Fog::Logger.deprecation(
|
62
|
+
format(E_SERVICE_PROVIDER_CONSTANT, service: service_name, provider: provider_name)
|
63
|
+
)
|
44
64
|
Fog.const_get(service_name).const_get(*const_get_args(provider_name))
|
45
65
|
end
|
46
66
|
|
@@ -55,22 +75,22 @@ module Fog
|
|
55
75
|
def check_provider_alias(provider)
|
56
76
|
case provider
|
57
77
|
when :baremetalcloud
|
58
|
-
Fog::Logger.deprecation(
|
78
|
+
Fog::Logger.deprecation(":baremetalcloud is deprecated. Use :bare_metal_cloud instead!")
|
59
79
|
:bare_metal_cloud
|
60
80
|
when :gogrid
|
61
|
-
Fog::Logger.deprecation(
|
81
|
+
Fog::Logger.deprecation(":gogrid is deprecated. Use :go_grid instead!")
|
62
82
|
:go_grid
|
63
83
|
when :internetarchive
|
64
|
-
Fog::Logger.deprecation(
|
84
|
+
Fog::Logger.deprecation(":internetarchive is deprecated. Use :internet_archive instead!")
|
65
85
|
:internet_archive
|
66
86
|
when :new_servers
|
67
|
-
Fog::Logger.deprecation(
|
87
|
+
Fog::Logger.deprecation(":new_servers is deprecated. Use :bare_metal_cloud instead!")
|
68
88
|
:bare_metal_cloud
|
69
89
|
when :stormondemand
|
70
|
-
Fog::Logger.deprecation(
|
90
|
+
Fog::Logger.deprecation(":stormondemand is deprecated. Use :storm_on_demand instead!")
|
71
91
|
:storm_on_demand
|
72
92
|
when :vclouddirector
|
73
|
-
Fog::Logger.deprecation(
|
93
|
+
Fog::Logger.deprecation(":vclouddirector is deprecated. Use :vcloud_director instead!")
|
74
94
|
:vcloud_director
|
75
95
|
else provider
|
76
96
|
end
|
data/lib/fog/core/ssh.rb
CHANGED
@@ -28,7 +28,7 @@ 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
|
|
@@ -61,6 +61,7 @@ module Fog
|
|
61
61
|
|
62
62
|
channel.on_extended_data do |_ch, type, data|
|
63
63
|
next unless type == 1
|
64
|
+
|
64
65
|
result.stderr << data
|
65
66
|
yield ["", data] if blk
|
66
67
|
end
|
@@ -116,10 +117,11 @@ module Fog
|
|
116
117
|
|
117
118
|
# net-ssh has deprecated :paranoid in favor of :verify_host_key
|
118
119
|
# https://github.com/net-ssh/net-ssh/pull/524
|
119
|
-
opts = { :
|
120
|
+
opts = { paranoid: false, verify_host_key: :never }.merge(options)
|
120
121
|
if Net::SSH::VALID_OPTIONS.include? :verify_host_key
|
121
122
|
opts.delete(:paranoid)
|
122
123
|
end
|
124
|
+
opts[:verify_host_key] = false unless Net::SSH::Verifiers.const_defined?(:Never)
|
123
125
|
opts
|
124
126
|
end
|
125
127
|
|
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__)
|