fog-openstack 1.0.8 → 1.0.9

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
  SHA256:
3
- metadata.gz: 270074b35f68ff30e1fdf308aebfc3c65c7612a0b47ef4086bc8eba90e81caef
4
- data.tar.gz: cdcf2622d79d20d4d32712b57c61ae59f565fb200c9207de8e4055962cb0216b
3
+ metadata.gz: 530da777fdef44b8a3c8fa5a17af871552a076cffe5d02ceb62c7111398e9f96
4
+ data.tar.gz: 347b19093860b01a5a55bf449b132ace59f7587c273aa011a7a6b7f933c45d3f
5
5
  SHA512:
6
- metadata.gz: 8f99c8410def0a380c0ca60c17972e25f276242ec17868a37807ff771178c105b79c32e7404f1a300bff19886aba9b9b0c3766120a7ebb96fad30ce2843dcbf2
7
- data.tar.gz: abd0932213deea67ce5d1b7ef79f0dfd20895e9b8ee52f8931732ecd15d8ba1fe42a582829c9dc24f1b1f70e2d09cc69e443ef61c5894a7373eee3e379c218c5
6
+ metadata.gz: 20cf27a82b8c3cd6383a502b4ca14dbf69939a654ae70d43172203be191bb9b3d1d5f89a51bfb7a3d30055cd0cf87b1ecfd2084ed8808ce92446f76d1da722b7
7
+ data.tar.gz: 7206050c3ae79424adec760d7d796117784c24124d9049268b9d3ab9dd19a19529d6dc6f25f87b8d5513057086023861644c931e90bd1a5ef2ade4ef0a72ac0b
data/.rubocop.yml CHANGED
@@ -21,6 +21,8 @@ CollectionMethods:
21
21
  reduce: inject
22
22
  CyclomaticComplexity:
23
23
  Severity: refactor
24
+ Debugger:
25
+ Enabled: true
24
26
  FormatString:
25
27
  EnforcedStyle: percent
26
28
  HashSyntax:
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency 'fog-json', '>= 1.0'
26
26
  spec.add_dependency 'ipaddress', '>= 0.8'
27
27
 
28
- spec.add_development_dependency 'bundler', '~> 1'
28
+ spec.add_development_dependency 'bundler'
29
29
  spec.add_development_dependency 'coveralls'
30
30
  spec.add_development_dependency "mime-types"
31
31
  spec.add_development_dependency "mime-types-data"
@@ -50,17 +50,18 @@ module Fog
50
50
  def request(params, parse_json = true)
51
51
  retried = false
52
52
  begin
53
+ authenticate! if @expires && (@expires - Time.now.utc).to_i < 60
54
+
53
55
  response = @connection.request(
54
56
  params.merge(
55
57
  :headers => headers(params.delete(:headers)),
56
58
  :path => "#{@path}/#{params[:path]}"
57
59
  )
58
60
  )
59
- rescue Excon::Errors::Unauthorized => error
61
+ rescue Excon::Errors::Unauthorized, Excon::Error::Unauthorized => error
60
62
  # token expiration and token renewal possible
61
63
  if error.response.body != 'Bad username or password' && @openstack_can_reauthenticate && !retried
62
- @openstack_must_reauthenticate = true
63
- authenticate
64
+ authenticate!
64
65
  retried = true
65
66
  retry
66
67
  # bad credentials or token renewal not possible
@@ -171,6 +172,9 @@ module Fog
171
172
  instance_variable_set "@#{openstack_param}".to_sym, value
172
173
  end
173
174
 
175
+ # Ensure OpenStack User's Password is always a String
176
+ @openstack_api_key = @openstack_api_key.to_s if @openstack_api_key
177
+
174
178
  @auth_token ||= options[:openstack_auth_token]
175
179
  @openstack_must_reauthenticate = false
176
180
  @openstack_endpoint_type = options[:openstack_endpoint_type] || 'public'
@@ -197,7 +201,7 @@ module Fog
197
201
 
198
202
  @openstack_service_type = options[:openstack_service_type] || default_service_type
199
203
  @openstack_endpoint_type = options[:openstack_endpoint_type] || default_endpoint_type
