lib/fog/openstack/compute.rb in fog-1.7.0 vs lib/fog/openstack/compute.rb in fog-1.8.0

- old
+ new

@@ -67,10 +67,11 @@ request :change_server_password request :add_fixed_ip request :remove_fixed_ip request :server_diagnostics request :boot_from_snapshot + request :reset_server_state # Server Extenstions request :get_console_output request :get_vnc_console request :live_migrate_server @@ -123,10 +124,11 @@ request :delete_key_pair # Tenant request :list_tenants request :set_tenant + request :get_limits # Volume request :list_volumes request :create_volume request :get_volume_details @@ -187,17 +189,17 @@ :key_pairs => {}, :security_groups => {}, :addresses => {}, :quota => { 'metadata_items' => 128, + 'key_pairs' => 10, 'injected_file_content_bytes' => 10240, + 'injected_file_path_bytes' => 256, 'injected_files' => 5, - 'gigabytes' => 1000, 'ram' => 51200, 'floating_ips' => 10, 'instances' => 10, - 'volumes' => 10, 'cores' => 20, } } end end @@ -247,13 +249,14 @@ attr_reader :current_user attr_reader :current_tenant 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 @openstack_auth_token + unless @auth_token missing_credentials = Array.new @openstack_api_key = options[:openstack_api_key] @openstack_username = options[:openstack_username] missing_credentials << :openstack_api_key unless @openstack_api_key @@ -298,10 +301,11 @@ def request(params) begin response = @connection.request(params.merge({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, :path => "#{@path}/#{@tenant_id}/#{params[:path]}", :query => params[:query] || ('ignore_awful_caching' << Time.now.to_i.to_s) @@ -331,18 +335,18 @@ end 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, - :openstack_auth_token => @openstack_auth_token, - :openstack_auth_uri => @openstack_auth_uri, - :openstack_region => @openstack_region, - :openstack_tenant => @openstack_tenant, + :openstack_api_key => @openstack_api_key, + :openstack_username => @openstack_username, + :openstack_auth_token => @auth_token, + :openstack_auth_uri => @openstack_auth_uri, + :openstack_region => @openstack_region, + :openstack_tenant => @openstack_tenant, :openstack_service_name => @openstack_service_name, :openstack_identity_service_name => @openstack_identity_service_name } if @openstack_auth_uri.path =~ /\/v2.0\// @@ -357,15 +361,12 @@ @openstack_must_reauthenticate = false @auth_token = credentials[:token] @auth_token_expiration = credentials[:expires] @openstack_management_url = credentials[:server_management_url] @openstack_identity_public_endpoint = credentials[:identity_public_endpoint] - uri = URI.parse(@openstack_management_url) - else - @auth_token = @openstack_auth_token - uri = URI.parse(@openstack_management_url) end + uri = URI.parse(@openstack_management_url) @host = uri.host @path, @tenant_id = uri.path.scan(/(\/.*)\/(.*)/).flatten @path.sub!(/\/$/, '') unless @path.match(/1\.1|v2/)