diff --git a/lib/fog/openstack.rb b/lib/fog/openstack.rb index 7d8dc80d3..6d4689cd1 100644 --- a/lib/fog/openstack.rb +++ b/lib/fog/openstack.rb @@ -84,6 +84,8 @@ module Fog service = body['access']['serviceCatalog']. detect {|s| service_name.include?(s['type']) } + options[:unscoped_token] = body['access']['token']['id'] + unless service unless tenant_name response = Fog::Connection.new( @@ -133,7 +135,8 @@ module Fog :server_management_url => management_url, :token => body['access']['token']['id'], :expires => body['access']['token']['expires'], - :current_user_id => body['access']['user']['id'] + :current_user_id => body['access']['user']['id'], + :unscoped_token => options[:unscoped_token] } end @@ -141,7 +144,7 @@ module Fog api_key = options[:openstack_api_key].to_s username = options[:openstack_username].to_s tenant_name = options[:openstack_tenant].to_s - auth_token = options[:openstack_auth_token] + auth_token = options[:openstack_auth_token] || options[:unscoped_token] uri = options[:openstack_auth_uri] connection = Fog::Connection.new(uri.to_s, false, connection_options) diff --git a/lib/fog/openstack/identity.rb b/lib/fog/openstack/identity.rb index bfe5fe257..09bbb4745 100644 --- a/lib/fog/openstack/identity.rb +++ b/lib/fog/openstack/identity.rb @@ -153,6 +153,7 @@ module Fog class Real attr_reader :current_user attr_reader :current_tenant + attr_reader :unscoped_token def initialize(options={}) @openstack_auth_token = options[:openstack_auth_token] @@ -238,7 +239,7 @@ module Fog private def authenticate - if @openstack_must_reauthenticate || @openstack_auth_token.nil? + if !@openstack_management_url || @openstack_must_reauthenticate options = { :openstack_api_key => @openstack_api_key, :openstack_username => @openstack_username, @@ -258,6 +259,7 @@ module Fog @auth_token = credentials[:token] @openstack_management_url = credentials[:server_management_url] @openstack_current_user_id = credentials[:current_user_id] + @unscoped_token = credentials[:unscoped_token] uri = URI.parse(@openstack_management_url) else @auth_token = @openstack_auth_token diff --git a/lib/fog/openstack/image.rb b/lib/fog/openstack/image.rb index b410d5e3b..f822e4b10 100644 --- a/lib/fog/openstack/image.rb +++ b/lib/fog/openstack/image.rb @@ -172,7 +172,7 @@ module Fog private def authenticate - if @openstack_must_reauthenticate || @openstack_auth_token.nil? + if !@openstack_management_url || @openstack_must_reauthenticate options = { :openstack_tenant => @openstack_tenant, :openstack_api_key => @openstack_api_key, diff --git a/lib/fog/openstack/volume.rb b/lib/fog/openstack/volume.rb index 88a1fe102..e3c1629d9 100644 --- a/lib/fog/openstack/volume.rb +++ b/lib/fog/openstack/volume.rb @@ -175,7 +175,7 @@ module Fog private def authenticate - if @openstack_must_reauthenticate || @openstack_auth_token.nil? + if !@openstack_management_url || @openstack_must_reauthenticate options = { :openstack_tenant => @openstack_tenant, :openstack_api_key => @openstack_api_key,