fog 1.33.0 → 1.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +47 -0
- data/Rakefile +3 -0
- data/fog.gemspec +4 -4
- data/lib/fog/openstack/baremetal.rb +20 -82
- data/lib/fog/openstack/compute.rb +11 -34
- data/lib/fog/openstack/core.rb +37 -10
- data/lib/fog/openstack/identity.rb +33 -44
- data/lib/fog/openstack/identity_v2.rb +14 -84
- data/lib/fog/openstack/identity_v3.rb +4 -51
- data/lib/fog/openstack/image.rb +22 -83
- data/lib/fog/openstack/metering.rb +15 -76
- data/lib/fog/openstack/models/compute/server.rb +1 -1
- data/lib/fog/openstack/models/orchestration/events.rb +1 -0
- data/lib/fog/openstack/models/orchestration/resources.rb +1 -0
- data/lib/fog/openstack/models/orchestration/stack.rb +1 -1
- data/lib/fog/openstack/models/orchestration/stacks.rb +1 -0
- data/lib/fog/openstack/models/orchestration/templates.rb +1 -0
- data/lib/fog/openstack/network.rb +21 -21
- data/lib/fog/openstack/orchestration.rb +11 -91
- data/lib/fog/openstack/planning.rb +19 -81
- data/lib/fog/openstack/requests/compute/list_security_groups.rb +9 -1
- data/lib/fog/openstack/requests/network/add_router_interface.rb +12 -4
- data/lib/fog/openstack/requests/network/create_port.rb +14 -12
- data/lib/fog/openstack/requests/network/get_port.rb +4 -0
- data/lib/fog/openstack/requests/network/set_tenant.rb +1 -0
- data/lib/fog/openstack/storage.rb +18 -57
- data/lib/fog/openstack/volume.rb +17 -79
- data/lib/fog/rackspace/requests/storage/get_object_https_url.rb +13 -2
- data/lib/fog/vcloud_director/generators/compute/edge_gateway_service_configuration.rb +7 -6
- data/lib/fog/vcloud_director/models/compute/vm_customizations.rb +15 -0
- data/lib/fog/version.rb +1 -1
- data/lib/tasks/changelog_task.rb +1 -0
- data/spec/fog/openstack/volume_spec.rb +5 -0
- data/tests/compute/helper.rb +0 -6
- data/tests/openstack/requests/network/port_tests.rb +14 -12
- data/tests/rackspace/requests/storage/object_tests.rb +46 -4
- data/tests/vcloud_director/requests/compute/edge_gateway_tests.rb +2 -2
- metadata +11 -74
- data/lib/fog/bin/dynect.rb +0 -28
- data/tests/brightbox/compute/helper.rb +0 -1
- data/tests/brightbox/compute/schema.rb +0 -799
- data/tests/brightbox/compute_tests.rb +0 -101
- data/tests/brightbox/helper.rb +0 -1
- data/tests/brightbox/models/compute/account_tests.rb +0 -17
- data/tests/brightbox/models/compute/cloud_ip_tests.rb +0 -32
- data/tests/brightbox/models/compute/database_server_tests.rb +0 -78
- data/tests/brightbox/models/compute/database_snapshot_tests.rb +0 -26
- data/tests/brightbox/models/compute/database_type_tests.rb +0 -27
- data/tests/brightbox/models/compute/server_tests.rb +0 -19
- data/tests/brightbox/oauth2_tests.rb +0 -110
- data/tests/brightbox/requests/compute/account_tests.rb +0 -65
- data/tests/brightbox/requests/compute/api_client_tests.rb +0 -64
- data/tests/brightbox/requests/compute/application_test.rb +0 -63
- data/tests/brightbox/requests/compute/cloud_ip_tests.rb +0 -85
- data/tests/brightbox/requests/compute/collaboration_tests.rb +0 -39
- data/tests/brightbox/requests/compute/database_server_tests.rb +0 -54
- data/tests/brightbox/requests/compute/database_snapsnot_tests.rb +0 -47
- data/tests/brightbox/requests/compute/database_type_tests.rb +0 -17
- data/tests/brightbox/requests/compute/firewall_policy_tests.rb +0 -40
- data/tests/brightbox/requests/compute/firewall_rule_tests.rb +0 -43
- data/tests/brightbox/requests/compute/helper.rb +0 -41
- data/tests/brightbox/requests/compute/image_tests.rb +0 -60
- data/tests/brightbox/requests/compute/interface_tests.rb +0 -33
- data/tests/brightbox/requests/compute/load_balancer_tests.rb +0 -121
- data/tests/brightbox/requests/compute/server_group_tests.rb +0 -96
- data/tests/brightbox/requests/compute/server_tests.rb +0 -99
- data/tests/brightbox/requests/compute/server_type_tests.rb +0 -34
- data/tests/brightbox/requests/compute/user_collaboration_tests.rb +0 -67
- data/tests/brightbox/requests/compute/user_tests.rb +0 -38
- data/tests/brightbox/requests/compute/zone_tests.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c821b9ebefd673f9820e7ae4f41afa5add225538
|
4
|
+
data.tar.gz: 1432597d1fa4695ea327825276f2720a2d460036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2afc927bafda27b29fffb39f59ffeb25f6e0a04cd5bbbba091c10b8fb44d997611b86a9e188103343a3821f5660daccc497220710646a39fc01b6ca38f669b15
|
7
|
+
data.tar.gz: 667d372ed314968334671ae4569c934236610958dc2e54717dd02d14c212eb8c3e5553500e795d77493723c66a4385fdace66bb06a4abf4602a0baa542bab683
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,50 @@
|
|
1
|
+
## 1.34.0 09/03/2015
|
2
|
+
*Hash* 23467f391cbc9d8d3262da33cec533f8b8e80cee
|
3
|
+
|
4
|
+
Statistic | Value
|
5
|
+
------------- | --------:
|
6
|
+
Collaborators | 2
|
7
|
+
Downloads | 11446261
|
8
|
+
Forks | 1472
|
9
|
+
Open Issues | 82
|
10
|
+
Watchers | 3594
|
11
|
+
|
12
|
+
**MVP!** Oleg Vivtash
|
13
|
+
|
14
|
+
#### [Brightbox]
|
15
|
+
* Remove provider specific tests. thanks Paul Thornthwaite
|
16
|
+
|
17
|
+
#### [OpenStack]
|
18
|
+
* Enable list_snapshots_detailed request. thanks Greg Blomquist
|
19
|
+
|
20
|
+
#### [misc]
|
21
|
+
* Adding #get_by_id for Fog::Compute::VcloudDirector::VmCustomizations. thanks Adam Leff
|
22
|
+
* Fix attach router to also use port id if passed. thanks Andrew Battye
|
23
|
+
* When getting a v3 identity service from the catalog, make sure the path includes /v3. thanks Darren Hague
|
24
|
+
* Fix issue #3662 - copy openstack_identity_endpoint option to @openstack_identity_public_endpoint. thanks Darren Hague
|
25
|
+
* Extract dynect bin from fog to fog-dynect. thanks Glenn Pratt
|
26
|
+
* Fix deprecated call to security_groups. thanks Greg Blomquist
|
27
|
+
* Fix deprecated call to resources. thanks Greg Blomquist
|
28
|
+
* Cloud Director supports multiple peer subnets. thanks Josh Myers
|
29
|
+
* Openstack missing passing of unscoped_token. thanks Ladislav Smola
|
30
|
+
* Allow Rackspace-specific options for get_object_https_url. thanks Oleg Vivtash
|
31
|
+
* Code prettified. thanks Oleg Vivtash
|
32
|
+
* Ruby187 hash syntax. thanks Oleg Vivtash
|
33
|
+
* Fog::Storage[:rackspace] object requests test update. thanks Oleg Vivtash
|
34
|
+
* Fog::Storage[:rackspace] object requests test cleanup. thanks Oleg Vivtash
|
35
|
+
* relax dependency for fog-ecloud. thanks Praveen Arimbrathodiyil
|
36
|
+
* support allowed address pairs. thanks pyama86
|
37
|
+
* style. thanks pyama86
|
38
|
+
* api path set. thanks pyama86
|
39
|
+
|
40
|
+
#### [openstack]
|
41
|
+
* allow auth_token attribute to be written to. thanks Darren Hague
|
42
|
+
* align recognized parameters, move common things among services into openstack core. thanks Maurice Schreiber
|
43
|
+
* undo premature move of identity_service_type: default value does no good. thanks Maurice Schreiber
|
44
|
+
* orchestration: add missing collection requires, path variable already contains tenant_id. thanks Maurice Schreiber
|
45
|
+
* core: fix wrong merge in 3b129ab9b2eac1cddc3fa680c88f436a6a853474. thanks Maurice Schreiber
|
46
|
+
|
47
|
+
|
1
48
|
## 1.33.0 08/12/2015
|
2
49
|
*Hash* 514fb792da07e6c5beaf4b735ea944fa873483f0
|
3
50
|
|
data/Rakefile
CHANGED
@@ -81,6 +81,9 @@ namespace :test do
|
|
81
81
|
task :openstack do
|
82
82
|
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/openstack")
|
83
83
|
end
|
84
|
+
task :rackspace do
|
85
|
+
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/rackspace")
|
86
|
+
end
|
84
87
|
task :cloudstack do
|
85
88
|
sh("export FOG_MOCK=#{mock} && bundle exec shindont tests/cloudstack")
|
86
89
|
end
|
data/fog.gemspec
CHANGED
@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
|
|
11
11
|
## If your rubyforge_project name is different, then edit it and comment out
|
12
12
|
## the sub! line in the Rakefile
|
13
13
|
s.name = "fog"
|
14
|
-
s.version = "1.
|
15
|
-
s.date = "2015-
|
14
|
+
s.version = "1.34.0"
|
15
|
+
s.date = "2015-09-03"
|
16
16
|
s.rubyforge_project = "fog"
|
17
17
|
|
18
18
|
## Make sure your summary is short. The description may be as long
|
@@ -55,8 +55,8 @@ Gem::Specification.new do |s|
|
|
55
55
|
s.add_dependency("fog-atmos")
|
56
56
|
s.add_dependency("fog-aws", ">= 0.6.0")
|
57
57
|
s.add_dependency("fog-brightbox", "~> 0.4")
|
58
|
-
s.add_dependency("fog-dynect")
|
59
|
-
s.add_dependency("fog-ecloud", "
|
58
|
+
s.add_dependency("fog-dynect", "~> 0.0.2")
|
59
|
+
s.add_dependency("fog-ecloud", "~> 0.1")
|
60
60
|
s.add_dependency("fog-google", ">= 0.0.2")
|
61
61
|
s.add_dependency("fog-local")
|
62
62
|
s.add_dependency("fog-powerdns", ">= 0.1.1")
|
@@ -6,10 +6,15 @@ module Fog
|
|
6
6
|
SUPPORTED_VERSIONS = /(.)*/
|
7
7
|
|
8
8
|
requires :openstack_auth_url
|
9
|
-
recognizes :openstack_auth_token, :openstack_management_url,
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
9
|
+
recognizes :openstack_auth_token, :openstack_management_url,
|
10
|
+
:persistent, :openstack_service_type, :openstack_service_name,
|
11
|
+
:openstack_tenant, :openstack_tenant_id,
|
12
|
+
:openstack_api_key, :openstack_username, :openstack_identity_endpoint,
|
13
|
+
:current_user, :current_tenant, :openstack_region,
|
14
|
+
:openstack_endpoint_type,
|
15
|
+
:openstack_project_name, :openstack_project_id,
|
16
|
+
:openstack_project_domain, :openstack_user_domain, :openstack_domain_name,
|
17
|
+
:openstack_project_domain_id, :openstack_user_domain_id, :openstack_domain_id
|
13
18
|
|
14
19
|
## MODELS
|
15
20
|
#
|
@@ -241,55 +246,29 @@ module Fog
|
|
241
246
|
end
|
242
247
|
|
243
248
|
class Real
|
244
|
-
|
245
|
-
attr_reader :current_tenant
|
249
|
+
include Fog::OpenStack::Core
|
246
250
|
|
247
251
|
def initialize(options={})
|
248
|
-
|
252
|
+
initialize_identity options
|
249
253
|
|
250
|
-
|
251
|
-
|
252
|
-
@openstack_api_key = options[:openstack_api_key]
|
253
|
-
@openstack_username = options[:openstack_username]
|
254
|
-
|
255
|
-
missing_credentials << :openstack_api_key unless @openstack_api_key
|
256
|
-
missing_credentials << :openstack_username unless @openstack_username
|
257
|
-
raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty?
|
258
|
-
end
|
259
|
-
|
260
|
-
@openstack_tenant = options[:openstack_tenant]
|
261
|
-
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
262
|
-
@openstack_management_url = options[:openstack_management_url]
|
263
|
-
@openstack_must_reauthenticate = false
|
264
|
-
@openstack_service_type = options[:openstack_service_type] || ['baremetal']
|
265
|
-
@openstack_service_name = options[:openstack_service_name]
|
266
|
-
@openstack_endpoint_type = options[:openstack_endpoint_type] || 'adminURL'
|
267
|
-
@openstack_region = options[:openstack_region]
|
254
|
+
@openstack_service_type = options[:openstack_service_type] || ['baremetal']
|
255
|
+
@openstack_service_name = options[:openstack_service_name]
|
268
256
|
|
269
257
|
@connection_options = options[:connection_options] || {}
|
270
258
|
|
271
|
-
@current_user = options[:current_user]
|
272
|
-
@current_tenant = options[:current_tenant]
|
273
|
-
|
274
259
|
authenticate
|
275
260
|
|
261
|
+
unless @path.match(SUPPORTED_VERSIONS)
|
262
|
+
@path = "/" + Fog::OpenStack.get_supported_version(SUPPORTED_VERSIONS,
|
263
|
+
@openstack_management_uri,
|
264
|
+
@auth_token,
|
265
|
+
@connection_options)
|
266
|
+
end
|
267
|
+
|
276
268
|
@persistent = options[:persistent] || false
|
277
269
|
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
278
270
|
end
|
279
271
|
|
280
|
-
def credentials
|
281
|
-
{ :provider => 'openstack',
|
282
|
-
:openstack_auth_url => @openstack_auth_uri.to_s,
|
283
|
-
:openstack_auth_token => @auth_token,
|
284
|
-
:openstack_management_url => @openstack_management_url,
|
285
|
-
:current_user => @current_user,
|
286
|
-
:current_tenant => @current_tenant }
|
287
|
-
end
|
288
|
-
|
289
|
-
def reload
|
290
|
-
@connection.reset
|
291
|
-
end
|
292
|
-
|
293
272
|
def request(params)
|
294
273
|
begin
|
295
274
|
response = @connection.request(params.merge({
|
@@ -323,47 +302,6 @@ module Fog
|
|
323
302
|
|
324
303
|
private
|
325
304
|
|
326
|
-
def authenticate
|
327
|
-
if !@openstack_management_url || @openstack_must_reauthenticate
|
328
|
-
options = {
|
329
|
-
:openstack_tenant => @openstack_tenant,
|
330
|
-
:openstack_api_key => @openstack_api_key,
|
331
|
-
:openstack_username => @openstack_username,
|
332
|
-
:openstack_auth_uri => @openstack_auth_uri,
|
333
|
-
:openstack_region => @openstack_region,
|
334
|
-
:openstack_auth_token => @openstack_must_reauthenticate ? nil : @openstack_auth_token,
|
335
|
-
:openstack_service_type => @openstack_service_type,
|
336
|
-
:openstack_service_name => @openstack_service_name,
|
337
|
-
:openstack_endpoint_type => @openstack_endpoint_type
|
338
|
-
}
|
339
|
-
|
340
|
-
credentials = Fog::OpenStack.authenticate(options, @connection_options)
|
341
|
-
|
342
|
-
@current_user = credentials[:user]
|
343
|
-
@current_tenant = credentials[:tenant]
|
344
|
-
|
345
|
-
@openstack_must_reauthenticate = false
|
346
|
-
@auth_token = credentials[:token]
|
347
|
-
@openstack_management_url = credentials[:server_management_url]
|
348
|
-
uri = URI.parse(@openstack_management_url)
|
349
|
-
else
|
350
|
-
@auth_token = @openstack_auth_token
|
351
|
-
uri = URI.parse(@openstack_management_url)
|
352
|
-
end
|
353
|
-
|
354
|
-
@host = uri.host
|
355
|
-
@path = uri.path
|
356
|
-
@path.sub!(/\/$/, '')
|
357
|
-
unless @path.match(SUPPORTED_VERSIONS)
|
358
|
-
@path = "/" + Fog::OpenStack.get_supported_version(SUPPORTED_VERSIONS,
|
359
|
-
uri,
|
360
|
-
@auth_token,
|
361
|
-
@connection_options)
|
362
|
-
end
|
363
|
-
@port = uri.port
|
364
|
-
@scheme = uri.scheme
|
365
|
-
true
|
366
|
-
end
|
367
305
|
end
|
368
306
|
end
|
369
307
|
end
|
@@ -327,28 +327,27 @@ module Fog
|
|
327
327
|
end
|
328
328
|
|
329
329
|
class Real
|
330
|
-
|
331
330
|
include Fog::OpenStack::Core
|
332
331
|
|
333
332
|
def initialize(options={})
|
334
333
|
initialize_identity options
|
335
334
|
|
336
335
|
@openstack_identity_service_type = options[:openstack_identity_service_type] || 'identity'
|
337
|
-
@openstack_service_type = options[:openstack_service_type] || ['nova', 'compute']
|
338
|
-
@openstack_service_name = options[:openstack_service_name]
|
339
|
-
|
340
|
-
@connection_options = options[:connection_options] || {}
|
341
336
|
|
342
|
-
|
337
|
+
@openstack_service_type = options[:openstack_service_type] || ['nova', 'compute']
|
338
|
+
@openstack_service_name = options[:openstack_service_name]
|
343
339
|
|
344
|
-
@
|
345
|
-
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
346
|
-
end
|
340
|
+
@connection_options = options[:connection_options] || {}
|
347
341
|
|
342
|
+
authenticate
|
348
343
|
|
344
|
+
unless @path.match(/1\.1|v2/)
|
345
|
+
raise Fog::OpenStack::Errors::ServiceUnavailable.new(
|
346
|
+
"OpenStack compute binding only supports version 2 (a.k.a. 1.1)")
|
347
|
+
end
|
349
348
|
|
350
|
-
|
351
|
-
@connection.
|
349
|
+
@persistent = options[:persistent] || false
|
350
|
+
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
|
352
351
|
end
|
353
352
|
|
354
353
|
def request(params)
|
@@ -365,7 +364,7 @@ module Fog
|
|
365
364
|
rescue Excon::Errors::Unauthorized => error
|
366
365
|
if error.response.body != 'Bad username or password' # token expiration
|
367
366
|
@openstack_must_reauthenticate = true
|
368
|
-
|
367
|
+
authenticate
|
369
368
|
retry
|
370
369
|
else # Bad Credentials
|
371
370
|
raise error
|
@@ -388,28 +387,6 @@ module Fog
|
|
388
387
|
|
389
388
|
private
|
390
389
|
|
391
|
-
def authenticate_compute
|
392
|
-
authenticate
|
393
|
-
|
394
|
-
uri = URI.parse(@openstack_management_url)
|
395
|
-
@host = uri.host
|
396
|
-
@path = uri.path
|
397
|
-
|
398
|
-
@path.sub!(/\/$/, '')
|
399
|
-
unless @path.match(/1\.1|v2/)
|
400
|
-
raise Fog::OpenStack::Errors::ServiceUnavailable.new(
|
401
|
-
"OpenStack compute binding only supports version 2 (a.k.a. 1.1)")
|
402
|
-
end
|
403
|
-
|
404
|
-
# Not all implementations have identity service in the catalog
|
405
|
-
if @openstack_identity_public_endpoint || @openstack_management_url
|
406
|
-
@identity_connection = Fog::Core::Connection.new(
|
407
|
-
@openstack_identity_public_endpoint || @openstack_management_url,
|
408
|
-
false, @connection_options)
|
409
|
-
end
|
410
|
-
|
411
|
-
true
|
412
|
-
end
|
413
390
|
end
|
414
391
|
end
|
415
392
|
end
|
data/lib/fog/openstack/core.rb
CHANGED
@@ -56,7 +56,7 @@ module Fog
|
|
56
56
|
service(:planning, 'Planning')
|
57
57
|
|
58
58
|
module Core
|
59
|
-
|
59
|
+
attr_accessor :auth_token
|
60
60
|
attr_reader :auth_token_expiration
|
61
61
|
attr_reader :current_user
|
62
62
|
attr_reader :current_user_id
|
@@ -75,6 +75,7 @@ module Fog
|
|
75
75
|
end
|
76
76
|
|
77
77
|
@auth_token ||= options[:openstack_auth_token]
|
78
|
+
@openstack_identity_public_endpoint = options[:openstack_identity_endpoint]
|
78
79
|
|
79
80
|
@openstack_auth_uri = URI.parse(options[:openstack_auth_url])
|
80
81
|
@openstack_must_reauthenticate = false
|
@@ -97,16 +98,22 @@ module Fog
|
|
97
98
|
end
|
98
99
|
|
99
100
|
def credentials
|
100
|
-
options = {
|
101
|
-
:
|
102
|
-
:
|
101
|
+
options = {
|
102
|
+
:provider => 'openstack',
|
103
|
+
:openstack_auth_url => @openstack_auth_uri.to_s,
|
104
|
+
:openstack_auth_token => @auth_token,
|
103
105
|
:openstack_identity_endpoint => @openstack_identity_public_endpoint,
|
104
|
-
:current_user
|
105
|
-
:current_user_id
|
106
|
-
:current_tenant
|
106
|
+
:current_user => @current_user,
|
107
|
+
:current_user_id => @current_user_id,
|
108
|
+
:current_tenant => @current_tenant,
|
109
|
+
:unscoped_token => @unscoped_token}
|
107
110
|
openstack_options.merge options
|
108
111
|
end
|
109
112
|
|
113
|
+
def reload
|
114
|
+
@connection.reset
|
115
|
+
end
|
116
|
+
|
110
117
|
private
|
111
118
|
|
112
119
|
def openstack_options
|
@@ -135,6 +142,7 @@ module Fog
|
|
135
142
|
@openstack_must_reauthenticate = false
|
136
143
|
@auth_token = credentials[:token]
|
137
144
|
@openstack_management_url = credentials[:server_management_url]
|
145
|
+
@unscoped_token = credentials[:unscoped_token]
|
138
146
|
else
|
139
147
|
@auth_token = @openstack_auth_token
|
140
148
|
end
|
@@ -142,8 +150,17 @@ module Fog
|
|
142
150
|
|
143
151
|
@host = @openstack_management_uri.host
|
144
152
|
@path = @openstack_management_uri.path
|
153
|
+
@path.sub!(/\/$/, '')
|
145
154
|
@port = @openstack_management_uri.port
|
146
155
|
@scheme = @openstack_management_uri.scheme
|
156
|
+
|
157
|
+
# Not all implementations have identity service in the catalog
|
158
|
+
if @openstack_identity_public_endpoint || @openstack_management_url
|
159
|
+
@identity_connection = Fog::Core::Connection.new(
|
160
|
+
@openstack_identity_public_endpoint || @openstack_management_url,
|
161
|
+
false, @connection_options)
|
162
|
+
end
|
163
|
+
|
147
164
|
true
|
148
165
|
end
|
149
166
|
end
|
@@ -342,7 +359,7 @@ module Fog
|
|
342
359
|
raise Fog::Errors::NotFound.new("Multiple regions available choose one of these '#{regions.join(',')}'")
|
343
360
|
end
|
344
361
|
|
345
|
-
identity_service = get_service_v3(body, identity_service_type) if identity_service_type
|
362
|
+
identity_service = get_service_v3(body, identity_service_type, nil, nil, :endpoint_path_matches => /\/v3/) if identity_service_type
|
346
363
|
|
347
364
|
management_url = service['endpoints'].find { |e| e['interface']==endpoint_type }['url']
|
348
365
|
identity_url = identity_service['endpoints'].find { |e| e['interface']=='public' }['url'] if identity_service
|
@@ -502,8 +519,9 @@ module Fog
|
|
502
519
|
[response.headers["X-Subject-Token"], Fog::JSON.decode(response.body)]
|
503
520
|
end
|
504
521
|
|
505
|
-
def self.get_service_v3(hash, service_type=[], service_name=nil, region=nil)
|
522
|
+
def self.get_service_v3(hash, service_type=[], service_name=nil, region=nil, options={})
|
506
523
|
|
524
|
+
# Find all services matching any of the types in service_type, filtered by service_name if it's non-nil
|
507
525
|
services = hash['token']['catalog'].find_all do |s|
|
508
526
|
if service_name.nil? or service_name.empty?
|
509
527
|
service_type.include?(s['type'])
|
@@ -512,12 +530,21 @@ module Fog
|
|
512
530
|
end
|
513
531
|
end if hash['token']['catalog']
|
514
532
|
|
533
|
+
# Filter the found services by region (if specified) and whether the endpoint path matches the given regex (e.g. /\/v3/)
|
515
534
|
services.find do |s|
|
516
|
-
|
535
|
+
s['endpoints'].any? { |ep| endpoint_region?(ep, region) && endpoint_path_match?(ep, options[:endpoint_path_matches])}
|
517
536
|
end if services
|
518
537
|
|
519
538
|
end
|
520
539
|
|
540
|
+
def self.endpoint_region?(endpoint, region)
|
541
|
+
region.nil? || endpoint['region'] == region
|
542
|
+
end
|
543
|
+
|
544
|
+
def self.endpoint_path_match?(endpoint, match_regex)
|
545
|
+
match_regex.nil? || URI(endpoint['url']).path =~ match_regex
|
546
|
+
end
|
547
|
+
|
521
548
|
def self.get_supported_version(supported_versions, uri, auth_token, connection_options = {})
|
522
549
|
connection = Fog::Core::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, connection_options)
|
523
550
|
response = connection.request({
|
@@ -22,53 +22,42 @@ module Fog
|
|
22
22
|
end
|
23
23
|
|
24
24
|
module Common
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
@unscoped_token = credentials[:unscoped_token]
|
55
|
-
uri = URI.parse(@openstack_management_url)
|
56
|
-
else
|
57
|
-
@auth_token = @openstack_auth_token
|
58
|
-
uri = URI.parse(@openstack_management_url)
|
25
|
+
attr_reader :unscoped_token
|
26
|
+
|
27
|
+
include Fog::OpenStack::Core
|
28
|
+
|
29
|
+
def request(params)
|
30
|
+
retried = false
|
31
|
+
begin
|
32
|
+
response = @connection.request(params.merge({
|
33
|
+
:headers => params.fetch(:headers,{}).merge({
|
34
|
+
'Content-Type' => 'application/json',
|
35
|
+
'Accept' => 'application/json',
|
36
|
+
'X-Auth-Token' => @auth_token
|
37
|
+
}),
|
38
|
+
:path => "#{@path}/#{params[:path]}"
|
39
|
+
}))
|
40
|
+
rescue Excon::Errors::Unauthorized => error
|
41
|
+
raise if retried
|
42
|
+
retried = true
|
43
|
+
|
44
|
+
@openstack_must_reauthenticate = true
|
45
|
+
authenticate
|
46
|
+
retry
|
47
|
+
rescue Excon::Errors::HTTPStatusError => error
|
48
|
+
raise case error
|
49
|
+
when Excon::Errors::NotFound
|
50
|
+
Fog::Identity::OpenStack::NotFound.slurp(error)
|
51
|
+
else
|
52
|
+
error
|
53
|
+
end
|
59
54
|
end
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
@port = uri.port
|
65
|
-
@scheme = uri.scheme
|
66
|
-
true
|
55
|
+
unless response.body.empty?
|
56
|
+
response.body = Fog::JSON.decode(response.body)
|
57
|
+
end
|
58
|
+
response
|
67
59
|
end
|
68
|
-
|
69
60
|
end
|
70
61
|
end
|
71
|
-
|
72
|
-
|
73
62
|
end
|
74
63
|
end
|