200
- @openstack_endpoint_type.gsub!(/URL/, '')
204
+ @openstack_endpoint_type = @openstack_endpoint_type.gsub(/URL/, '')
201
205
  @connection_options = options[:connection_options] || {}
202
206
  @persistent = options[:persistent] || false
203
207
  end
@@ -221,7 +225,7 @@ module Fog
221
225
  @current_user = token.user['name']
222
226
  @current_user_id = token.user['id']
223
227
  @current_tenant = token.tenant
224
- @expires = token.expires
228
+ @expires = Time.parse(token.expires)
225
229
  @auth_token = token.token
226
230
  @unscoped_token = token.token
227
231
  @openstack_must_reauthenticate = false
@@ -237,6 +241,11 @@ module Fog
237
241
 
238
242
  true
239
243
  end
244
+
245
+ def authenticate!
246
+ @openstack_must_reauthenticate = true
247
+ authenticate
248
+ end
240
249
  end
241
250
  end
242
251
  end
@@ -27,6 +27,7 @@ module Fog
27
27
  # * 'scheme'<~String> - The scheme to use (http, https)
28
28
  # * 'host'<~String> - The host to use
29
29
  # * 'port'<~Integer> - The port to use
30
+ # * 'filename'<~String> - Filename returned Content-Disposition response header
30
31
  #
31
32
  # ==== Returns
32
33
  # * response<~Excon::Response>:
@@ -34,6 +35,7 @@ module Fog
34
35
  #
35
36
  # ==== See Also
36
37
  # http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
38
+ # https://developer.openstack.org/api-ref/object-store/?expanded=get-object-content-and-metadata-detail#get-object-content-and-metadata
37
39
  def create_temp_url(container, object, expires, method, options = {})
38
40
  raise ArgumentError, "Insufficient parameters specified." unless container && object && expires && method
39
41
  raise ArgumentError, "Storage must be instantiated with the :openstack_temp_url_key option" if @openstack_temp_url_key.nil?
@@ -54,14 +56,19 @@ module Fog
54
56
  string_to_sign = "#{method}\n#{expires}\n#{object_path_unescaped}"
55
57
 
56
58
  hmac = Fog::HMAC.new('sha1', @openstack_temp_url_key.to_s)
57
- sig = sig_to_hex(hmac.sign(string_to_sign))
59
+
60
+ query = {
61
+ temp_url_sig: sig_to_hex(hmac.sign(string_to_sign)),
62
+ temp_url_expires: expires
63
+ }
64
+ query[:filename] = options[:filename] if options[:filename]
58
65
 
59
66
  temp_url_options = {
60
67
  :scheme => scheme,
61
68
  :host => host,
62
69
  :port => port,
63
70
  :path => object_path_escaped,
64
- :query => "temp_url_sig=#{sig}&temp_url_expires=#{expires}"
71
+ :query => query.map { |k, v| "#{k}=#{v}" }.join('&')
65
72
  }
66
73
  URI::Generic.build(temp_url_options).to_s
67
74
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module OpenStack
3
- VERSION = '1.0.8'.freeze
3
+ VERSION = '1.0.9'.freeze
4
4
  end
5
5
  end
@@ -6,7 +6,8 @@ module Fog
6
6
 
7
7
  def _create_volume(data, options = {})
8
8
  vanilla_options = [:snapshot_id, :imageRef, :volume_type,
9
- :source_volid, :availability_zone, :metadata]
9
+ :source_volid, :availability_zone, :metadata,
10
+ :multiattach]
10
11
  vanilla_options.select { |o| options[o] }.each do |key|
11
12
  data['volume'][key] = options[key]
12
13
  end
@@ -84,82 +84,8 @@ module Fog
84
84
  request :set_tenant
85
85
  request :action
86
86
 
