From 564b6884afd3bb32cbd233b37c8539cb9aa47ae2 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Fri, 10 Feb 2012 17:19:08 +0000 Subject: [PATCH] [Compute|OpenStack] match auth response to stable/diablo branch of keystone 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. --- lib/fog/openstack.rb | 16 +++++++++------- lib/fog/openstack/compute.rb | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/fog/openstack.rb b/lib/fog/openstack.rb index afebfd0b8c..720799fc98 100644 --- a/lib/fog/openstack.rb +++ b/lib/fog/openstack.rb @@ -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], @@ -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 diff --git a/lib/fog/openstack/compute.rb b/lib/fog/openstack/compute.rb index 2a4b548a3b..d064a8c4ff 100644 --- a/lib/fog/openstack/compute.rb +++ b/lib/fog/openstack/compute.rb @@ -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