Browse files

Adding ability to launch t1.micro instances.

  • Loading branch information...
1 parent 339278c commit 14b2ea146f4ae66ee8d026b45556bac88efcdf42 @nstielau nstielau committed with Sep 12, 2010
Showing with 8 additions and 4 deletions.
  1. +1 −1 lib/AWS/EC2/instances.rb
  2. +7 −3 test/test_EC2_instances.rb
View
2 lib/AWS/EC2/instances.rb
@@ -36,7 +36,7 @@ def run_instances( options = {} )
raise ArgumentError, ":image_id must be provided" if options[:image_id].nil? || options[:image_id].empty?
raise ArgumentError, ":min_count is not valid" unless options[:min_count].to_i > 0
raise ArgumentError, ":max_count is not valid or must be >= :min_count" unless options[:max_count].to_i > 0 && options[:max_count].to_i >= options[:min_count].to_i
- raise ArgumentError, ":instance_type must specify a valid instance type" unless options[:instance_type].nil? || ["m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].include?(options[:instance_type])
+ raise ArgumentError, ":instance_type must specify a valid instance type" unless options[:instance_type].nil? || ["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].include?(options[:instance_type])
raise ArgumentError, ":monitoring_enabled must be 'true' or 'false'" unless options[:monitoring_enabled].nil? || [true, false].include?(options[:monitoring_enabled])
raise ArgumentError, ":disable_api_termination must be 'true' or 'false'" unless options[:disable_api_termination].nil? || [true, false].include?(options[:disable_api_termination])
raise ArgumentError, ":instance_initiated_shutdown_behavior must be 'stop' or 'terminate'" unless options[:instance_initiated_shutdown_behavior].nil? || ["stop", "terminate"].include?(options[:instance_initiated_shutdown_behavior])
View
10 test/test_EC2_instances.rb
@@ -304,9 +304,13 @@
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 2, :max_count => 1 ) }.should.raise(AWS::ArgumentError)
# :instance_type
- @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "InstanceType" => 'm1.small').
- returns stub(:body => @run_instances_response_body, :is_a? => true)
- lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_type => "m1.small" ) }.should.not.raise(AWS::ArgumentError)
+
+ ["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].each do |type|
+ @ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "InstanceType" => type).
+ returns stub(:body => @run_instances_response_body, :is_a? => true)
+ lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_type => type ) }.should.not.raise(AWS::ArgumentError)
+ end
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_type => "m1.notarealsize" ) }.should.raise(AWS::ArgumentError)
# :monitoring_enabled

0 comments on commit 14b2ea1

Please sign in to comment.