87
- class Mock
88
- def self.data
89
- @data ||= Hash.new do |hash, key|
90
- hash[key] = {
91
- :users => {},
92
- :tenants => {},
93
- :quota => {
94
- 'gigabytes' => 1000,
95
- 'volumes' => 10,
96
- 'snapshots' => 10
97
- }
98
- }
99
- end
100
- end
101
-
102
- def self.reset
103
- @data = nil
104
- end
105
-
106
- def initialize(options = {})
107
- @openstack_username = options[:openstack_username]
108
- @openstack_tenant = options[:openstack_tenant]
109
- @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
110
-
111
- @auth_token = Fog::Mock.random_base64(64)
112
- @auth_token_expiration = (Time.now.utc + 86400).iso8601
113
-
114
- management_url = URI.parse(options[:openstack_auth_url])
115
- management_url.port = 8776
116
- management_url.path = '/v1'
117
- @openstack_management_url = management_url.to_s
118
-
119
- @data ||= {:users => {}}
120
- unless @data[:users].find { |u| u['name'] == options[:openstack_username] }
121
- id = Fog::Mock.random_numbers(6).to_s
122
- @data[:users][id] = {
123
- 'id' => id,
124
- 'name' => options[:openstack_username],
125
- 'email' => "#{options[:openstack_username]}@mock.com",
126
- 'tenantId' => Fog::Mock.random_numbers(6).to_s,
127
- 'enabled' => true
128
- }
129
- end
130
- end
131
-
132
- def data
133
- self.class.data[@openstack_username]
134
- end
135
-
136
- def reset_data
137
- self.class.data.delete(@openstack_username)
138
- end
139
-
140
- def credentials
141
- {:provider => 'openstack',
142
- :openstack_auth_url => @openstack_auth_uri.to_s,
143
- :openstack_auth_token => @auth_token,
144
- :openstack_management_url => @openstack_management_url}
145
- end
146
- end
147
-
148
- class Real
149
- include Fog::OpenStack::Core
150
-
151
- def self.not_found_class
152
- Fog::OpenStack::Volume::NotFound
153
- end
154
-
155
- def default_endtpoint_type
156
- 'admin'
157
- end
158
-
159
- def default_service_type
160
- %w[volume]
161
- end
162
- end
87
+ autoload :Mock, 'fog/openstack/volume/v1/mock'
88
+ autoload :Real, 'fog/openstack/volume/v1/real'
163
89
  end
164
90
  end
165
91
  end
@@ -0,0 +1,68 @@
1
+ module Fog
2
+ module OpenStack
3
+ class Volume
4
+ class V1 < Fog::OpenStack::Volume
5
+ class Mock
6
+ def self.data
7
+ @data ||= Hash.new do |hash, key|
8
+ hash[key] = {
9
+ :users => {},
10
+ :tenants => {},
11
+ :quota => {
12
+ 'gigabytes' => 1000,
13
+ 'volumes' => 10,
14
+ 'snapshots' => 10
15
+ }
16
+ }
17
+ end
18
+ end
19
+
20
+ def self.reset
21
+ @data = nil
22
+ end
23
+
24
+ def initialize(options = {})
25
+ @openstack_username = options[:openstack_username]
26
+ @openstack_tenant = options[:openstack_tenant]
27
+ @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
28
+
29
+ @auth_token = Fog::Mock.random_base64(64)
30
+ @auth_token_expiration = (Time.now.utc + 86400).iso8601
31
+
32
+ management_url = URI.parse(options[:openstack_auth_url])
33
+ management_url.port = 8776
34
+ management_url.path = '/v1'
35
+ @openstack_management_url = management_url.to_s
36
+
37
+ @data ||= {:users => {}}
38
+ unless @data[:users].find { |u| u['name'] == options[:openstack_username] }
39
+ id = Fog::Mock.random_numbers(6).to_s
40
+ @data[:users][id] = {
41
+ 'id' => id,
42
+ 'name' => options[:openstack_username],
43
+ 'email' => "#{options[:openstack_username]}@mock.com",
44
+ 'tenantId' => Fog::Mock.random_numbers(6).to_s,
45
+ 'enabled' => true
46
+ }
47
+ end
48
+ end
49
+
50
+ def data
51
+ self.class.data[@openstack_username]
52
+ end
53
+
54
+ def reset_data
55
+ self.class.data.delete(@openstack_username)
56
+ end
57
+
58
+ def credentials
59
+ {:provider => 'openstack',
60
+ :openstack_auth_url => @openstack_auth_uri.to_s,
61
+ :openstack_auth_token => @auth_token,
62
+ :openstack_management_url => @openstack_management_url}
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module OpenStack
3
+ class Volume
4
+ class V1 < Fog::OpenStack::Volume
5
+ class Real
6
+ include Fog::OpenStack::Core
7
+
8
+ def self.not_found_class
9
+ Fog::OpenStack::Volume::NotFound
10
+ end
11
+
12
+ def default_endtpoint_type
13
+ 'admin'
14
+ end
15
+
16
+ def default_service_type
17
+ %w[volume]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -86,82 +86,8 @@ module Fog
86
86
  request :action
