amazon-ec2 0.9.15 → 0.9.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/ChangeLog +25 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +29 -0
- data/README.rdoc +24 -44
- data/Rakefile +3 -24
- data/amazon-ec2.gemspec +25 -140
- data/bin/awshell +81 -0
- data/bin/ec2sh +6 -48
- data/bin/setup.rb +57 -8
- data/lib/AWS.rb +49 -5
- data/lib/AWS/Autoscaling.rb +0 -2
- data/lib/AWS/Cloudwatch.rb +0 -2
- data/lib/AWS/Cloudwatch/monitoring.rb +22 -7
- data/lib/AWS/EC2.rb +1 -1
- data/lib/AWS/EC2/instances.rb +38 -11
- data/lib/AWS/EC2/password.rb +20 -0
- data/lib/AWS/EC2/spot_instance_requests.rb +1 -0
- data/lib/AWS/EC2/spot_prices.rb +3 -3
- data/lib/AWS/EC2/tags.rb +47 -0
- data/lib/AWS/EC2/volumes.rb +1 -1
- data/lib/AWS/ELB.rb +0 -2
- data/lib/AWS/RDS.rb +0 -2
- data/lib/AWS/RDS/rds.rb +5 -5
- data/lib/AWS/version.rb +3 -0
- data/test/test_EC2.rb +2 -2
- data/test/test_EC2_instances.rb +96 -3
- data/test/test_EC2_password.rb +46 -0
- data/test/test_EC2_spot_instance_requests.rb +11 -0
- data/test/test_EC2_spot_prices.rb +11 -3
- data/test/test_EC2_volumes.rb +16 -0
- metadata +43 -23
- data/README_dev.rdoc +0 -11
- data/perftools/ec2prof +0 -0
- data/perftools/ec2prof-results.dot +0 -132
- data/perftools/ec2prof-results.txt +0 -100
- data/perftools/ec2prof.symbols +0 -102
@@ -37,6 +37,7 @@ module AWS
|
|
37
37
|
raise ArgumentError, ":addressing_type has been deprecated." if options[:addressing_type]
|
38
38
|
raise ArgumentError, ":spot_price must be provided" if options[:spot_price].nil? || options[:spot_price].empty?
|
39
39
|
raise ArgumentError, ":base64_encoded must be 'true' or 'false'" unless [true, false].include?(options[:base64_encoded])
|
40
|
+
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])
|
40
41
|
|
41
42
|
user_data = extract_user_data(options)
|
42
43
|
|
data/lib/AWS/EC2/spot_prices.rb
CHANGED
@@ -2,7 +2,7 @@ module AWS
|
|
2
2
|
module EC2
|
3
3
|
|
4
4
|
class Base < AWS::Base
|
5
|
-
|
5
|
+
|
6
6
|
# This method returns historical information about spot prices.
|
7
7
|
#
|
8
8
|
# Amazon periodically sets the spot price for each instance type based on
|
@@ -16,7 +16,7 @@ module AWS
|
|
16
16
|
def describe_spot_price_history( options = {} )
|
17
17
|
raise ArgumentError, ":start_time must be a Time object" unless options[:start_time].nil? || options[:start_time].kind_of?(Time)
|
18
18
|
raise ArgumentError, ":end_time must be a Time object" unless options[:end_time].nil? || options[:end_time].kind_of?(Time)
|
19
|
-
raise ArgumentError, ":instance_type must specify a valid instance type" unless options[:instance_type].nil? || ["m1.small", "m1.large", "m1.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge"].include?(options[:instance_type])
|
19
|
+
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])
|
20
20
|
raise ArgumentError, ":product_description must be 'Linux/UNIX' or 'Windows'" unless options[:product_description].nil? || ["Linux/UNIX", "Windows"].include?(options[:product_description])
|
21
21
|
|
22
22
|
params = {}
|
@@ -24,7 +24,7 @@ module AWS
|
|
24
24
|
params.merge!("EndTime" => options[:end_time].iso8601) if options[:end_time]
|
25
25
|
params.merge!("InstanceType" => options[:instance_type]) if options[:instance_type]
|
26
26
|
params.merge!("ProductDescription" => options[:product_description]) if options[:product_description]
|
27
|
-
|
27
|
+
|
28
28
|
return response_generator(:action => "DescribeSpotPriceHistory", :params => params)
|
29
29
|
end
|
30
30
|
|
data/lib/AWS/EC2/tags.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module AWS
|
2
|
+
module EC2
|
3
|
+
class Base < AWS::Base
|
4
|
+
|
5
|
+
# The CreateTags operation adds or overwrites tags for the specified resource(s).
|
6
|
+
#
|
7
|
+
# @option options [Array] :resource_id ([]) The ids of the resource(s) to tag
|
8
|
+
# @option options [Array] :tag ([]) An array of Hashes representing the tags { tag_name => tag_value }. Use nil or empty string to get a tag without a value
|
9
|
+
#
|
10
|
+
def create_tags( options = {} )
|
11
|
+
raise ArgumentError, "No :resource_id provided" if options[:resource_id].nil? || options[:resource_id].empty?
|
12
|
+
raise ArgumentError, "No :tag provided" if options[:tag].nil? || options[:tag].empty?
|
13
|
+
|
14
|
+
params = pathlist("ResourceId", options[:resource_id] )
|
15
|
+
params.merge!(pathkvlist('Tag', options[:tag], 'Key', 'Value', {}))
|
16
|
+
return response_generator(:action => "CreateTags", :params => params)
|
17
|
+
end
|
18
|
+
|
19
|
+
# The DescribeTags operation lists the tags, If you do not specify any filters, all tags will be returned.
|
20
|
+
#
|
21
|
+
# @option options [optional, Array] :filter ([]) An array of Hashes representing the filters. Note that the values in the hashes have to be arrays. E.g. [{:key => ['name']}, {:resource_type => ['instance']},...]
|
22
|
+
#
|
23
|
+
def describe_tags( options = {} )
|
24
|
+
params = {}
|
25
|
+
if options[:filter]
|
26
|
+
params.merge!(pathkvlist('Filter', options[:filter], 'Name', 'Value', {:resource_id => 'resource-id', :resource_type => 'resource-type' }))
|
27
|
+
end
|
28
|
+
return response_generator(:action => "DescribeTags", :params => params)
|
29
|
+
end
|
30
|
+
|
31
|
+
# The DeleteTags operation deletes tags for the specified resource(s).
|
32
|
+
#
|
33
|
+
# @option options [Array] :resource_id ([]) The ids of the resource(s) to tag
|
34
|
+
# @option options [Array] :tag ([]) An array of Hashes representing the tags { tag_name => tag_value }. If a value is given (instead of nil/empty string), then the tag is only deleted if it has this value
|
35
|
+
#
|
36
|
+
def delete_tags( options = {} )
|
37
|
+
raise ArgumentError, "No :resource_id provided" if options[:resource_id].nil? || options[:resource_id].empty?
|
38
|
+
raise ArgumentError, "No :tag provided" if options[:tag].nil? || options[:tag].empty?
|
39
|
+
|
40
|
+
params = pathlist("ResourceId", options[:resource_id] )
|
41
|
+
params.merge!(pathkvlist('Tag', options[:tag], 'Key', 'Value', {}))
|
42
|
+
return response_generator(:action => "DeleteTags", :params => params)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/lib/AWS/EC2/volumes.rb
CHANGED
@@ -88,7 +88,7 @@ module AWS
|
|
88
88
|
"VolumeId" => options[:volume_id],
|
89
89
|
"InstanceId" => options[:instance_id],
|
90
90
|
"Device" => options[:device],
|
91
|
-
"Force" => options[:force]
|
91
|
+
"Force" => options[:force].to_s
|
92
92
|
}
|
93
93
|
return response_generator(:action => "DetachVolume", :params => params)
|
94
94
|
end
|
data/lib/AWS/ELB.rb
CHANGED
@@ -8,8 +8,6 @@ module AWS
|
|
8
8
|
# export ELB_URL='https://elasticloadbalancing.amazonaws.com'
|
9
9
|
if ENV['ELB_URL']
|
10
10
|
ELB_URL = ENV['ELB_URL']
|
11
|
-
VALID_HOSTS = ['elasticloadbalancing.amazonaws.com']
|
12
|
-
raise ArgumentError, "Invalid ELB_URL environment variable : #{ELB_URL}" unless VALID_HOSTS.include?(ELB_URL)
|
13
11
|
DEFAULT_HOST = URI.parse(ELB_URL).host
|
14
12
|
else
|
15
13
|
# Default US API endpoint
|
data/lib/AWS/RDS.rb
CHANGED
@@ -8,8 +8,6 @@ module AWS
|
|
8
8
|
# export RDS_URL='https://rds.amazonaws.com'
|
9
9
|
if ENV['RDS_URL']
|
10
10
|
RDS_URL = ENV['RDS_URL']
|
11
|
-
VALID_HOSTS = ['rds.amazonaws.com']
|
12
|
-
raise ArgumentError, "Invalid RDS_URL environment variable : #{RDS_URL}" unless VALID_HOSTS.include?(RDS_URL)
|
13
11
|
DEFAULT_HOST = URI.parse(RDS_URL).host
|
14
12
|
else
|
15
13
|
# Default US API endpoint
|
data/lib/AWS/RDS/rds.rb
CHANGED
@@ -14,7 +14,7 @@ module AWS
|
|
14
14
|
# @option options [String] :port is the port the database accepts connections on (3306)
|
15
15
|
# @option options [String] :db_name contains the name of the database to create when created (nil)
|
16
16
|
# @option options [String] :db_parameter_group is the database parameter group to associate with this instance (nil)
|
17
|
-
# @option options [
|
17
|
+
# @option options [Array] :db_security_groups are the list of db security groups to associate with the instance (nil)
|
18
18
|
# @option options [String] :availability_zone is the availability_zone to create the instance in (nil)
|
19
19
|
# @option options [String] :preferred_maintenance_window in format: ddd:hh24:mi-ddd:hh24:mi (nil)
|
20
20
|
# @option options [String] :backup_retention_period is the number of days which automated backups are retained (1)
|
@@ -43,7 +43,7 @@ module AWS
|
|
43
43
|
params["Port"] = options[:port].to_s if options.has?(:port)
|
44
44
|
params["DBName"] = options[:db_name] if options.has?(:db_name)
|
45
45
|
params["DBParameterGroup"] = options[:db_parameter_group] if options.has?(:db_parameter_group)
|
46
|
-
params
|
46
|
+
params.merge!(pathlist("DBSecurityGroups.member", [options[:db_security_groups]].flatten)) if options.has_key?(:db_security_groups)
|
47
47
|
params["AvailabilityZone"] = options[:availability_zone] if options.has?(:availability_zone)
|
48
48
|
params["PreferredMaintenanceWindow"] = options[:preferred_maintenance_window] if options.has?(:preferred_maintenance_window)
|
49
49
|
params["BackupRetentionPeriod"] = options[:backup_retention_period].to_s if options.has?(:backup_retention_period)
|
@@ -344,7 +344,7 @@ module AWS
|
|
344
344
|
# @option options [String] :port is the port the database accepts connections on (3306)
|
345
345
|
# @option options [String] :db_name contains the name of the database to create when created (nil)
|
346
346
|
# @option options [String] :db_parameter_group_name is the database parameter group to associate with this instance (nil)
|
347
|
-
# @option options [
|
347
|
+
# @option options [Array] :db_security_groups are the list of db security groups to associate with the instance (nil)
|
348
348
|
# @option options [String] :availability_zone is the availability_zone to create the instance in (nil)
|
349
349
|
# @option options [String] :preferred_maintenance_window in format: ddd:hh24:mi-ddd:hh24:mi (nil)
|
350
350
|
# @option options [String] :backup_retention_period is the number of days which automated backups are retained (1)
|
@@ -367,7 +367,7 @@ module AWS
|
|
367
367
|
params["Port"] = options[:port].to_s if options.has?(:port)
|
368
368
|
params["DBName"] = options[:db_name] if options.has?(:db_name)
|
369
369
|
params["DBParameterGroupName"] = options[:db_parameter_group_name] if options.has?(:db_parameter_group_name)
|
370
|
-
params
|
370
|
+
params.merge!(pathlist("DBSecurityGroups.member", [options[:db_security_groups]].flatten)) if options.has_key?(:db_security_groups)
|
371
371
|
params["AvailabilityZone"] = options[:availability_zone] if options.has?(:availability_zone)
|
372
372
|
params["PreferredMaintenanceWindow"] = options[:preferred_maintenance_window] if options.has?(:preferred_maintenance_window)
|
373
373
|
params["BackupRetentionPeriod"] = options[:backup_retention_period].to_s if options.has?(:backup_retention_period)
|
@@ -471,7 +471,7 @@ module AWS
|
|
471
471
|
# @option options [optional, Boolean] :use_latest_restorable_time specifies that the db be restored to the latest restored time. Conditional, cannot be specified if :restore_time parameter is provided.
|
472
472
|
# @option options [optional, Date] :restore_time specifies the date and time to restore from. Conditional, cannot be specified if :use_latest_restorable_time parameter is true.
|
473
473
|
# @option options [String] :target_db_instance_identifier is the name of the new database instance to be created.
|
474
|
-
# @option options [optional, String] :db_instance_class specifies the class of the compute and memory of the EC2 instance, Options : db.m1.small | db.m1.large | db.m1.xlarge | db.m2.2xlarge | db.m2.4xlarge
|
474
|
+
# @option options [optional, String] :db_instance_class specifies the class of the compute and memory of the EC2 instance, Options : db.m1.small | db.m1.large | db.m1.xlarge | db.m2.2xlarge | db.m2.4xlarge | db.cc1.4xlarge
|
475
475
|
# @option options [optional, Integer] :port is the port which the db can accept connections on. Constraints: Value must be 1115-65535
|
476
476
|
# @option options [optional, String] :availability_zone is the EC2 zone which the db instance will be created
|
477
477
|
#
|
data/lib/AWS/version.rb
ADDED
data/test/test_EC2.rb
CHANGED
@@ -61,8 +61,8 @@ context "The EC2 method " do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
specify "AWS.encode should return the expected string" do
|
64
|
-
AWS.encode("secretaccesskey", "foobar123", urlencode=true).should.equal "
|
65
|
-
AWS.encode("secretaccesskey", "foobar123", urlencode=false).should.equal "
|
64
|
+
AWS.encode("secretaccesskey", "foobar123", urlencode=true).should.equal "CPzGGhtvlG3P3yp88fPZp0HKouUV8mQK1ZcdFGQeAug%3D"
|
65
|
+
AWS.encode("secretaccesskey", "foobar123", urlencode=false).should.equal "CPzGGhtvlG3P3yp88fPZp0HKouUV8mQK1ZcdFGQeAug="
|
66
66
|
end
|
67
67
|
|
68
68
|
end
|
data/test/test_EC2_instances.rb
CHANGED
@@ -217,6 +217,27 @@ context "EC2 instances " do
|
|
217
217
|
</UnmonitorInstancesResponse>
|
218
218
|
|
219
219
|
RESPONSE
|
220
|
+
|
221
|
+
@describe_instance_attribute_response_body = <<-RESPONSE
|
222
|
+
<DescribeInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/">
|
223
|
+
<instanceId>i-10a64379</instanceId>
|
224
|
+
<kernel>
|
225
|
+
<value>aki-f70657b2</value>
|
226
|
+
</kernel>
|
227
|
+
</DescribeInstanceAttributeResponse>
|
228
|
+
RESPONSE
|
229
|
+
|
230
|
+
@modify_instance_attribute_response_body = <<-RESPONSE
|
231
|
+
<ModifyInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/">
|
232
|
+
<return>true</return>
|
233
|
+
</ModifyInstanceAttributeResponse>
|
234
|
+
RESPONSE
|
235
|
+
|
236
|
+
@reset_instance_attribute_response_body = <<-RESPONSE
|
237
|
+
<ResetInstanceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/">
|
238
|
+
<return>true</return>
|
239
|
+
</ResetInstanceAttributeResponse>
|
240
|
+
RESPONSE
|
220
241
|
end
|
221
242
|
|
222
243
|
|
@@ -304,9 +325,13 @@ context "EC2 instances " do
|
|
304
325
|
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 2, :max_count => 1 ) }.should.raise(AWS::ArgumentError)
|
305
326
|
|
306
327
|
# :instance_type
|
307
|
-
|
308
|
-
|
309
|
-
|
328
|
+
|
329
|
+
["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].each do |type|
|
330
|
+
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "InstanceType" => type).
|
331
|
+
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
332
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_type => type ) }.should.not.raise(AWS::ArgumentError)
|
333
|
+
end
|
334
|
+
|
310
335
|
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :instance_type => "m1.notarealsize" ) }.should.raise(AWS::ArgumentError)
|
311
336
|
|
312
337
|
# :monitoring_enabled
|
@@ -608,4 +633,72 @@ context "EC2 instances " do
|
|
608
633
|
@response.instancesSet.item[1].monitoring.state.should.equal "disabling"
|
609
634
|
end
|
610
635
|
|
636
|
+
specify "should get an ArgumentError when trying to describe/modify/reset an instance attribute without an istance id" do
|
637
|
+
lambda { @ec2.describe_instance_attribute(:attribute => "ramdisk") }.should.raise(AWS::ArgumentError)
|
638
|
+
lambda { @ec2.modify_instance_attribute(:attribute => "ramdisk") }.should.raise(AWS::ArgumentError)
|
639
|
+
lambda { @ec2.reset_instance_attribute(:attribute => "ramdisk") }.should.raise(AWS::ArgumentError)
|
640
|
+
|
641
|
+
lambda { @ec2.describe_instance_attribute(:attribute => "ramdisk", :instance_id => nil) }.should.raise(AWS::ArgumentError)
|
642
|
+
lambda { @ec2.modify_instance_attribute(:attribute => "ramdisk", :instance_id => nil) }.should.raise(AWS::ArgumentError)
|
643
|
+
lambda { @ec2.reset_instance_attribute(:attribute => "ramdisk", :instance_id => nil) }.should.raise(AWS::ArgumentError)
|
644
|
+
|
645
|
+
lambda { @ec2.describe_instance_attribute(:attribute => "ramdisk", :instance_id => "") }.should.raise(AWS::ArgumentError)
|
646
|
+
lambda { @ec2.modify_instance_attribute(:attribute => "ramdisk", :instance_id => "") }.should.raise(AWS::ArgumentError)
|
647
|
+
lambda { @ec2.reset_instance_attribute(:attribute => "ramdisk", :instance_id => "") }.should.raise(AWS::ArgumentError)
|
648
|
+
end
|
649
|
+
|
650
|
+
specify "should get an ArgumentError when trying to describe/modify/reset an instance attribute without an attribute" do
|
651
|
+
lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a") }.should.raise(AWS::ArgumentError)
|
652
|
+
lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a") }.should.raise(AWS::ArgumentError)
|
653
|
+
lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a") }.should.raise(AWS::ArgumentError)
|
654
|
+
|
655
|
+
lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => nil) }.should.raise(AWS::ArgumentError)
|
656
|
+
lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => nil) }.should.raise(AWS::ArgumentError)
|
657
|
+
lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => nil) }.should.raise(AWS::ArgumentError)
|
658
|
+
|
659
|
+
lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => "") }.should.raise(AWS::ArgumentError)
|
660
|
+
lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => "") }.should.raise(AWS::ArgumentError)
|
661
|
+
lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => "") }.should.raise(AWS::ArgumentError)
|
662
|
+
end
|
663
|
+
|
664
|
+
specify "should get an ArgumentError when trying to describe/modify/reset an instance attribute without a valid attribute" do
|
665
|
+
lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError)
|
666
|
+
lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError)
|
667
|
+
lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError)
|
668
|
+
end
|
669
|
+
|
670
|
+
specify "should not get an ArgumentError when trying to describe/modify/reset an instance attribute with a valid attribute" do
|
671
|
+
@ec2.stubs(:make_request).returns stub(:body => @describe_instance_attribute_response_body, :is_a? => true)
|
672
|
+
%w(instanceType kernel ramdisk userData disableApiTermination instanceInitiatedShutdownBehavior rootDevice blockDeviceMapping).each do |a|
|
673
|
+
lambda { @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => a) }.should.not.raise(AWS::ArgumentError)
|
674
|
+
lambda { @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError)
|
675
|
+
end
|
676
|
+
%w(kernel ramdisk).each do |a|
|
677
|
+
lambda { @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'party') }.should.raise(AWS::ArgumentError)
|
678
|
+
end
|
679
|
+
end
|
680
|
+
|
681
|
+
specify "should successfully describe instance attribute" do
|
682
|
+
@ec2.stubs(:make_request).with('DescribeInstanceAttribute', {"InstanceId"=>"i-33457a5a", "Attribute" => "kernel"}).
|
683
|
+
returns stub(:body => @describe_instance_attribute_response_body, :is_a? => true)
|
684
|
+
@response = @ec2.describe_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'kernel')
|
685
|
+
@response.class.should.equal Hash
|
686
|
+
@response.kernel.value.should.equal "aki-f70657b2"
|
687
|
+
end
|
688
|
+
|
689
|
+
specify "should successfully modify instance attribute" do
|
690
|
+
@ec2.stubs(:make_request).with('ModifyInstanceAttribute', {"InstanceId"=>"i-33457a5a", "Attribute" => "disableApiTermination", "Value" => "true"}).
|
691
|
+
returns stub(:body => @modify_instance_attribute_response_body, :is_a? => true)
|
692
|
+
@response = @ec2.modify_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'disableApiTermination', :value => true)
|
693
|
+
@response.class.should.equal Hash
|
694
|
+
@response.return.should.equal "true"
|
695
|
+
end
|
696
|
+
|
697
|
+
specify "should successfully reset instance attribute" do
|
698
|
+
@ec2.stubs(:make_request).with('ResetInstanceAttribute', {"InstanceId"=>"i-33457a5a", "Attribute" => "kernel"}).
|
699
|
+
returns stub(:body => @reset_instance_attribute_response_body, :is_a? => true)
|
700
|
+
@response = @ec2.reset_instance_attribute(:instance_id => "i-33457a5a", :attribute => 'kernel')
|
701
|
+
@response.class.should.equal Hash
|
702
|
+
@response.return.should.equal "true"
|
703
|
+
end
|
611
704
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
|
+
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "The EC2 password " do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@get_password_data_response_body = <<-RESPONSE
|
19
|
+
<GetPasswordDataResponse xmlns="http://ec2.amazonaws.com/doc/2010-06-15/">
|
20
|
+
<instanceId>i-2574e22a</instanceId>
|
21
|
+
<timestamp>2009-10-24 15:00:00</timestamp>
|
22
|
+
<passwordData>TGludXggdmVyc2lvbiAyLjYuMTYteGVuVSAoYnVpbGRlckBwYXRjaGJhdC5hbWF6b25zYSkgKGdj</passwordData></GetPasswordDataResponse>
|
23
|
+
RESPONSE
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
specify "should return an encrypted password encoded by base64 " do
|
29
|
+
@ec2.stubs(:make_request).with('GetPasswordData', {"InstanceId"=>"i-2574e22a"}).
|
30
|
+
returns stub(:body => @get_password_data_response_body, :is_a? => true)
|
31
|
+
@ec2.get_password_data( :instance_id => "i-2574e22a" ).should.be.an.instance_of Hash
|
32
|
+
response = @ec2.get_password_data( :instance_id => "i-2574e22a" )
|
33
|
+
response.instanceId.should.equal "i-2574e22a"
|
34
|
+
response.timestamp.should.equal "2009-10-24 15:00:00"
|
35
|
+
response.passwordData.should.equal "TGludXggdmVyc2lvbiAyLjYuMTYteGVuVSAoYnVpbGRlckBwYXRjaGJhdC5hbWF6b25zYSkgKGdj"
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
specify "method get_password_data should raise an exception when called without nil/empty string arguments" do
|
40
|
+
lambda { @ec2.get_password_data() }.should.raise(AWS::ArgumentError)
|
41
|
+
lambda { @ec2.get_password_data(:instance_id => nil) }.should.raise(AWS::ArgumentError)
|
42
|
+
lambda { @ec2.get_password_data(:instance_id => "") }.should.raise(AWS::ArgumentError)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
end
|
@@ -107,6 +107,17 @@ context "An EC2 spot instances request " do
|
|
107
107
|
|
108
108
|
end
|
109
109
|
|
110
|
+
specify "should be able to be requested with various instance sizes" do
|
111
|
+
["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].each do |type|
|
112
|
+
@ec2.stubs(:make_request).with('RequestSpotInstances', {"SpotPrice"=>"0.50", 'LaunchSpecification.InstanceType' => type, 'LaunchSpecification.ImageId' => 'ami-60a54009', "InstanceCount"=>"1"}).
|
113
|
+
returns stub(:body => @create_spot_instances_request_response_body, :is_a? => true)
|
114
|
+
lambda { @ec2.request_spot_instances( :image_id => "ami-60a54009", :instance_type => type, :spot_price => '0.50' ) }.should.not.raise(AWS::ArgumentError)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
specify "should raise an exception with a bad instance type" do
|
119
|
+
lambda { @ec2.request_spot_instances({"SpotPrice"=>"0.50", 'LaunchSpecification.InstanceType' => 'm1.notarealsize', "InstanceCount"=>"1"}) }.should.raise(AWS::ArgumentError)
|
120
|
+
end
|
110
121
|
|
111
122
|
specify "should be able to be created" do
|
112
123
|
@ec2.stubs(:make_request).with('RequestSpotInstances', {"SpotPrice"=>"0.50", 'LaunchSpecification.InstanceType' => 'm1.small', "InstanceCount"=>"1"}).
|
@@ -39,13 +39,21 @@ context "Spot price history " do
|
|
39
39
|
specify "should reject an end_time which is not a Time object" do
|
40
40
|
lambda { @ec2.describe_spot_price_history(:end_time => 42) }.should.raise(AWS::ArgumentError)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
|
+
specify "should be able to be requested with various instance types" do
|
44
|
+
["t1.micro", "m1.small", "m1.large", "m1.xlarge", "m2.xlarge", "c1.medium", "c1.xlarge", "m2.2xlarge", "m2.4xlarge", "cc1.4xlarge"].each do |type|
|
45
|
+
@ec2.stubs(:make_request).with('DescribeSpotPriceHistory', {'InstanceType' => type}).
|
46
|
+
returns stub(:body => @describe_spot_price_history_response_body, :is_a? => true)
|
47
|
+
lambda { @ec2.describe_spot_price_history( :instance_type => type ) }.should.not.raise(AWS::ArgumentError)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
43
51
|
specify "should reject an invalid instance type" do
|
44
52
|
lambda { @ec2.describe_spot_price_history(:instance_type => 'm1.tiny') }.should.raise(AWS::ArgumentError)
|
45
53
|
end
|
46
|
-
|
54
|
+
|
47
55
|
specify "should reject an invalid product description" do
|
48
56
|
lambda { @ec2.describe_spot_price_history(:product_description => 'Solaris') }.should.raise(AWS::ArgumentError)
|
49
57
|
end
|
50
|
-
|
58
|
+
|
51
59
|
end
|
data/test/test_EC2_volumes.rb
CHANGED
@@ -139,4 +139,20 @@ context "EC2 volumes " do
|
|
139
139
|
response.status.should.equal "detaching"
|
140
140
|
end
|
141
141
|
|
142
|
+
specify "should be able to be force detached with a string" do
|
143
|
+
@ec2.stubs(:make_request).with('DetachVolume', {"VolumeId" => "vol-4d826724", "InstanceId"=>"i-6058a509", "Device"=>"", "Force"=>"true"}).
|
144
|
+
returns stub(:body => @detach_volume_response_body, :is_a? => true)
|
145
|
+
|
146
|
+
response = @ec2.detach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509", :force => 'true' )
|
147
|
+
response.volumeId.should.equal "vol-4d826724"
|
148
|
+
end
|
149
|
+
|
150
|
+
specify "should be able to be force detached with a Boolean" do
|
151
|
+
@ec2.stubs(:make_request).with('DetachVolume', {"VolumeId" => "vol-4d826724", "InstanceId"=>"i-6058a509", "Device"=>"", "Force"=>"true"}).
|
152
|
+
returns stub(:body => @detach_volume_response_body, :is_a? => true)
|
153
|
+
|
154
|
+
response = @ec2.detach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509", :force => true )
|
155
|
+
response.volumeId.should.equal "vol-4d826724"
|
156
|
+
end
|
157
|
+
|
142
158
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 0.9.
|
9
|
+
- 17
|
10
|
+
version: 0.9.17
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Glenn Rempe
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-21 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -42,12 +42,12 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
45
|
+
hash: 41
|
46
46
|
segments:
|
47
47
|
- 0
|
48
48
|
- 9
|
49
|
-
-
|
50
|
-
version: 0.9.
|
49
|
+
- 9
|
50
|
+
version: 0.9.9
|
51
51
|
type: :development
|
52
52
|
version_requirements: *id002
|
53
53
|
- !ruby/object:Gem::Dependency
|
@@ -74,12 +74,12 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
77
|
+
hash: 41
|
78
78
|
segments:
|
79
79
|
- 0
|
80
80
|
- 9
|
81
|
-
-
|
82
|
-
version: 0.9.
|
81
|
+
- 9
|
82
|
+
version: 0.9.9
|
83
83
|
type: :development
|
84
84
|
version_requirements: *id004
|
85
85
|
- !ruby/object:Gem::Dependency
|
@@ -90,17 +90,35 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
hash:
|
93
|
+
hash: 3
|
94
94
|
segments:
|
95
95
|
- 0
|
96
|
-
-
|
97
|
-
-
|
98
|
-
version: 0.
|
96
|
+
- 5
|
97
|
+
- 4
|
98
|
+
version: 0.5.4
|
99
99
|
type: :development
|
100
100
|
version_requirements: *id005
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: yard
|
103
|
+
prerelease: false
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
hash: 3
|
110
|
+
segments:
|
111
|
+
- 0
|
112
|
+
- 6
|
113
|
+
- 2
|
114
|
+
version: 0.6.2
|
115
|
+
type: :development
|
116
|
+
version_requirements: *id006
|
101
117
|
description: A Ruby library for accessing the Amazon Web Services EC2, ELB, RDS, Cloudwatch, and Autoscaling APIs.
|
102
|
-
email:
|
118
|
+
email:
|
119
|
+
- glenn@rempe.us
|
103
120
|
executables:
|
121
|
+
- awshell
|
104
122
|
- ec2-gem-example.rb
|
105
123
|
- ec2-gem-profile.rb
|
106
124
|
- ec2sh
|
@@ -111,17 +129,18 @@ extra_rdoc_files:
|
|
111
129
|
- ChangeLog
|
112
130
|
- LICENSE
|
113
131
|
- README.rdoc
|
114
|
-
- README_dev.rdoc
|
115
132
|
files:
|
116
133
|
- .gitignore
|
117
134
|
- .yardopts
|
118
135
|
- ChangeLog
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
119
138
|
- LICENSE
|
120
139
|
- README.rdoc
|
121
|
-
- README_dev.rdoc
|
122
140
|
- Rakefile
|
123
141
|
- VERSION
|
124
142
|
- amazon-ec2.gemspec
|
143
|
+
- bin/awshell
|
125
144
|
- bin/ec2-gem-example.rb
|
126
145
|
- bin/ec2-gem-profile.rb
|
127
146
|
- bin/ec2sh
|
@@ -141,12 +160,14 @@ files:
|
|
141
160
|
- lib/AWS/EC2/images.rb
|
142
161
|
- lib/AWS/EC2/instances.rb
|
143
162
|
- lib/AWS/EC2/keypairs.rb
|
163
|
+
- lib/AWS/EC2/password.rb
|
144
164
|
- lib/AWS/EC2/products.rb
|
145
165
|
- lib/AWS/EC2/security_groups.rb
|
146
166
|
- lib/AWS/EC2/snapshots.rb
|
147
167
|
- lib/AWS/EC2/spot_instance_requests.rb
|
148
168
|
- lib/AWS/EC2/spot_prices.rb
|
149
169
|
- lib/AWS/EC2/subnets.rb
|
170
|
+
- lib/AWS/EC2/tags.rb
|
150
171
|
- lib/AWS/EC2/volumes.rb
|
151
172
|
- lib/AWS/ELB.rb
|
152
173
|
- lib/AWS/ELB/load_balancers.rb
|
@@ -154,10 +175,7 @@ files:
|
|
154
175
|
- lib/AWS/RDS/rds.rb
|
155
176
|
- lib/AWS/exceptions.rb
|
156
177
|
- lib/AWS/responses.rb
|
157
|
-
-
|
158
|
-
- perftools/ec2prof-results.dot
|
159
|
-
- perftools/ec2prof-results.txt
|
160
|
-
- perftools/ec2prof.symbols
|
178
|
+
- lib/AWS/version.rb
|
161
179
|
- test/test_Autoscaling_groups.rb
|
162
180
|
- test/test_EC2.rb
|
163
181
|
- test/test_EC2_availability_zones.rb
|
@@ -167,6 +185,7 @@ files:
|
|
167
185
|
- test/test_EC2_images.rb
|
168
186
|
- test/test_EC2_instances.rb
|
169
187
|
- test/test_EC2_keypairs.rb
|
188
|
+
- test/test_EC2_password.rb
|
170
189
|
- test/test_EC2_products.rb
|
171
190
|
- test/test_EC2_responses.rb
|
172
191
|
- test/test_EC2_s3_xmlsimple.rb
|
@@ -222,7 +241,7 @@ rubyforge_project: amazon-ec2
|
|
222
241
|
rubygems_version: 1.3.7
|
223
242
|
signing_key:
|
224
243
|
specification_version: 3
|
225
|
-
summary: Amazon EC2 Ruby
|
244
|
+
summary: Amazon EC2 Ruby gem
|
226
245
|
test_files:
|
227
246
|
- test/test_Autoscaling_groups.rb
|
228
247
|
- test/test_EC2.rb
|
@@ -233,6 +252,7 @@ test_files:
|
|
233
252
|
- test/test_EC2_images.rb
|
234
253
|
- test/test_EC2_instances.rb
|
235
254
|
- test/test_EC2_keypairs.rb
|
255
|
+
- test/test_EC2_password.rb
|
236
256
|
- test/test_EC2_products.rb
|
237
257
|
- test/test_EC2_responses.rb
|
238
258
|
- test/test_EC2_s3_xmlsimple.rb
|
@@ -243,5 +263,5 @@ test_files:
|
|
243
263
|
- test/test_EC2_subnets.rb
|
244
264
|
- test/test_EC2_volumes.rb
|
245
265
|
- test/test_ELB_load_balancers.rb
|
246
|
-
- test/test_helper.rb
|
247
266
|
- test/test_RDS.rb
|
267
|
+
- test/test_helper.rb
|