Skip to content

Commit

Permalink
[Compute|OpenStack] match auth response to stable/diablo branch of ke…
Browse files Browse the repository at this point in the history
…ystone

This may require more tweaks for Essex, or when Keystone Light lands.

I also believe v1.0 auth may be broken by not sending back the
X-Server-Management-Url header.
  • Loading branch information
xtoddx committed Feb 10, 2012
1 parent f5cb2ad commit 564b688
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions lib/fog/openstack.rb
Expand Up @@ -79,12 +79,14 @@ def self.authenticate_v2(options, connection_options = {})
@compute_service_name = options[:openstack_compute_service_name]

req_body= {
'passwordCredentials' => {
'username' => @openstack_username,
'password' => @openstack_api_key
'auth' => {
'passwordCredentials' => {
'username' => @openstack_username,
'password' => @openstack_api_key
}
}
}
req_body['tenantId'] = @openstack_tenant if @openstack_tenant
req_body['auth']['tenantName'] = @openstack_tenant if @openstack_tenant

response = connection.request({
:expects => [200, 204],
Expand All @@ -96,9 +98,9 @@ def self.authenticate_v2(options, connection_options = {})
})
body=MultiJson.decode(response.body)

if body['auth']['serviceCatalog'] and body['auth']['serviceCatalog'][@compute_service_name] and body['auth']['serviceCatalog'][@compute_service_name][0] then
mgmt_url = body['auth']['serviceCatalog'][@compute_service_name][0]['publicURL']
token = body['auth']['token']['id']
if svc = body['access']['serviceCatalog'].detect{|x| x['name'] == @compute_service_name}
mgmt_url = svc['endpoints'].detect{|x| x['publicURL']}['publicURL']
token = body['access']['token']['id']
return {
:token => token,
:server_management_url => mgmt_url
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/openstack/compute.rb
Expand Up @@ -186,8 +186,8 @@ def authenticate
raise Fog::Compute::OpenStack::ServiceUnavailable.new(
"OpenStack binding only supports version 1.1")
end
# Add tenant
@path += @openstack_tenant if @openstack_tenant
# Add tenant (done by keystone now for 1.1 auth api)
# @path += @openstack_tenant if @openstack_tenant
@port = uri.port
@scheme = uri.scheme
end
Expand Down

0 comments on commit 564b688

Please sign in to comment.