87
87
  request :snapshot_action
88
88
 
89
- class Mock
90
- def self.data
91
- @data ||= Hash.new do |hash, key|
92
- hash[key] = {
93
- :users => {},
94
- :tenants => {},
95
- :quota => {
96
- 'gigabytes' => 1000,
97
- 'volumes' => 10,
98
- 'snapshots' => 10
99
- }
100
- }
101
- end
102
- end
103
-
104
- def self.reset
105
- @data = nil
106
- end
107
-
108
- def initialize(options = {})
109
- @openstack_username = options[:openstack_username]
110
- @openstack_tenant = options[:openstack_tenant]
111
- @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
112
-
113
- @auth_token = Fog::Mock.random_base64(64)
114
- @auth_token_expiration = (Time.now.utc + 86400).iso8601
115
-
116
- management_url = URI.parse(options[:openstack_auth_url])
117
- management_url.port = 8776
118
- management_url.path = '/v1'
119
- @openstack_management_url = management_url.to_s
120
-
121
- @data ||= {:users => {}}
122
- unless @data[:users].find { |u| u['name'] == options[:openstack_username] }
123
- id = Fog::Mock.random_numbers(6).to_s
124
- @data[:users][id] = {
125
- 'id' => id,
126
- 'name' => options[:openstack_username],
127
- 'email' => "#{options[:openstack_username]}@mock.com",
128
- 'tenantId' => Fog::Mock.random_numbers(6).to_s,
129
- 'enabled' => true
130
- }
131
- end
132
- end
133
-
134
- def data
135
- self.class.data[@openstack_username]
136
- end
137
-
138
- def reset_data
139
- self.class.data.delete(@openstack_username)
140
- end
141
-
142
- def credentials
143
- {:provider => 'openstack',
144
- :openstack_auth_url => @openstack_auth_uri.to_s,
145
- :openstack_auth_token => @auth_token,
146
- :openstack_management_url => @openstack_management_url}
147
- end
148
- end
149
-
150
- class Real
151
- include Fog::OpenStack::Core
152
-
153
- def self.not_found_class
154
- Fog::OpenStack::Volume::NotFound
155
- end
156
-
157
- def default_endtpoint_type
158
- 'admin'
159
- end
160
-
161
- def default_service_type
162
- %w[volumev2]
163
- end
164
- end
89
+ autoload :Mock, 'fog/openstack/volume/v2/mock'
90
+ autoload :Real, 'fog/openstack/volume/v2/real'
165
91
  end
166
92
  end
167
93
  end
@@ -0,0 +1,68 @@
1
+ module Fog
2
+ module OpenStack
3
+ class Volume
4
+ class V2 < Fog::OpenStack::Volume
5
+ class Mock
6
+ def self.data
7
+ @data ||= Hash.new do |hash, key|
8
+ hash[key] = {
9
+ :users => {},
10
+ :tenants => {},
11
+ :quota => {
12
+ 'gigabytes' => 1000,
13
+ 'volumes' => 10,
14
+ 'snapshots' => 10
15
+ }
16
+ }
17
+ end
18
+ end
19
+
20
+ def self.reset
21
+ @data = nil
22
+ end
23
+
24
+ def initialize(options = {})
25
+ @openstack_username = options[:openstack_username]
26
+ @openstack_tenant = options[:openstack_tenant]
27
+ @openstack_auth_uri = URI.parse(options[:openstack_auth_url])
28
+
29
+ @auth_token = Fog::Mock.random_base64(64)
30
+ @auth_token_expiration = (Time.now.utc + 86400).iso8601
31
+
32
+ management_url = URI.parse(options[:openstack_auth_url])
33
+ management_url.port = 8776
34
+ management_url.path = '/v1'
35
+ @openstack_management_url = management_url.to_s
36
+
37
+ @data ||= {:users => {}}
38
+ unless @data[:users].find { |u| u['name'] == options[:openstack_username] }
39
+ id = Fog::Mock.random_numbers(6).to_s
40
+ @data[:users][id] = {
41
+ 'id' => id,
42
+ 'name' => options[:openstack_username],
43
+ 'email' => "#{options[:openstack_username]}@mock.com",
44
+ 'tenantId' => Fog::Mock.random_numbers(6).to_s,
45
+ 'enabled' => true
46
+ }
47
+ end
48
+ end
49
+
50
+ def data
51
+ self.class.data[@openstack_username]
52
+ end
53
+
54
+ def reset_data
55
+ self.class.data.delete(@openstack_username)
56
+ end
57
+
58
+ def credentials
59
+ {:provider => 'openstack',
60
+ :openstack_auth_url => @openstack_auth_uri.to_s,
61
+ :openstack_auth_token => @auth_token,
62
+ :openstack_management_url => @openstack_management_url}
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module OpenStack
3
+ class Volume
4
+ class V2 < Fog::OpenStack::Volume
5
+ class Real
6
+ include Fog::OpenStack::Core
7
+
8
+ def self.not_found_class
9
+ Fog::OpenStack::Volume::NotFound
10
+ end
11
+
12
+ def default_endtpoint_type
13
+ 'admin'
14
+ end
15
+
16
+ def default_service_type
17
+ %w[volumev2]
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Darby
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-22 00:00:00.000000000 Z
11
+ date: 2019-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '1'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '1'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: coveralls
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -1214,6 +1214,7 @@ files:
1214
1214
  - lib/fog/openstack/volume/requests/update_volume.rb
