@@ -300,11 +300,12 @@ def self.get_service(body, service_type=[], service_name=nil)
300300 end
301301
302302 def self . retrieve_tokens_v2 ( options , connection_options = { } )
303- api_key = options [ :openstack_api_key ] . to_s
304- username = options [ :openstack_username ] . to_s
305- tenant_name = options [ :openstack_tenant ] . to_s
306- auth_token = options [ :openstack_auth_token ] || options [ :unscoped_token ]
307- uri = options [ :openstack_auth_uri ]
303+ api_key = options [ :openstack_api_key ] . to_s
304+ username = options [ :openstack_username ] . to_s
305+ tenant_name = options [ :openstack_tenant ] . to_s
306+ auth_token = options [ :openstack_auth_token ] || options [ :unscoped_token ]
307+ uri = options [ :openstack_auth_uri ]
308+ omit_default_port = options [ :openstack_auth_omit_default_port ]
308309
309310 identity_v2_connection = Fog ::Core ::Connection . new ( uri . to_s , false , connection_options )
310311 request_body = { :auth => Hash . new }
@@ -321,32 +322,36 @@ def self.retrieve_tokens_v2(options, connection_options = {})
321322 end
322323 request_body [ :auth ] [ :tenantName ] = tenant_name if tenant_name
323324
324- response = identity_v2_connection . request ( {
325- :expects => [ 200 , 204 ] ,
326- :headers => { 'Content-Type' => 'application/json' } ,
327- :body => Fog ::JSON . encode ( request_body ) ,
328- :method => 'POST' ,
329- :path => ( uri . path and not uri . path . empty? ) ? uri . path : 'v2.0'
330- } )
325+ request = {
326+ :expects => [ 200 , 204 ] ,
327+ :headers => { 'Content-Type' => 'application/json' } ,
328+ :body => Fog ::JSON . encode ( request_body ) ,
329+ :method => 'POST' ,
330+ :path => ( uri . path and not uri . path . empty? ) ? uri . path : 'v2.0'
331+ }
332+ request [ :omit_default_port ] = omit_default_port unless omit_default_port . nil?
333+
334+ response = identity_v2_connection . request ( request )
331335
332336 Fog ::JSON . decode ( response . body )
333337 end
334338
335339 def self . retrieve_tokens_v3 ( options , connection_options = { } )
336340
337- api_key = options [ :openstack_api_key ] . to_s
338- username = options [ :openstack_username ] . to_s
339- userid = options [ :openstack_userid ]
340- domain_id = options [ :openstack_domain_id ]
341- domain_name = options [ :openstack_domain_name ]
342- project_domain = options [ :openstack_project_domain ]
341+ api_key = options [ :openstack_api_key ] . to_s
342+ username = options [ :openstack_username ] . to_s
343+ userid = options [ :openstack_userid ]
344+ domain_id = options [ :openstack_domain_id ]
345+ domain_name = options [ :openstack_domain_name ]
346+ project_domain = options [ :openstack_project_domain ]
343347 project_domain_id = options [ :openstack_project_domain_id ]
344- user_domain = options [ :openstack_user_domain ]
345- user_domain_id = options [ :openstack_user_domain_id ]
346- project_name = options [ :openstack_project_name ]
347- project_id = options [ :openstack_project_id ]
348- auth_token = options [ :openstack_auth_token ] || options [ :unscoped_token ]
349- uri = options [ :openstack_auth_uri ]
348+ user_domain = options [ :openstack_user_domain ]
349+ user_domain_id = options [ :openstack_user_domain_id ]
350+ project_name = options [ :openstack_project_name ]
351+ project_id = options [ :openstack_project_id ]
352+ auth_token = options [ :openstack_auth_token ] || options [ :unscoped_token ]
353+ uri = options [ :openstack_auth_uri ]
354+ omit_default_port = options [ :openstack_auth_omit_default_port ]
350355
351356 connection = Fog ::Core ::Connection . new ( uri . to_s , false , connection_options )
352357 request_body = { :auth => { } }
@@ -405,12 +410,16 @@ def self.retrieve_tokens_v3(options, connection_options = {})
405410 response , expires = @@token_cache [ { body : request_body , path : path } ]
406411
407412 unless response && expires > Time . now
408- response = connection . request ( { :expects => [ 201 ] ,
409- :headers => { 'Content-Type' => 'application/json' } ,
410- :body => Fog ::JSON . encode ( request_body ) ,
411- :method => 'POST' ,
412- :path => path
413- } )
413+ request = {
414+ :expects => [ 201 ] ,
415+ :headers => { 'Content-Type' => 'application/json' } ,
416+ :body => Fog ::JSON . encode ( request_body ) ,
417+ :method => 'POST' ,
418+ :path => path
419+ }
420+ request [ :omit_default_port ] = omit_default_port unless omit_default_port . nil?
421+
422+ response = connection . request ( request )
414423 @@token_cache [ { body : request_body , path : path } ] = response , Time . now + 30 # 30-second TTL, enough for most requests
415424 end
416425
0 commit comments