From 76ea6b97d061b7aaba5ef5e65195f67b7997e4a6 Mon Sep 17 00:00:00 2001 From: Zuhaib M Siddique Date: Fri, 7 Sep 2012 17:57:08 -0700 Subject: [PATCH] [AWS|Compute] Add the ablity to pass :version and use newer AWS API --- lib/fog/aws/compute.rb | 5 +++-- lib/fog/compute.rb | 5 ++--- tests/aws/requests/compute/instance_tests.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/fog/aws/compute.rb b/lib/fog/aws/compute.rb index 3d7f458f3..51388be30 100644 --- a/lib/fog/aws/compute.rb +++ b/lib/fog/aws/compute.rb @@ -7,7 +7,7 @@ module Fog extend Fog::AWS::CredentialFetcher::ServiceMethods requires :aws_access_key_id, :aws_secret_access_key - recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent, :aws_session_token, :use_iam_profile, :aws_credentials_expire_at, :instrumentor, :instrumentor_name + recognizes :endpoint, :region, :host, :path, :port, :scheme, :persistent, :aws_session_token, :use_iam_profile, :aws_credentials_expire_at, :instrumentor, :instrumentor_name, :version secrets :aws_secret_access_key, :hmac, :aws_session_token @@ -317,6 +317,7 @@ module Fog @region = options[:region] ||= 'us-east-1' @instrumentor = options[:instrumentor] @instrumentor_name = options[:instrumentor_name] || 'fog.aws.compute' + @version = options[:version] || '2012-07-20' if @endpoint = options[:endpoint] endpoint = URI.parse(@endpoint) @@ -362,7 +363,7 @@ module Fog :host => @host, :path => @path, :port => @port, - :version => '2012-07-20' + :version => @version } ) diff --git a/lib/fog/compute.rb b/lib/fog/compute.rb index c5919e087..4fddf6863 100644 --- a/lib/fog/compute.rb +++ b/lib/fog/compute.rb @@ -9,9 +9,6 @@ module Fog attributes = attributes.dup # prevent delete from having side effects provider = attributes.delete(:provider).to_s.downcase.to_sym - version = attributes.delete(:version) - version = version.to_s.downcase.to_sym unless version.nil? - case provider when :aws require 'fog/aws/compute' @@ -69,6 +66,8 @@ module Fog require 'fog/ovirt/compute' Fog::Compute::Ovirt.new(attributes) when :rackspace + version = attributes.delete(:version) + version = version.to_s.downcase.to_sym unless version.nil? if version == :v2 require 'fog/rackspace/compute_v2' Fog::Compute::RackspaceV2.new(attributes) diff --git a/tests/aws/requests/compute/instance_tests.rb b/tests/aws/requests/compute/instance_tests.rb index f947908cd..f53778b88 100644 --- a/tests/aws/requests/compute/instance_tests.rb +++ b/tests/aws/requests/compute/instance_tests.rb @@ -167,7 +167,7 @@ Shindo.tests('Fog::Compute[:aws] | instance requests', ['aws']) do 'ami-6bbb1302' # ubuntu 12.04 daily build 20120728 else # Use a MS Windows AMI to test #get_password_data - 'ami-c941efa0' # Amazon Public Images - Windows_Server-2008-SP2-English-64Bit-Base-2012.07.11 + 'ami-71b50018' # Amazon Public Images - Windows_Server-2008-SP2-English-64Bit-Base-2012.07.11 end # Create a keypair for decrypting the password