1215
1215
  - lib/fog/openstack/volume/requests/update_volume_type.rb
1216
1216
  - lib/fog/openstack/volume/v1.rb
1217
+ - lib/fog/openstack/volume/v1/mock.rb
1217
1218
  - lib/fog/openstack/volume/v1/models/availability_zone.rb
1218
1219
  - lib/fog/openstack/volume/v1/models/availability_zones.rb
1219
1220
  - lib/fog/openstack/volume/v1/models/backup.rb
@@ -1226,6 +1227,7 @@ files:
1226
1227
  - lib/fog/openstack/volume/v1/models/volume_type.rb
1227
1228
  - lib/fog/openstack/volume/v1/models/volume_types.rb
1228
1229
  - lib/fog/openstack/volume/v1/models/volumes.rb
1230
+ - lib/fog/openstack/volume/v1/real.rb
1229
1231
  - lib/fog/openstack/volume/v1/requests/accept_transfer.rb
1230
1232
  - lib/fog/openstack/volume/v1/requests/action.rb
1231
1233
  - lib/fog/openstack/volume/v1/requests/create_backup.rb
@@ -1270,6 +1272,7 @@ files:
1270
1272
  - lib/fog/openstack/volume/v1/requests/update_snapshot_metadata.rb
1271
1273
  - lib/fog/openstack/volume/v1/requests/update_volume.rb
1272
1274
  - lib/fog/openstack/volume/v2.rb
1275
+ - lib/fog/openstack/volume/v2/mock.rb
1273
1276
  - lib/fog/openstack/volume/v2/models/availability_zone.rb
1274
1277
  - lib/fog/openstack/volume/v2/models/availability_zones.rb
1275
1278
  - lib/fog/openstack/volume/v2/models/backup.rb
@@ -1282,6 +1285,7 @@ files:
1282
1285
  - lib/fog/openstack/volume/v2/models/volume_type.rb
1283
1286
  - lib/fog/openstack/volume/v2/models/volume_types.rb
1284
1287
  - lib/fog/openstack/volume/v2/models/volumes.rb
1288
+ - lib/fog/openstack/volume/v2/real.rb
1285
1289
  - lib/fog/openstack/volume/v2/requests/accept_transfer.rb
1286
1290
  - lib/fog/openstack/volume/v2/requests/action.rb
1287
1291
  - lib/fog/openstack/volume/v2/requests/create_backup.rb
@@ -1398,8 +1402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1398
1402
  - !ruby/object:Gem::Version
1399
1403
  version: '0'
1400
1404
  requirements: []
1401
- rubyforge_project:
1402
- rubygems_version: 2.7.6
1405
+ rubygems_version: 3.0.3
1403
1406
  signing_key:
1404
1407
  specification_version: 4
1405
1408
  summary: OpenStack fog provider gem