diff --git a/lib/miasma/contrib/open_stack.rb b/lib/miasma/contrib/open_stack.rb index 059cc42..21abadb 100644 --- a/lib/miasma/contrib/open_stack.rb +++ b/lib/miasma/contrib/open_stack.rb @@ -155,15 +155,15 @@ def authentication_request ) ) else - if(credentials[:open_stack_domain]) + if(credentials[:open_stack_project]) scope = Smash.new( - :domain => Smash.new( - :name => credentials[:open_stack_domain] + :project => Smash.new( + :name => credentials[:open_stack_project] ) ) - if(credentials[:open_stack_project]) - scope[:project] = Smash.new( - :name => credentials[:open_stack_project] + if(credentials[:open_stack_domain]) + scope[:project][:domain] = Smash.new( + :name => credentials[:open_stack_domain] ) end end @@ -186,7 +186,7 @@ def identify_and_load :auth => authentication_request ) ) - unless(result.status == 200) + unless(result.status == 200 || result.status == 201) raise Error::ApiError::AuthenticationError.new('Failed to authenticate!', result) end info = MultiJson.load(result.body.to_s).to_smash[:token] @@ -314,7 +314,9 @@ def endpoint_for(api_name, region) end if(region) point = srv[:endpoints].detect do |endpoint| - endpoint[:region].to_s.downcase == region.to_s.downcase + if(endpoint[:interface].to_s.downcase == "public") + endpoint[:region].to_s.downcase == region.to_s.downcase + end end else point = srv[:endpoints].first @@ -340,4 +342,4 @@ def api_token Models::Compute.autoload :OpenStack, 'miasma/contrib/open_stack/compute' Models::Orchestration.autoload :OpenStack, 'miasma/contrib/open_stack/orchestration' Models::Storage.autoload :OpenStack, 'miasma/contrib/open_stack/storage' -end +end \ No newline at end of file