lib/fog/openstack/compute.rb in fog-1.28.0 vs lib/fog/openstack/compute.rb in fog-1.29.0

- old
+ new

@@ -100,10 +100,13 @@ # Flavor Access request :add_flavor_access request :remove_flavor_access request :list_tenants_with_flavor_access + # Hypervisor + request :get_hypervisor_statistics + # Metadata request :list_metadata request :get_metadata request :set_metadata request :update_metadata @@ -245,10 +248,11 @@ @data = nil end def initialize(options={}) @openstack_username = options[:openstack_username] + @openstack_domain = options[:openstack_domain] @openstack_auth_uri = URI.parse(options[:openstack_auth_url]) @current_tenant = options[:openstack_tenant] @auth_token = Fog::Mock.random_base64(64) @@ -284,27 +288,30 @@ class Real attr_reader :auth_token attr_reader :auth_token_expiration attr_reader :current_user attr_reader :current_tenant + attr_reader :openstack_domain def initialize(options={}) @openstack_auth_token = options[:openstack_auth_token] @auth_token = options[:openstack_auth_token] @openstack_identity_public_endpoint = options[:openstack_identity_endpoint] unless @auth_token missing_credentials = Array.new @openstack_api_key = options[:openstack_api_key] @openstack_username = options[:openstack_username] + @openstack_domain = options[:openstack_domain] missing_credentials << :openstack_api_key unless @openstack_api_key missing_credentials << :openstack_username unless @openstack_username raise ArgumentError, "Missing required arguments: #{missing_credentials.join(', ')}" unless missing_credentials.empty? end @openstack_tenant = options[:openstack_tenant] + @openstack_domain = options[:openstack_domain] || 'Default' @openstack_auth_uri = URI.parse(options[:openstack_auth_url]) @openstack_management_url = options[:openstack_management_url] @openstack_must_reauthenticate = false @openstack_service_type = options[:openstack_service_type] || ['nova', 'compute'] @openstack_service_name = options[:openstack_service_name] @@ -323,10 +330,11 @@ @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options) end def credentials { :provider => 'openstack', + :openstack_domain => @openstack_domain, :openstack_auth_url => @openstack_auth_uri.to_s, :openstack_auth_token => @auth_token, :openstack_management_url => @openstack_management_url, :openstack_identity_endpoint => @openstack_identity_public_endpoint, :openstack_region => @openstack_region, @@ -378,10 +386,11 @@ def authenticate if !@openstack_management_url || @openstack_must_reauthenticate options = { :openstack_api_key => @openstack_api_key, :openstack_username => @openstack_username, + :openstack_domain => @openstack_domain, :openstack_auth_token => @openstack_must_reauthenticate ? nil : @auth_token, :openstack_auth_uri => @openstack_auth_uri, :openstack_region => @openstack_region, :openstack_tenant => @openstack_tenant, :openstack_service_type => @openstack_service_type, @@ -391,10 +400,12 @@ } if @openstack_auth_uri.path =~ /\/v2.0/ credentials = Fog::OpenStack.authenticate_v2(options, @connection_options) + elsif @openstack_auth_uri.path =~ /\/v3/ + credentials = Fog::OpenStack.authenticate_v3(options, @connection_options) else credentials = Fog::OpenStack.authenticate_v1(options, @connection_options) end @current_user = credentials[:user] @@ -410,10 +421,10 @@ uri = URI.parse(@openstack_management_url) @host = uri.host @path, @tenant_id = uri.path.scan(/(\/.*)\/(.*)/).flatten @path.sub!(/\/$/, '') - unless @path.match(/1\.1|v2/) + unless @path.match(/1\.1|v2|v3/) raise Fog::OpenStack::Errors::ServiceUnavailable.new( "OpenStack binding only supports version 2 (a.k.a. 1.1)") end @port = uri.port