amazon-ec2 0.2.15 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +86 -73
- data/README.rdoc +21 -18
- data/Rakefile +0 -1
- data/bin/ec2-gem-example.rb +12 -12
- data/bin/ec2sh +2 -2
- data/bin/setup.rb +5 -5
- data/lib/EC2.rb +3 -3
- data/lib/EC2/availability_zones.rb +4 -5
- data/lib/EC2/console.rb +3 -3
- data/lib/EC2/elastic_ips.rb +2 -2
- data/lib/EC2/exceptions.rb +2 -2
- data/lib/EC2/image_attributes.rb +2 -2
- data/lib/EC2/images.rb +2 -2
- data/lib/EC2/instances.rb +5 -2
- data/lib/EC2/keypairs.rb +2 -2
- data/lib/EC2/products.rb +3 -3
- data/lib/EC2/responses.rb +20 -131
- data/lib/EC2/security_groups.rb +2 -2
- data/lib/EC2/snapshots.rb +94 -0
- data/lib/EC2/volumes.rb +170 -0
- data/test/test_EC2.rb +2 -2
- data/test/test_EC2_availability_zones.rb +4 -4
- data/test/test_EC2_console.rb +4 -4
- data/test/test_EC2_elastic_ips.rb +7 -7
- data/test/test_EC2_image_attributes.rb +12 -12
- data/test/test_EC2_images.rb +6 -6
- data/test/test_EC2_instances.rb +17 -12
- data/test/test_EC2_keypairs.rb +5 -5
- data/test/test_EC2_products.rb +3 -3
- data/test/test_EC2_responses.rb +15 -65
- data/test/test_EC2_security_groups.rb +7 -7
- data/test/test_EC2_snapshots.rb +83 -0
- data/test/test_EC2_volumes.rb +142 -0
- data/test/test_helper.rb +3 -4
- metadata +10 -33
data/lib/EC2/volumes.rb
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library, EBS volumes support
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Yann Klis (mailto:yann.klis@novelys.com)
|
6
|
+
# Copyright:: Copyright (c) 2008 Yann Klis
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
|
+
#++
|
10
|
+
|
11
|
+
module EC2
|
12
|
+
|
13
|
+
class Base
|
14
|
+
|
15
|
+
#Amazon Developer Guide Docs:
|
16
|
+
#
|
17
|
+
# The DescribeVolumes operation lists one or more Amazon EBS volumes that you own, If you do not specify any volumes, Amazon EBS returns all volumes that you own.
|
18
|
+
#
|
19
|
+
#Required Arguments:
|
20
|
+
#
|
21
|
+
# none
|
22
|
+
#
|
23
|
+
#Optional Arguments:
|
24
|
+
#
|
25
|
+
# :volume_id => Array (default : [])
|
26
|
+
#
|
27
|
+
|
28
|
+
def describe_volumes( options = {} )
|
29
|
+
|
30
|
+
options = { :volume_id => [] }.merge(options)
|
31
|
+
|
32
|
+
params = pathlist("VolumeId", options[:volume_id] )
|
33
|
+
|
34
|
+
return response_generator(:action => "DescribeVolumes", :params => params)
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
#Amazon Developer Guide Docs:
|
39
|
+
#
|
40
|
+
# The CreateVolume operation creates a new Amazon EBS volume that you can mount from any Amazon EC2 instance.
|
41
|
+
#
|
42
|
+
#Required Arguments:
|
43
|
+
#
|
44
|
+
# :availability_zone => String (default : '')
|
45
|
+
#
|
46
|
+
#Optional Arguments:
|
47
|
+
#
|
48
|
+
# :size => String (default : '')
|
49
|
+
# :snapshot_id => String (default : '')
|
50
|
+
#
|
51
|
+
|
52
|
+
def create_volume( options = {} )
|
53
|
+
|
54
|
+
# defaults
|
55
|
+
options = { :availability_zone => '' }.merge(options)
|
56
|
+
|
57
|
+
raise ArgumentError, "No :availability_zone provided" if options[:availability_zone].nil? || options[:availability_zone].empty?
|
58
|
+
|
59
|
+
options = { :size => '' }.merge(options)
|
60
|
+
options = { :snapshot_id => '' }.merge(options)
|
61
|
+
|
62
|
+
params = {
|
63
|
+
"AvailabilityZone" => options[:availability_zone],
|
64
|
+
"Size" => options[:size],
|
65
|
+
"SnapshotId" => options[:snapshot_id]
|
66
|
+
}
|
67
|
+
|
68
|
+
return response_generator(:action => "CreateVolume", :params => params)
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
#Amazon Developer Guide Docs:
|
73
|
+
#
|
74
|
+
# The DeleteVolume operation deletes an Amazon EBS volume.
|
75
|
+
#
|
76
|
+
#Required Arguments:
|
77
|
+
#
|
78
|
+
# :volume_id => String (default : '')
|
79
|
+
#
|
80
|
+
#Optional Arguments:
|
81
|
+
#
|
82
|
+
# none
|
83
|
+
#
|
84
|
+
|
85
|
+
def delete_volume( options = {} )
|
86
|
+
|
87
|
+
options = { :volume_id => '' }.merge(options)
|
88
|
+
|
89
|
+
raise ArgumentError, "No :volume_id provided" if options[:volume_id].nil? || options[:volume_id].empty?
|
90
|
+
|
91
|
+
params = {
|
92
|
+
"VolumeId" => options[:volume_id]
|
93
|
+
}
|
94
|
+
|
95
|
+
return response_generator(:action => "DeleteVolume", :params => params)
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
#Amazon Developer Guide Docs:
|
100
|
+
#
|
101
|
+
# The AttachVolume operation attaches an Amazon EBS volume to an instance.
|
102
|
+
#
|
103
|
+
#Required Arguments:
|
104
|
+
#
|
105
|
+
# :volume_id => String (default : '')
|
106
|
+
# :instance_id => String (default : '')
|
107
|
+
# :device => String (default : '')
|
108
|
+
#
|
109
|
+
#Optional Arguments:
|
110
|
+
#
|
111
|
+
# none
|
112
|
+
#
|
113
|
+
|
114
|
+
def attach_volume( options = {} )
|
115
|
+
|
116
|
+
options = { :volume_id => '' }.merge(options)
|
117
|
+
options = { :instance_id => '' }.merge(options)
|
118
|
+
options = { :device => '' }.merge(options)
|
119
|
+
|
120
|
+
raise ArgumentError, "No :volume_id provided" if options[:volume_id].nil? || options[:volume_id].empty?
|
121
|
+
raise ArgumentError, "No :instance_id provided" if options[:instance_id].nil? || options[:instance_id].empty?
|
122
|
+
raise ArgumentError, "No :device provided" if options[:device].nil? || options[:device].empty?
|
123
|
+
|
124
|
+
params = {
|
125
|
+
"VolumeId" => options[:volume_id],
|
126
|
+
"InstanceId" => options[:instance_id],
|
127
|
+
"Device" => options[:device]
|
128
|
+
}
|
129
|
+
|
130
|
+
return response_generator(:action => "AttachVolume", :params => params)
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
#Amazon Developer Guide Docs:
|
135
|
+
#
|
136
|
+
# The DetachVolume operation detaches an Amazon EBS volume from an instance.
|
137
|
+
#
|
138
|
+
#Required Arguments:
|
139
|
+
#
|
140
|
+
# :volume_id => String (default : '')
|
141
|
+
#
|
142
|
+
#Optional Arguments:
|
143
|
+
#
|
144
|
+
# :instance_id => String (default : '')
|
145
|
+
# :device => String (default : '')
|
146
|
+
# :force => Boolean (default : '')
|
147
|
+
#
|
148
|
+
|
149
|
+
def detach_volume( options = {} )
|
150
|
+
|
151
|
+
options = { :volume_id => '' }.merge(options)
|
152
|
+
|
153
|
+
raise ArgumentError, "No :volume_id provided" if options[:volume_id].nil? || options[:volume_id].empty?
|
154
|
+
|
155
|
+
options = { :instance_id => '' }.merge(options)
|
156
|
+
options = { :device => '' }.merge(options)
|
157
|
+
options = { :force => '' }.merge(options)
|
158
|
+
|
159
|
+
params = {
|
160
|
+
"VolumeId" => options[:volume_id],
|
161
|
+
"InstanceId" => options[:instance_id],
|
162
|
+
"Device" => options[:device],
|
163
|
+
"Force" => options[:force]
|
164
|
+
}
|
165
|
+
|
166
|
+
return response_generator(:action => "DetachVolume", :params => params)
|
167
|
+
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
data/test/test_EC2.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
# Amazon Web Services EC2 Query API Ruby library
|
3
3
|
#
|
4
4
|
# Ruby Gem Name:: amazon-ec2
|
5
|
-
# Author:: Glenn Rempe (mailto:
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
6
|
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
7
|
# License:: Distributes under the same terms as Ruby
|
8
|
-
# Home:: http://amazon-ec2
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
9
|
#++
|
10
10
|
|
11
11
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
@@ -2,10 +2,10 @@
|
|
2
2
|
# Amazon Web Services EC2 Query API Ruby library
|
3
3
|
#
|
4
4
|
# Ruby Gem Name:: amazon-ec2
|
5
|
-
# Author:: Glenn Rempe (mailto:
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
6
|
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
7
|
# License:: Distributes under the same terms as Ruby
|
8
|
-
# Home:: http://amazon-ec2
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
9
|
#++
|
10
10
|
|
11
11
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
@@ -28,14 +28,14 @@ context "EC2 availability zones" do
|
|
28
28
|
</item>
|
29
29
|
</availabilityZoneInfo>
|
30
30
|
</DescribeAvailabilityZonesResponse>
|
31
|
-
|
31
|
+
RESPONSE
|
32
32
|
|
33
33
|
end
|
34
34
|
|
35
35
|
specify "should be able to be described with describe_availability_zones" do
|
36
36
|
@ec2.stubs(:make_request).with('DescribeAvailabilityZones', { "ZoneName.1" => "us-east-1a", "ZoneName.2" => "us-east-1b" }).
|
37
37
|
returns stub(:body => @describe_availability_zones_response_body, :is_a? => true)
|
38
|
-
@ec2.describe_availability_zones( :zone_name => ["us-east-1a", "us-east-1b"] ).should.be.an.instance_of
|
38
|
+
@ec2.describe_availability_zones( :zone_name => ["us-east-1a", "us-east-1b"] ).should.be.an.instance_of Hash
|
39
39
|
|
40
40
|
response = @ec2.describe_availability_zones( :zone_name => ["us-east-1a", "us-east-1b"] )
|
41
41
|
|
data/test/test_EC2_console.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
# Amazon Web Services EC2 Query API Ruby library
|
3
3
|
#
|
4
4
|
# Ruby Gem Name:: amazon-ec2
|
5
|
-
# Author:: Glenn Rempe (mailto:
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
6
|
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
7
|
# License:: Distributes under the same terms as Ruby
|
8
|
-
# Home:: http://amazon-ec2
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
9
|
#++
|
10
10
|
|
11
11
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
@@ -37,7 +37,7 @@ context "The EC2 console " do
|
|
37
37
|
specify "should return info written to a specific instances console" do
|
38
38
|
@ec2.stubs(:make_request).with('GetConsoleOutput', {"InstanceId"=>"i-2ea64347"}).
|
39
39
|
returns stub(:body => @get_console_output_response_body, :is_a? => true)
|
40
|
-
@ec2.get_console_output( :instance_id => "i-2ea64347" ).should.be.an.instance_of
|
40
|
+
@ec2.get_console_output( :instance_id => "i-2ea64347" ).should.be.an.instance_of Hash
|
41
41
|
response = @ec2.get_console_output( :instance_id => "i-2ea64347" )
|
42
42
|
response.instanceId.should.equal "i-28a64341"
|
43
43
|
response.timestamp.should.equal "2007-01-03 15:00:00"
|
@@ -51,4 +51,4 @@ context "The EC2 console " do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
|
54
|
-
end
|
54
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
# Amazon Web Services EC2 Query API Ruby library
|
3
3
|
#
|
4
4
|
# Ruby Gem Name:: amazon-ec2
|
5
|
-
# Author:: Glenn Rempe (mailto:
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
6
|
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
7
|
# License:: Distributes under the same terms as Ruby
|
8
|
-
# Home:: http://amazon-ec2
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
9
|
#++
|
10
10
|
|
11
11
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
@@ -57,7 +57,7 @@ context "EC2 elastic IP addresses " do
|
|
57
57
|
@ec2.stubs(:make_request).with('AllocateAddress', {}).
|
58
58
|
returns stub(:body => @allocate_address_body, :is_a? => true)
|
59
59
|
|
60
|
-
@ec2.allocate_address.should.be.an.instance_of
|
60
|
+
@ec2.allocate_address.should.be.an.instance_of Hash
|
61
61
|
|
62
62
|
response = @ec2.allocate_address
|
63
63
|
response.publicIp.should.equal "67.202.55.255"
|
@@ -79,7 +79,7 @@ context "EC2 elastic IP addresses " do
|
|
79
79
|
@ec2.stubs(:make_request).with('DescribeAddresses', {"PublicIp.1"=>"67.202.55.255"}).
|
80
80
|
returns stub(:body => @describe_addresses_response_body, :is_a? => true)
|
81
81
|
|
82
|
-
@ec2.describe_addresses( :public_ip => "67.202.55.255" ).should.be.an.instance_of
|
82
|
+
@ec2.describe_addresses( :public_ip => "67.202.55.255" ).should.be.an.instance_of Hash
|
83
83
|
|
84
84
|
response = @ec2.describe_addresses( :public_ip => "67.202.55.255" )
|
85
85
|
response.addressesSet.item[0].instanceId.should.equal "i-28a64341"
|
@@ -91,7 +91,7 @@ context "EC2 elastic IP addresses " do
|
|
91
91
|
@ec2.stubs(:make_request).with('ReleaseAddress', {"PublicIp" => "67.202.55.255"}).
|
92
92
|
returns stub(:body => @release_address_response_body, :is_a? => true)
|
93
93
|
|
94
|
-
@ec2.release_address( :public_ip => "67.202.55.255" ).should.be.an.instance_of
|
94
|
+
@ec2.release_address( :public_ip => "67.202.55.255" ).should.be.an.instance_of Hash
|
95
95
|
|
96
96
|
response = @ec2.release_address( :public_ip => "67.202.55.255" )
|
97
97
|
response.return.should.equal "true"
|
@@ -102,7 +102,7 @@ context "EC2 elastic IP addresses " do
|
|
102
102
|
@ec2.stubs(:make_request).with('AssociateAddress', {"InstanceId" => "i-2ea64347", "PublicIp"=>"67.202.55.255"}).
|
103
103
|
returns stub(:body => @associate_address_response_body, :is_a? => true)
|
104
104
|
|
105
|
-
@ec2.associate_address( :instance_id => "i-2ea64347", :public_ip => "67.202.55.255" ).should.be.an.instance_of
|
105
|
+
@ec2.associate_address( :instance_id => "i-2ea64347", :public_ip => "67.202.55.255" ).should.be.an.instance_of Hash
|
106
106
|
|
107
107
|
response = @ec2.associate_address( :instance_id => "i-2ea64347", :public_ip => "67.202.55.255" )
|
108
108
|
response.return.should.equal "true"
|
@@ -124,7 +124,7 @@ context "EC2 elastic IP addresses " do
|
|
124
124
|
@ec2.stubs(:make_request).with('DisassociateAddress', {'PublicIp' => '67.202.55.255'}).
|
125
125
|
returns stub(:body => @disassociate_address_response_body, :is_a? => true)
|
126
126
|
|
127
|
-
@ec2.disassociate_address( :public_ip => "67.202.55.255" ).should.be.an.instance_of
|
127
|
+
@ec2.disassociate_address( :public_ip => "67.202.55.255" ).should.be.an.instance_of Hash
|
128
128
|
|
129
129
|
response = @ec2.disassociate_address( :public_ip => "67.202.55.255" )
|
130
130
|
response.return.should.equal "true"
|
@@ -2,10 +2,10 @@
|
|
2
2
|
# Amazon Web Services EC2 Query API Ruby library
|
3
3
|
#
|
4
4
|
# Ruby Gem Name:: amazon-ec2
|
5
|
-
# Author:: Glenn Rempe (mailto:
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
6
|
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
7
|
# License:: Distributes under the same terms as Ruby
|
8
|
-
# Home:: http://amazon-ec2
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
9
|
#++
|
10
10
|
|
11
11
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
@@ -62,7 +62,7 @@ context "EC2 image_attributes " do
|
|
62
62
|
"UserId.1"=>"123",
|
63
63
|
"Group.1"=>"all"}).
|
64
64
|
returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
65
|
-
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id=>["123"], :group=>["all"]).should.be.an.instance_of
|
65
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id=>["123"], :group=>["all"]).should.be.an.instance_of Hash
|
66
66
|
end
|
67
67
|
|
68
68
|
|
@@ -72,7 +72,7 @@ context "EC2 image_attributes " do
|
|
72
72
|
"OperationType"=>"add",
|
73
73
|
"Group.1"=>"all"}).
|
74
74
|
returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
75
|
-
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]).should.be.an.instance_of
|
75
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]).should.be.an.instance_of Hash
|
76
76
|
end
|
77
77
|
|
78
78
|
|
@@ -82,7 +82,7 @@ context "EC2 image_attributes " do
|
|
82
82
|
"OperationType"=>"remove",
|
83
83
|
"Group.1"=>"all"}).
|
84
84
|
returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
85
|
-
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"remove", :group=>["all"]).should.be.an.instance_of
|
85
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"remove", :group=>["all"]).should.be.an.instance_of Hash
|
86
86
|
end
|
87
87
|
|
88
88
|
|
@@ -95,7 +95,7 @@ context "EC2 image_attributes " do
|
|
95
95
|
@ec2.modify_image_attribute(:image_id=>"ami-61a54008",
|
96
96
|
:attribute=>"launchPermission",
|
97
97
|
:operation_type=>"add",
|
98
|
-
:user_id=>["123"]).should.be.an.instance_of
|
98
|
+
:user_id=>["123"]).should.be.an.instance_of Hash
|
99
99
|
end
|
100
100
|
|
101
101
|
|
@@ -107,7 +107,7 @@ context "EC2 image_attributes " do
|
|
107
107
|
|
108
108
|
@ec2.modify_image_attribute(:image_id=>"ami-61a54008",
|
109
109
|
:attribute=>"productCodes",
|
110
|
-
:product_code=>["774F4FF8"]).should.be.an.instance_of
|
110
|
+
:product_code=>["774F4FF8"]).should.be.an.instance_of Hash
|
111
111
|
end
|
112
112
|
|
113
113
|
|
@@ -124,7 +124,7 @@ context "EC2 image_attributes " do
|
|
124
124
|
:attribute=>"launchPermission",
|
125
125
|
:operation_type=>"add",
|
126
126
|
:user_id=>["123", "345"],
|
127
|
-
:group=>["123", "all"]).should.be.an.instance_of
|
127
|
+
:group=>["123", "all"]).should.be.an.instance_of Hash
|
128
128
|
end
|
129
129
|
|
130
130
|
|
@@ -166,7 +166,7 @@ context "EC2 image_attributes " do
|
|
166
166
|
returns stub(:body => @describe_image_attribute_response_body_launch_permissions, :is_a? => true)
|
167
167
|
|
168
168
|
@ec2.describe_image_attribute(:image_id => "ami-61a54008", :attribute => "launchPermission").
|
169
|
-
should.be.an.instance_of
|
169
|
+
should.be.an.instance_of Hash
|
170
170
|
|
171
171
|
response = @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission")
|
172
172
|
response.imageId.should.equal "ami-61a54008"
|
@@ -181,7 +181,7 @@ context "EC2 image_attributes " do
|
|
181
181
|
returns stub(:body => @describe_image_attribute_response_body_product_codes, :is_a? => true)
|
182
182
|
|
183
183
|
@ec2.describe_image_attribute(:image_id => "ami-61a54008", :attribute => "productCodes").
|
184
|
-
should.be.an.instance_of
|
184
|
+
should.be.an.instance_of Hash
|
185
185
|
|
186
186
|
response = @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"productCodes")
|
187
187
|
response.imageId.should.equal "ami-61a54008"
|
@@ -214,7 +214,7 @@ context "EC2 image_attributes " do
|
|
214
214
|
@ec2.stubs(:make_request).with('ResetImageAttribute', {"ImageId"=>"ami-61a54008",
|
215
215
|
"Attribute"=>"launchPermission"}).
|
216
216
|
returns stub(:body => @reset_image_attribute_response_body, :is_a? => true)
|
217
|
-
@ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission").should.be.an.instance_of
|
217
|
+
@ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission").should.be.an.instance_of Hash
|
218
218
|
@ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission").return.should.equal "true"
|
219
219
|
end
|
220
220
|
|
@@ -235,4 +235,4 @@ context "EC2 image_attributes " do
|
|
235
235
|
end
|
236
236
|
|
237
237
|
|
238
|
-
end
|
238
|
+
end
|
data/test/test_EC2_images.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
# Amazon Web Services EC2 Query API Ruby library
|
3
3
|
#
|
4
4
|
# Ruby Gem Name:: amazon-ec2
|
5
|
-
# Author:: Glenn Rempe (mailto:
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
6
|
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
7
|
# License:: Distributes under the same terms as Ruby
|
8
|
-
# Home:: http://amazon-ec2
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
9
|
#++
|
10
10
|
|
11
11
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
@@ -60,7 +60,7 @@ context "An EC2 image " do
|
|
60
60
|
@ec2.stubs(:make_request).with('RegisterImage', {"ImageLocation"=>"mybucket-myimage.manifest.xml"}).
|
61
61
|
returns stub(:body => @register_image_response_body, :is_a? => true)
|
62
62
|
@ec2.register_image(:image_location => "mybucket-myimage.manifest.xml").imageId.should.equal "ami-61a54008"
|
63
|
-
@ec2.register_image(:image_location => "mybucket-myimage.manifest.xml").should.be.an.instance_of
|
63
|
+
@ec2.register_image(:image_location => "mybucket-myimage.manifest.xml").should.be.an.instance_of Hash
|
64
64
|
end
|
65
65
|
|
66
66
|
|
@@ -73,9 +73,9 @@ context "An EC2 image " do
|
|
73
73
|
specify "should be able to be described and return the correct Ruby response class for parent and members" do
|
74
74
|
@ec2.stubs(:make_request).with('DescribeImages', {}).
|
75
75
|
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
76
|
-
@ec2.describe_images.should.be.an.instance_of
|
76
|
+
@ec2.describe_images.should.be.an.instance_of Hash
|
77
77
|
response = @ec2.describe_images
|
78
|
-
response.should.be.an.instance_of
|
78
|
+
response.should.be.an.instance_of Hash
|
79
79
|
end
|
80
80
|
|
81
81
|
|
@@ -182,7 +182,7 @@ context "An EC2 image " do
|
|
182
182
|
specify "should be able to be de-registered" do
|
183
183
|
@ec2.stubs(:make_request).with('DeregisterImage', {"ImageId"=>"ami-61a54008"}).
|
184
184
|
returns stub(:body => @deregister_image_response_body, :is_a? => true)
|
185
|
-
@ec2.deregister_image(:image_id => "ami-61a54008" ).should.be.an.instance_of
|
185
|
+
@ec2.deregister_image(:image_id => "ami-61a54008" ).should.be.an.instance_of Hash
|
186
186
|
@ec2.deregister_image(:image_id => "ami-61a54008" ).return.should.equal "true"
|
187
187
|
end
|
188
188
|
|
data/test/test_EC2_instances.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
# Amazon Web Services EC2 Query API Ruby library
|
3
3
|
#
|
4
4
|
# Ruby Gem Name:: amazon-ec2
|
5
|
-
# Author:: Glenn Rempe (mailto:
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@rempe.us)
|
6
6
|
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
7
|
# License:: Distributes under the same terms as Ruby
|
8
|
-
# Home:: http://amazon-ec2
|
8
|
+
# Home:: http://github.com/grempe/amazon-ec2/tree/master
|
9
9
|
#++
|
10
10
|
|
11
11
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
@@ -30,7 +30,7 @@ context "EC2 instances " do
|
|
30
30
|
<imageId>ami-60a54009</imageId>
|
31
31
|
<instanceState>
|
32
32
|
<code>0</code>
|
33
|
-
|
33
|
+
<name>pending</name>
|
34
34
|
</instanceState>
|
35
35
|
<privateDnsName></privateDnsName>
|
36
36
|
<dnsName></dnsName>
|
@@ -44,7 +44,7 @@ context "EC2 instances " do
|
|
44
44
|
<imageId>ami-60a54009</imageId>
|
45
45
|
<instanceState>
|
46
46
|
<code>0</code>
|
47
|
-
|
47
|
+
<name>pending</name>
|
48
48
|
</instanceState>
|
49
49
|
<privateDnsName></privateDnsName>
|
50
50
|
<dnsName></dnsName>
|
@@ -58,7 +58,7 @@ context "EC2 instances " do
|
|
58
58
|
<imageId>ami-60a54009</imageId>
|
59
59
|
<instanceState>
|
60
60
|
<code>0</code>
|
61
|
-
|
61
|
+
<name>pending</name>
|
62
62
|
</instanceState>
|
63
63
|
<privateDnsName></privateDnsName>
|
64
64
|
<dnsName></dnsName>
|
@@ -146,7 +146,7 @@ context "EC2 instances " do
|
|
146
146
|
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "AddressingType" => 'public', 'InstanceType' => 'm1.small').
|
147
147
|
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
148
148
|
|
149
|
-
@ec2.run_instances( :image_id => "ami-60a54009" ).should.be.an.instance_of
|
149
|
+
@ec2.run_instances( :image_id => "ami-60a54009" ).should.be.an.instance_of Hash
|
150
150
|
|
151
151
|
response = @ec2.run_instances( :image_id => "ami-60a54009" )
|
152
152
|
|
@@ -223,27 +223,32 @@ context "EC2 instances " do
|
|
223
223
|
specify "should be able specify an availability_zone" do
|
224
224
|
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "Placement.AvailabilityZone" => "zone123", "UserData" => "foo", "AddressingType" => 'public', 'InstanceType' => 'm1.small').
|
225
225
|
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
226
|
-
@ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1, :availability_zone => "zone123", :group_id => [], :user_data => "foo", :base64_encoded => true ).should.be.an.instance_of
|
226
|
+
@ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1, :availability_zone => "zone123", :group_id => [], :user_data => "foo", :base64_encoded => true ).should.be.an.instance_of Hash
|
227
227
|
end
|
228
228
|
|
229
229
|
specify "should be able to call run_instances with :user_data and :base64_encoded => true (default is false)" do
|
230
230
|
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "UserData" => "foo", "AddressingType" => 'public', 'InstanceType' => 'm1.small').
|
231
231
|
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
232
|
-
@ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1, :group_id => [], :user_data => "foo", :base64_encoded => true ).should.be.an.instance_of
|
232
|
+
@ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1, :group_id => [], :user_data => "foo", :base64_encoded => true ).should.be.an.instance_of Hash
|
233
233
|
end
|
234
234
|
|
235
|
+
specify "should be able specify an kernel_id" do
|
236
|
+
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "Placement.AvailabilityZone" => "zone123", "UserData" => "foo", "AddressingType" => 'public', 'InstanceType' => 'm1.small', 'KernelId' => 'kernfoo').
|
237
|
+
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
238
|
+
@ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1, :availability_zone => "zone123", :group_id => [], :user_data => "foo", :base64_encoded => true, :kernel_id => 'kernfoo' ).should.be.an.instance_of Hash
|
239
|
+
end
|
235
240
|
|
236
241
|
specify "should be able to call run_instances with :user_data and :base64_encoded => false" do
|
237
242
|
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "UserData" => "Zm9v", "AddressingType" => 'public', 'InstanceType' => 'm1.small').
|
238
243
|
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
239
|
-
@ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1, :group_id => [], :user_data => "foo", :base64_encoded => false ).should.be.an.instance_of
|
244
|
+
@ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1, :max_count => 1, :group_id => [], :user_data => "foo", :base64_encoded => false ).should.be.an.instance_of Hash
|
240
245
|
end
|
241
246
|
|
242
247
|
|
243
248
|
specify "should be able to be described and return the correct Ruby response class" do
|
244
249
|
@ec2.stubs(:make_request).with('DescribeInstances', {}).
|
245
250
|
returns stub(:body => @describe_instances_response_body, :is_a? => true)
|
246
|
-
@ec2.describe_instances.should.be.an.instance_of
|
251
|
+
@ec2.describe_instances.should.be.an.instance_of Hash
|
247
252
|
response = @ec2.describe_instances
|
248
253
|
response.reservationSet.item[0].reservationId.should.equal "r-44a5402d"
|
249
254
|
end
|
@@ -297,7 +302,7 @@ context "EC2 instances " do
|
|
297
302
|
specify "should be able to be rebooted when provided with an :instance_id" do
|
298
303
|
@ec2.expects(:make_request).with('RebootInstances', {"InstanceId.1"=>"i-2ea64347", "InstanceId.2"=>"i-21a64348"}).
|
299
304
|
returns stub(:body => @reboot_instances_response_body, :is_a? => true)
|
300
|
-
@ec2.reboot_instances( :instance_id => ["i-2ea64347", "i-21a64348"] ).class.should.equal
|
305
|
+
@ec2.reboot_instances( :instance_id => ["i-2ea64347", "i-21a64348"] ).class.should.equal Hash
|
301
306
|
end
|
302
307
|
|
303
308
|
|
@@ -311,7 +316,7 @@ context "EC2 instances " do
|
|
311
316
|
specify "should be able to be terminated when provided with an :instance_id" do
|
312
317
|
@ec2.stubs(:make_request).with('TerminateInstances', {"InstanceId.1"=>"i-28a64341", "InstanceId.2"=>"i-21a64348"}).
|
313
318
|
returns stub(:body => @terminate_instances_response_body, :is_a? => true)
|
314
|
-
@ec2.terminate_instances( :instance_id => ["i-28a64341", "i-21a64348"] ).class.should.equal
|
319
|
+
@ec2.terminate_instances( :instance_id => ["i-28a64341", "i-21a64348"] ).class.should.equal Hash
|
315
320
|
|
316
321
|
@response = @ec2.terminate_instances( :instance_id => ["i-28a64341", "i-21a64348"] )
|
317
322
|
|