lib/fog/openstack/compute.rb in fog-1.0.0 vs lib/fog/openstack/compute.rb in fog-1.1.0

- old
+ new

@@ -4,12 +4,12 @@ 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 collection :flavors model :image @@ -165,11 +165,11 @@ :openstack_username => @openstack_username, :openstack_auth_url => @openstack_auth_url, :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) end @auth_token = credentials[:token] @@ -179,11 +179,14 @@ @auth_token = @openstack_auth_token uri = URI.parse(@openstack_management_url) 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 @scheme = uri.scheme end