mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #559 from xtoddx/osauth
[OpenStack|compute] fix v2.0 auth endpoints
This commit is contained in:
commit
2acb3006f5
2 changed files with 12 additions and 8 deletions
|
@ -88,12 +88,13 @@ module Fog
|
|||
|
||||
response = connection.request({
|
||||
:expects => [200, 204],
|
||||
:body => req_body,
|
||||
:headers => {'Content-Type' => 'application/json'},
|
||||
:body => MultiJson.encode(req_body),
|
||||
:host => uri.host,
|
||||
:method => 'GET',
|
||||
:method => 'POST',
|
||||
:path => (uri.path and not uri.path.empty?) ? uri.path : 'v2.0'
|
||||
})
|
||||
body=response.body
|
||||
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']
|
||||
|
|
|
@ -6,8 +6,8 @@ module Fog
|
|||
module Compute
|
||||
class OpenStack < Fog::Service
|
||||
|
||||
requires :openstack_api_key, :openstack_username, :openstack_auth_url, :openstack_tenant
|
||||
recognizes :openstack_auth_token, :openstack_management_url, :persistent, :openstack_compute_service_name
|
||||
requires :openstack_api_key, :openstack_username, :openstack_auth_url
|
||||
recognizes :openstack_auth_token, :openstack_management_url, :persistent, :openstack_compute_service_name, :openstack_tenant
|
||||
|
||||
model_path 'fog/openstack/models/compute'
|
||||
model :flavor
|
||||
|
@ -167,7 +167,7 @@ module Fog
|
|||
:openstack_tenant => @openstack_tenant,
|
||||
:openstack_compute_service_name => @openstack_compute_service_name
|
||||
}
|
||||
if @openstack_auth_url =~ /.*v2.0\/?$/
|
||||
if @openstack_auth_url =~ /\/v2.0\//
|
||||
credentials = Fog::OpenStack.authenticate_v2(options, @connection_options)
|
||||
else
|
||||
credentials = Fog::OpenStack.authenticate_v1(options, @connection_options)
|
||||
|
@ -181,8 +181,11 @@ module Fog
|
|||
end
|
||||
@host = uri.host
|
||||
@path = uri.path
|
||||
# Force URL into v1.1 namespace (what this binding supports)
|
||||
@path.sub!(/\/.*\/?/, '/v1.1/')
|
||||
@path.sub!(/\/$/, '')
|
||||
unless @path.match(/1\.1/)
|
||||
raise Fog::Compute::OpenStack::ServiceUnavailable.new(
|
||||
"OpenStack binding only supports version 1.1")
|
||||
end
|
||||
# Add tenant
|
||||
@path += @openstack_tenant if @openstack_tenant
|
||||
@port = uri.port
|
||||
|
|
Loading…
Reference in a new issue