Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[openstack] Re-record VCRs, plus some light refactoring
Also, the bug in webmock 1.22.1 is now fixed, so enforce webmock 1.22.2 or higher
- Loading branch information
Showing
35 changed files
with
4,649 additions
and
3,879 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,17 +154,16 @@ def authenticate | |
@port = @openstack_management_uri.port | ||
@scheme = @openstack_management_uri.scheme | ||
|
||
# Not all implementations have identity service in the catalog | ||
if @openstack_identity_public_endpoint || @openstack_management_url | ||
@identity_connection = Fog::Core::Connection.new( | ||
@openstack_identity_public_endpoint || @openstack_management_url, | ||
false, @connection_options) | ||
end | ||
|
||
true | ||
end | ||
end | ||
|
||
@@token_cache = {} | ||
|
||
def self.clear_token_cache | ||
@@token_cache.clear | ||
end | ||
|
||
def self.authenticate(options, connection_options = {}) | ||
case options[:openstack_auth_uri].path | ||
when /v1(\.\d+)?/ | ||
|
@@ -410,7 +409,7 @@ def self.retrieve_tokens_v2(options, connection_options = {}) | |
auth_token = options[:openstack_auth_token] || options[:unscoped_token] | ||
uri = options[:openstack_auth_uri] | ||
|
||
connection = Fog::Core::Connection.new(uri.to_s, false, connection_options) | ||
@identity_connection = Fog::Core::Connection.new(uri.to_s, false, connection_options) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
dhague
Author
Contributor
|
||
request_body = {:auth => Hash.new} | ||
|
||
if auth_token | ||
|
@@ -425,7 +424,7 @@ def self.retrieve_tokens_v2(options, connection_options = {}) | |
end | ||
request_body[:auth][:tenantName] = tenant_name if tenant_name | ||
|
||
response = connection.request({ | ||
response = @identity_connection.request({ | ||
:expects => [200, 204], | ||
:headers => {'Content-Type' => 'application/json'}, | ||
:body => Fog::JSON.encode(request_body), | ||
|
@@ -506,15 +505,14 @@ def self.retrieve_tokens_v3(options, connection_options = {}) | |
|
||
path = (uri.path and not uri.path.empty?) ? uri.path : 'v3' | ||
|
||
@@token_cache ||= {} | ||
response, expires = @@token_cache[{body: request_body, path: path}] | ||
|
||
unless response && expires > Time.now | ||
response = connection.request({ :expects => [201], | ||
:headers => {'Content-Type' => 'application/json'}, | ||
:body => Fog::JSON.encode(request_body), | ||
:method => 'POST', | ||
:path => (uri.path and not uri.path.empty?) ? uri.path : 'v3' | ||
:path => path | ||
}) | ||
@@token_cache[{body: request_body, path: path}] = response, Time.now + 30 # 30-second TTL, enough for most requests | ||
end | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Instance variables should not be created within class methods like this one. It was fine where it was before. Now calls like this one https://github.com/fog/fog/blob/master/lib/fog/openstack/requests/compute/list_tenants.rb are not possible to make.