amazon-ec2 0.1.0 → 0.2.0
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/History.txt +166 -95
- data/License.txt +67 -20
- data/Manifest.txt +17 -6
- data/README.txt +112 -2
- data/Rakefile +15 -5
- data/bin/ec2-gem-example.rb +61 -0
- data/bin/ec2sh +73 -0
- data/bin/setup.rb +19 -0
- data/lib/EC2.rb +142 -61
- data/lib/EC2/console.rb +44 -0
- data/lib/EC2/exceptions.rb +136 -0
- data/lib/EC2/image_attributes.rb +137 -29
- data/lib/EC2/images.rb +120 -73
- data/lib/EC2/instances.rb +168 -98
- data/lib/EC2/keypairs.rb +79 -23
- data/lib/EC2/responses.rb +142 -321
- data/lib/EC2/security_groups.rb +209 -117
- data/lib/EC2/version.rb +11 -2
- data/test/test_EC2.rb +44 -13
- data/test/test_EC2_console.rb +54 -0
- data/test/test_EC2_image_attributes.rb +188 -0
- data/test/test_EC2_images.rb +191 -0
- data/test/test_EC2_instances.rb +303 -0
- data/test/test_EC2_keypairs.rb +123 -0
- data/test/test_EC2_responses.rb +102 -0
- data/test/test_EC2_security_groups.rb +205 -0
- data/test/test_EC2_version.rb +44 -0
- data/test/test_helper.rb +16 -8
- data/website/index.html +378 -86
- data/website/index.txt +339 -88
- data/website/stylesheets/screen.css +8 -8
- metadata +89 -16
- data/examples/ec2-example.rb +0 -48
- data/test/test_responses.rb +0 -17
@@ -0,0 +1,188 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@elasticworkbench.com)
|
6
|
+
# Copyright:: Copyright (c) 2007 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://amazon-ec2.rubyforge.org
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 image_attributes " do
|
14
|
+
|
15
|
+
setup do
|
16
|
+
@ec2 = EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@modify_image_attribute_response_body = <<-RESPONSE
|
19
|
+
<ModifyImageAttributeResponse xm-lns="http://ec2.amazonaws.com/doc/2007-01-19">
|
20
|
+
<return>true</return>
|
21
|
+
</ModifyImageAttributeResponse>
|
22
|
+
RESPONSE
|
23
|
+
|
24
|
+
@reset_image_attribute_response_body = <<-RESPONSE
|
25
|
+
<ResetImageAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19">
|
26
|
+
<return>true</return>
|
27
|
+
</ResetImageAttributeResponse>
|
28
|
+
RESPONSE
|
29
|
+
|
30
|
+
@describe_image_attribute_response_body = <<-RESPONSE
|
31
|
+
<DescribeImageAttributeResponse xm-lns="http://ec2.amazonaws.com/doc/2007-01-19">
|
32
|
+
<imageId>ami-61a54008</imageId>
|
33
|
+
<launchPermission>
|
34
|
+
<item>
|
35
|
+
<group>all</group>
|
36
|
+
</item>
|
37
|
+
<item>
|
38
|
+
<userId>495219933132</userId>
|
39
|
+
</item>
|
40
|
+
</launchPermission>
|
41
|
+
</DescribeImageAttributeResponse>
|
42
|
+
RESPONSE
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
specify "should be able to be changed with modify_image_attribute (with :attribute and single value :user_id and :group)" do
|
48
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
49
|
+
"Attribute"=>"launchPermission",
|
50
|
+
"OperationType"=>"add",
|
51
|
+
"UserId.1"=>"123",
|
52
|
+
"Group.1"=>"all"}).
|
53
|
+
returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
54
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :user_id=>["123"], :group=>["all"]).should.be.an.instance_of EC2::Response
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
specify "should be able to be changed with modify_image_attribute ( with :attribute but specifying :group only)" do
|
59
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
60
|
+
"Attribute"=>"launchPermission",
|
61
|
+
"OperationType"=>"add",
|
62
|
+
"Group.1"=>"all"}).
|
63
|
+
returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
64
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]).should.be.an.instance_of EC2::Response
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
specify "should be able to be changed with modify_image_attribute ( with :operation_type 'remove')" do
|
69
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
70
|
+
"Attribute"=>"launchPermission",
|
71
|
+
"OperationType"=>"remove",
|
72
|
+
"Group.1"=>"all"}).
|
73
|
+
returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
74
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"remove", :group=>["all"]).should.be.an.instance_of EC2::Response
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
specify "should be able to be changed with modify_image_attribute ( with :attribute but specifying :user_id only)" do
|
79
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
80
|
+
"Attribute"=>"launchPermission",
|
81
|
+
"OperationType"=>"add",
|
82
|
+
"UserId.1"=>"123"}).returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
83
|
+
|
84
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008",
|
85
|
+
:attribute=>"launchPermission",
|
86
|
+
:operation_type=>"add",
|
87
|
+
:user_id=>["123"]).should.be.an.instance_of EC2::Response
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
specify "should be able to be changed with modify_image_attribute ( with :attribute and multiple :user_id and :group elements)" do
|
92
|
+
@ec2.stubs(:make_request).with('ModifyImageAttribute', {"ImageId"=>"ami-61a54008",
|
93
|
+
"Attribute"=>"launchPermission",
|
94
|
+
"OperationType"=>"add",
|
95
|
+
"UserId.1"=>"123",
|
96
|
+
"UserId.2"=>"345",
|
97
|
+
"Group.1"=>"123",
|
98
|
+
"Group.2"=>"all"}).returns stub(:body => @modify_image_attribute_response_body, :is_a? => true)
|
99
|
+
|
100
|
+
@ec2.modify_image_attribute(:image_id=>"ami-61a54008",
|
101
|
+
:attribute=>"launchPermission",
|
102
|
+
:operation_type=>"add",
|
103
|
+
:user_id=>["123", "345"],
|
104
|
+
:group=>["123", "all"]).should.be.an.instance_of EC2::Response
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
specify "should raise an exception when modify_image_attribute is called with incorrect arguments" do
|
109
|
+
# method args can't be nil or empty
|
110
|
+
lambda { @ec2.modify_image_attribute() }.should.raise(EC2::ArgumentError)
|
111
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"") }.should.raise(EC2::ArgumentError)
|
112
|
+
|
113
|
+
# :image_id option must be not be empty or nil
|
114
|
+
lambda { @ec2.modify_image_attribute(:image_id=>nil, :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]) }.should.raise(EC2::ArgumentError)
|
115
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"", :attribute=>"launchPermission", :operation_type=>"add", :group=>["all"]) }.should.raise(EC2::ArgumentError)
|
116
|
+
|
117
|
+
# :attribute currently has one option which is 'launchPermission', it should fail with any other value, nil, or empty
|
118
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil, :operation_type=>"add", :group=>["all"]) }.should.raise(EC2::ArgumentError)
|
119
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"", :operation_type=>"add", :group=>["all"]) }.should.raise(EC2::ArgumentError)
|
120
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo", :operation_type=>"add", :group=>["all"]) }.should.raise(EC2::ArgumentError)
|
121
|
+
|
122
|
+
# :attribute option should fail if neither :group nor :user_id are also provided
|
123
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"add") }.should.raise(EC2::ArgumentError)
|
124
|
+
|
125
|
+
# :operation_type currently has two options which are 'add' and 'remove', and it should fail with any other, nil or empty
|
126
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>nil, :group=>["all"]) }.should.raise(EC2::ArgumentError)
|
127
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"", :group=>["all"]) }.should.raise(EC2::ArgumentError)
|
128
|
+
lambda { @ec2.modify_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission", :operation_type=>"foo", :group=>["all"]) }.should.raise(EC2::ArgumentError)
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
specify "method describe_image_attribute should return the proper attributes" do
|
133
|
+
@ec2.stubs(:make_request).with('DescribeImageAttribute', {"ImageId"=>"ami-61a54008",
|
134
|
+
"Attribute"=>"launchPermission" }).
|
135
|
+
returns stub(:body => @describe_image_attribute_response_body, :is_a? => true)
|
136
|
+
|
137
|
+
@ec2.describe_image_attribute(:image_id => "ami-61a54008", :attribute => "launchPermission").
|
138
|
+
should.be.an.instance_of EC2::Response
|
139
|
+
|
140
|
+
response = @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission")
|
141
|
+
response.imageId.should.equal "ami-61a54008"
|
142
|
+
response.launchPermission.item[0].group.should.equal "all"
|
143
|
+
response.launchPermission.item[1].userId.should.equal "495219933132"
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
specify "should raise an exception when describe_image_attribute is called with incorrect arguments" do
|
148
|
+
# method args can't be nil or empty
|
149
|
+
lambda { @ec2.describe_image_attribute() }.should.raise(EC2::ArgumentError)
|
150
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"") }.should.raise(EC2::ArgumentError)
|
151
|
+
|
152
|
+
# :image_id option must be not be empty or nil
|
153
|
+
lambda { @ec2.describe_image_attribute(:image_id=>nil, :attribute=>"launchPermission") }.should.raise(EC2::ArgumentError)
|
154
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"", :attribute=>"launchPermission") }.should.raise(EC2::ArgumentError)
|
155
|
+
|
156
|
+
# :attribute currently has one option which is 'launchPermission', it should fail with any other value, nil, or empty
|
157
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil) }.should.raise(EC2::ArgumentError)
|
158
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"") }.should.raise(EC2::ArgumentError)
|
159
|
+
lambda { @ec2.describe_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo") }.should.raise(EC2::ArgumentError)
|
160
|
+
end
|
161
|
+
|
162
|
+
|
163
|
+
specify "should be able to reset attributes with reset_image_attribute " do
|
164
|
+
@ec2.stubs(:make_request).with('ResetImageAttribute', {"ImageId"=>"ami-61a54008",
|
165
|
+
"Attribute"=>"launchPermission"}).
|
166
|
+
returns stub(:body => @reset_image_attribute_response_body, :is_a? => true)
|
167
|
+
@ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission").should.be.an.instance_of EC2::Response
|
168
|
+
@ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"launchPermission").return.should.equal "true"
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
specify "should raise an exception when reset_image_attribute is called with incorrect arguments" do
|
173
|
+
# method args can't be nil or empty
|
174
|
+
lambda { @ec2.reset_image_attribute() }.should.raise(EC2::ArgumentError)
|
175
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"") }.should.raise(EC2::ArgumentError)
|
176
|
+
|
177
|
+
# :image_id option must be not be empty or nil
|
178
|
+
lambda { @ec2.reset_image_attribute(:image_id=>nil, :attribute=>"launchPermission") }.should.raise(EC2::ArgumentError)
|
179
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"", :attribute=>"launchPermission") }.should.raise(EC2::ArgumentError)
|
180
|
+
|
181
|
+
# :attribute currently has one option which is 'launchPermission', it should fail with any other value, nil, or empty
|
182
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>nil) }.should.raise(EC2::ArgumentError)
|
183
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"") }.should.raise(EC2::ArgumentError)
|
184
|
+
lambda { @ec2.reset_image_attribute(:image_id=>"ami-61a54008", :attribute=>"foo") }.should.raise(EC2::ArgumentError)
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@elasticworkbench.com)
|
6
|
+
# Copyright:: Copyright (c) 2007 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://amazon-ec2.rubyforge.org
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "An EC2 image " do
|
14
|
+
|
15
|
+
setup do
|
16
|
+
@ec2 = EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@register_image_response_body = <<-RESPONSE
|
19
|
+
<RegisterImageResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19">
|
20
|
+
<imageId>ami-61a54008</imageId>
|
21
|
+
</RegisterImageResponse>
|
22
|
+
RESPONSE
|
23
|
+
|
24
|
+
@describe_image_response_body = <<-RESPONSE
|
25
|
+
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19">
|
26
|
+
<imagesSet>
|
27
|
+
<item>
|
28
|
+
<imageId>ami-61a54008</imageId>
|
29
|
+
<imageLocation>foobar1/image.manifest.xml</imageLocation>
|
30
|
+
<imageState>available</imageState>
|
31
|
+
<imageOwnerId>AAAATLBUXIEON5NQVUUX6OMPWBZIAAAA</imageOwnerId>
|
32
|
+
<isPublic>true</isPublic>
|
33
|
+
</item>
|
34
|
+
<item>
|
35
|
+
<imageId>ami-61a54009</imageId>
|
36
|
+
<imageLocation>foobar2/image.manifest.xml</imageLocation>
|
37
|
+
<imageState>deregistered</imageState>
|
38
|
+
<imageOwnerId>ZZZZTLBUXIEON5NQVUUX6OMPWBZIZZZZ</imageOwnerId>
|
39
|
+
<isPublic>false</isPublic>
|
40
|
+
</item>
|
41
|
+
</imagesSet>
|
42
|
+
</DescribeImagesResponse>
|
43
|
+
RESPONSE
|
44
|
+
|
45
|
+
@deregister_image_response_body = <<-RESPONSE
|
46
|
+
<DeregisterImageResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19">
|
47
|
+
<return>true</return>
|
48
|
+
</DeregisterImageResponse>
|
49
|
+
RESPONSE
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
specify "should be able to be registered" do
|
55
|
+
@ec2.stubs(:make_request).with('RegisterImage', {"ImageLocation"=>"mybucket-myimage.manifest.xml"}).
|
56
|
+
returns stub(:body => @register_image_response_body, :is_a? => true)
|
57
|
+
@ec2.register_image(:image_location => "mybucket-myimage.manifest.xml").imageId.should.equal "ami-61a54008"
|
58
|
+
@ec2.register_image(:image_location => "mybucket-myimage.manifest.xml").should.be.an.instance_of EC2::Response
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
specify "method register_image should raise an exception when called without nil/empty string arguments" do
|
63
|
+
lambda { @ec2.register_image() }.should.raise(EC2::ArgumentError)
|
64
|
+
lambda { @ec2.register_image(:image_location => "") }.should.raise(EC2::ArgumentError)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
specify "should be able to be described and return the correct Ruby response class for parent and members" do
|
69
|
+
@ec2.stubs(:make_request).with('DescribeImages', {}).
|
70
|
+
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
71
|
+
@ec2.describe_images.should.be.an.instance_of EC2::Response
|
72
|
+
response = @ec2.describe_images
|
73
|
+
response.should.be.an.instance_of EC2::Response
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
specify "should be able to be described with no params and return an imagesSet" do
|
78
|
+
@ec2.stubs(:make_request).with('DescribeImages', {}).
|
79
|
+
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
80
|
+
@ec2.describe_images.imagesSet.item.length.should.equal 2
|
81
|
+
end
|
82
|
+
|
83
|
+
specify "should be able to be described by an Array of ImageId.N ID's and return an array of Items" do
|
84
|
+
@ec2.stubs(:make_request).with('DescribeImages', {"ImageId.1"=>"ami-61a54008", "ImageId.2"=>"ami-61a54009"}).
|
85
|
+
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
86
|
+
@ec2.describe_images( :image_id => ["ami-61a54008", "ami-61a54009"] ).imagesSet.item.length.should.equal 2
|
87
|
+
|
88
|
+
response = @ec2.describe_images( :image_id => ["ami-61a54008", "ami-61a54009"] )
|
89
|
+
|
90
|
+
# test first 'Item' object returned
|
91
|
+
response.imagesSet.item[0].imageId.should.equal "ami-61a54008"
|
92
|
+
response.imagesSet.item[0].imageLocation.should.equal "foobar1/image.manifest.xml"
|
93
|
+
response.imagesSet.item[0].imageState.should.equal "available"
|
94
|
+
response.imagesSet.item[0].imageOwnerId.should.equal "AAAATLBUXIEON5NQVUUX6OMPWBZIAAAA"
|
95
|
+
response.imagesSet.item[0].isPublic.should.equal "true"
|
96
|
+
|
97
|
+
# test second 'Item' object returned
|
98
|
+
response.imagesSet.item[1].imageId.should.equal "ami-61a54009"
|
99
|
+
response.imagesSet.item[1].imageLocation.should.equal "foobar2/image.manifest.xml"
|
100
|
+
response.imagesSet.item[1].imageState.should.equal "deregistered"
|
101
|
+
response.imagesSet.item[1].imageOwnerId.should.equal "ZZZZTLBUXIEON5NQVUUX6OMPWBZIZZZZ"
|
102
|
+
response.imagesSet.item[1].isPublic.should.equal "false"
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
specify "should be able to be described by an owners with Owner.N ID's and return an array of Items" do
|
107
|
+
@ec2.stubs(:make_request).with('DescribeImages', "Owner.1" => "AAAATLBUXIEON5NQVUUX6OMPWBZIAAAA", "Owner.2" => "ZZZZTLBUXIEON5NQVUUX6OMPWBZIZZZZ").
|
108
|
+
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
109
|
+
@ec2.describe_images( :owner_id => ["AAAATLBUXIEON5NQVUUX6OMPWBZIAAAA", "ZZZZTLBUXIEON5NQVUUX6OMPWBZIZZZZ"] ).imagesSet.item.length.should.equal 2
|
110
|
+
|
111
|
+
# owner ID's
|
112
|
+
response = @ec2.describe_images( :owner_id => ["AAAATLBUXIEON5NQVUUX6OMPWBZIAAAA", "ZZZZTLBUXIEON5NQVUUX6OMPWBZIZZZZ"] )
|
113
|
+
response.imagesSet.item[0].imageId.should.equal "ami-61a54008"
|
114
|
+
response.imagesSet.item[1].imageId.should.equal "ami-61a54009"
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
specify "should be able to be described by an owner of 'self' and return an array of Items that I own" do
|
119
|
+
@ec2.stubs(:make_request).with('DescribeImages', "Owner.1" => "self").
|
120
|
+
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
121
|
+
@ec2.describe_images( :owner_id => "self" ).imagesSet.item.length.should.equal 2
|
122
|
+
|
123
|
+
# 'self' - Those that I own
|
124
|
+
response = @ec2.describe_images( :owner_id => "self" )
|
125
|
+
response.imagesSet.item[0].imageId.should.equal "ami-61a54008"
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
specify "should be able to be described by an owner of 'amazon' and return an array of Items that are Amazon Public AMI's" do
|
130
|
+
@ec2.stubs(:make_request).with('DescribeImages', "Owner.1" => "amazon").
|
131
|
+
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
132
|
+
@ec2.describe_images( :owner_id => "amazon" ).imagesSet.item.length.should.equal 2
|
133
|
+
|
134
|
+
# 'amazon' - Those that are owned and created by AWS
|
135
|
+
response = @ec2.describe_images( :owner_id => "amazon" )
|
136
|
+
response.imagesSet.item[0].imageId.should.equal "ami-61a54008"
|
137
|
+
end
|
138
|
+
|
139
|
+
|
140
|
+
specify "should be able to be described by an owners with Owner.N ID's who can execute AMI's and return an array of Items" do
|
141
|
+
@ec2.stubs(:make_request).with('DescribeImages', "ExecutableBy.1" => "AAAATLBUXIEON5NQVUUX6OMPWBZIAAAA", "ExecutableBy.2" => "ZZZZTLBUXIEON5NQVUUX6OMPWBZIZZZZ").
|
142
|
+
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
143
|
+
@ec2.describe_images( :executable_by => ["AAAATLBUXIEON5NQVUUX6OMPWBZIAAAA", "ZZZZTLBUXIEON5NQVUUX6OMPWBZIZZZZ"] ).imagesSet.item.length.should.equal 2
|
144
|
+
|
145
|
+
# executable by owner ID's
|
146
|
+
response = @ec2.describe_images( :executable_by => ["AAAATLBUXIEON5NQVUUX6OMPWBZIAAAA", "ZZZZTLBUXIEON5NQVUUX6OMPWBZIZZZZ"] )
|
147
|
+
response.imagesSet.item[0].imageId.should.equal "ami-61a54008"
|
148
|
+
response.imagesSet.item[1].imageId.should.equal "ami-61a54009"
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
specify "should be able to be described by an owners with Owner.N of 'self' who can execute AMI's and return an array of Items" do
|
153
|
+
@ec2.stubs(:make_request).with('DescribeImages', "ExecutableBy.1" => "self").
|
154
|
+
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
155
|
+
@ec2.describe_images( :executable_by => "self" ).imagesSet.item.length.should.equal 2
|
156
|
+
|
157
|
+
# executable by owner ID's
|
158
|
+
response = @ec2.describe_images( :executable_by => "self" )
|
159
|
+
response.imagesSet.item[0].imageId.should.equal "ami-61a54008"
|
160
|
+
response.imagesSet.item[1].imageId.should.equal "ami-61a54009"
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
specify "should be able to be described by an owners with Owner.N of 'all' who can execute AMI's and return an array of Items" do
|
165
|
+
@ec2.stubs(:make_request).with('DescribeImages', "ExecutableBy.1" => "all").
|
166
|
+
returns stub(:body => @describe_image_response_body, :is_a? => true)
|
167
|
+
@ec2.describe_images( :executable_by => "all" ).imagesSet.item.length.should.equal 2
|
168
|
+
|
169
|
+
# executable by owner ID's
|
170
|
+
response = @ec2.describe_images( :executable_by => "all" )
|
171
|
+
response.imagesSet.item[0].imageId.should.equal "ami-61a54008"
|
172
|
+
response.imagesSet.item[1].imageId.should.equal "ami-61a54009"
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
specify "should be able to be de-registered" do
|
177
|
+
@ec2.stubs(:make_request).with('DeregisterImage', {"ImageId"=>"ami-61a54008"}).
|
178
|
+
returns stub(:body => @deregister_image_response_body, :is_a? => true)
|
179
|
+
@ec2.deregister_image(:image_id => "ami-61a54008" ).should.be.an.instance_of EC2::Response
|
180
|
+
@ec2.deregister_image(:image_id => "ami-61a54008" ).return.should.equal "true"
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
specify "method deregister_image should raise an exception when called without nil/empty string arguments" do
|
185
|
+
lambda { @ec2.deregister_image() }.should.raise(EC2::ArgumentError)
|
186
|
+
lambda { @ec2.deregister_image( :image_id => nil ) }.should.raise(EC2::ArgumentError)
|
187
|
+
lambda { @ec2.deregister_image( :image_id => "" ) }.should.raise(EC2::ArgumentError)
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
end
|
@@ -0,0 +1,303 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:glenn@elasticworkbench.com)
|
6
|
+
# Copyright:: Copyright (c) 2007 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://amazon-ec2.rubyforge.org
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 instances " do
|
14
|
+
|
15
|
+
setup do
|
16
|
+
@ec2 = EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@run_instances_response_body = <<-RESPONSE
|
19
|
+
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19">
|
20
|
+
<reservationId>r-47a5402e</reservationId>
|
21
|
+
<ownerId>495219933132</ownerId>
|
22
|
+
<groupSet>
|
23
|
+
<item>
|
24
|
+
<groupId>default</groupId>
|
25
|
+
</item>
|
26
|
+
</groupSet>
|
27
|
+
<instancesSet>
|
28
|
+
<item>
|
29
|
+
<instanceId>i-2ba64342</instanceId>
|
30
|
+
<imageId>ami-60a54009</imageId>
|
31
|
+
<instanceState>
|
32
|
+
<code>0</code>
|
33
|
+
<name>pending</name>
|
34
|
+
</instanceState>
|
35
|
+
<privateDnsName/>
|
36
|
+
<dnsName/>
|
37
|
+
<keyName>example-key-name</keyName>
|
38
|
+
</item>
|
39
|
+
<item>
|
40
|
+
<instanceId>i-2bc64242</instanceId>
|
41
|
+
<imageId>ami-60a54009</imageId>
|
42
|
+
<instanceState>
|
43
|
+
<code>0</code>
|
44
|
+
<name>pending</name>
|
45
|
+
</instanceState>
|
46
|
+
<privateDnsName/>
|
47
|
+
<dnsName/>
|
48
|
+
<keyName>example-key-name</keyName>
|
49
|
+
</item>
|
50
|
+
<item>
|
51
|
+
<instanceId>i-2be64332</instanceId>
|
52
|
+
<imageId>ami-60a54009</imageId>
|
53
|
+
<instanceState>
|
54
|
+
<code>0</code>
|
55
|
+
<name>pending</name>
|
56
|
+
</instanceState>
|
57
|
+
<privateDnsName/>
|
58
|
+
<dnsName/>
|
59
|
+
<keyName>example-key-name</keyName>
|
60
|
+
</item>
|
61
|
+
</instancesSet>
|
62
|
+
</RunInstancesResponse>
|
63
|
+
RESPONSE
|
64
|
+
|
65
|
+
@describe_instances_response_body = <<-RESPONSE
|
66
|
+
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19">
|
67
|
+
<reservationSet>
|
68
|
+
<item>
|
69
|
+
<reservationId>r-44a5402d</reservationId>
|
70
|
+
<ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>
|
71
|
+
<groupSet>
|
72
|
+
<item>
|
73
|
+
<groupId>default</groupId>
|
74
|
+
</item>
|
75
|
+
</groupSet>
|
76
|
+
<instancesSet>
|
77
|
+
<item>
|
78
|
+
<instanceId>i-28a64341</instanceId>
|
79
|
+
<imageId>ami-6ea54007</imageId>
|
80
|
+
<instanceState>
|
81
|
+
<code>0</code>
|
82
|
+
<name>running</name>
|
83
|
+
</instanceState>
|
84
|
+
<privateDnsName>domU-12-31-35-00-1E-01.z-2.compute-1.internal</privateDnsName>
|
85
|
+
<dnsName>ec2-72-44-33-4.z-2.compute-1.amazonaws.com</dnsName>
|
86
|
+
<keyName>example-key-name</keyName>
|
87
|
+
</item>
|
88
|
+
</instancesSet>
|
89
|
+
</item>
|
90
|
+
</reservationSet>
|
91
|
+
</DescribeInstancesResponse>
|
92
|
+
RESPONSE
|
93
|
+
|
94
|
+
@reboot_instances_response_body = <<-RESPONSE
|
95
|
+
<RebootInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19">
|
96
|
+
<return>true</return>
|
97
|
+
</RebootInstancesResponse>
|
98
|
+
RESPONSE
|
99
|
+
|
100
|
+
@terminate_instances_response_body = <<-RESPONSE
|
101
|
+
<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19">
|
102
|
+
<instancesSet>
|
103
|
+
<item>
|
104
|
+
<instanceId>i-28a64341</instanceId>
|
105
|
+
<shutdownState>
|
106
|
+
<code>32</code>
|
107
|
+
<name>shutting-down</name>
|
108
|
+
</shutdownState>
|
109
|
+
<previousState>
|
110
|
+
<code>0</code>
|
111
|
+
<name>pending</name>
|
112
|
+
</previousState>
|
113
|
+
</item>
|
114
|
+
<item>
|
115
|
+
<instanceId>i-21a64348</instanceId>
|
116
|
+
<shutdownState>
|
117
|
+
<code>32</code>
|
118
|
+
<name>shutting-down</name>
|
119
|
+
</shutdownState>
|
120
|
+
<previousState>
|
121
|
+
<code>0</code>
|
122
|
+
<name>pending</name>
|
123
|
+
</previousState>
|
124
|
+
</item>
|
125
|
+
</instancesSet>
|
126
|
+
</TerminateInstancesResponse>
|
127
|
+
RESPONSE
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
specify "should be able to be run" do
|
132
|
+
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "AddressingType" => 'public').
|
133
|
+
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
134
|
+
|
135
|
+
@ec2.run_instances( :image_id => "ami-60a54009" ).should.be.an.instance_of EC2::Response
|
136
|
+
|
137
|
+
response = @ec2.run_instances( :image_id => "ami-60a54009" )
|
138
|
+
|
139
|
+
response.reservationId.should.equal "r-47a5402e"
|
140
|
+
response.ownerId.should.equal "495219933132"
|
141
|
+
|
142
|
+
response.groupSet.item[0].groupId.should.equal "default"
|
143
|
+
|
144
|
+
response.instancesSet.item.length.should.equal 3
|
145
|
+
|
146
|
+
response.instancesSet.item[0].instanceId.should.equal "i-2ba64342"
|
147
|
+
response.instancesSet.item[0].imageId.should.equal "ami-60a54009"
|
148
|
+
response.instancesSet.item[0].instanceState.code.should.equal "0"
|
149
|
+
response.instancesSet.item[0].instanceState.name.should.equal "pending"
|
150
|
+
response.instancesSet.item[0].privateDnsName
|
151
|
+
response.instancesSet.item[0].dnsName.should.be.nil
|
152
|
+
response.instancesSet.item[0].keyName.should.equal "example-key-name"
|
153
|
+
|
154
|
+
response.instancesSet.item[1].instanceId.should.equal "i-2bc64242"
|
155
|
+
response.instancesSet.item[1].imageId.should.equal "ami-60a54009"
|
156
|
+
response.instancesSet.item[1].instanceState.code.should.equal "0"
|
157
|
+
response.instancesSet.item[1].instanceState.name.should.equal "pending"
|
158
|
+
response.instancesSet.item[1].privateDnsName
|
159
|
+
response.instancesSet.item[1].dnsName.should.be.nil
|
160
|
+
response.instancesSet.item[1].keyName.should.equal "example-key-name"
|
161
|
+
|
162
|
+
response.instancesSet.item[2].instanceId.should.equal "i-2be64332"
|
163
|
+
response.instancesSet.item[2].imageId.should.equal "ami-60a54009"
|
164
|
+
response.instancesSet.item[2].instanceState.code.should.equal "0"
|
165
|
+
response.instancesSet.item[2].instanceState.name.should.equal "pending"
|
166
|
+
response.instancesSet.item[2].privateDnsName
|
167
|
+
response.instancesSet.item[2].dnsName.should.be.nil
|
168
|
+
response.instancesSet.item[2].keyName.should.equal "example-key-name"
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
specify "method 'run_instances' should reject invalid arguments" do
|
173
|
+
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "AddressingType" => 'public').
|
174
|
+
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
175
|
+
|
176
|
+
lambda { @ec2.run_instances() }.should.raise(EC2::ArgumentError)
|
177
|
+
lambda { @ec2.run_instances( :image_id => "" ) }.should.raise(EC2::ArgumentError)
|
178
|
+
|
179
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 1 ) }.should.not.raise(EC2::ArgumentError)
|
180
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => 0 ) }.should.raise(EC2::ArgumentError)
|
181
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => nil ) }.should.raise(EC2::ArgumentError)
|
182
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :min_count => "" ) }.should.raise(EC2::ArgumentError)
|
183
|
+
|
184
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => 1 ) }.should.not.raise(EC2::ArgumentError)
|
185
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => 0 ) }.should.raise(EC2::ArgumentError)
|
186
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => nil ) }.should.raise(EC2::ArgumentError)
|
187
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :max_count => "" ) }.should.raise(EC2::ArgumentError)
|
188
|
+
|
189
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => "public" ) }.should.not.raise(EC2::ArgumentError)
|
190
|
+
#lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => "direct" ) }.should.not.raise(EC2::ArgumentError)
|
191
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => nil ) }.should.raise(EC2::ArgumentError)
|
192
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => "" ) }.should.raise(EC2::ArgumentError)
|
193
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :addressing_type => "foo" ) }.should.raise(EC2::ArgumentError)
|
194
|
+
|
195
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => true ) }.should.not.raise(EC2::ArgumentError)
|
196
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => false ) }.should.not.raise(EC2::ArgumentError)
|
197
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => nil ) }.should.raise(EC2::ArgumentError)
|
198
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => "" ) }.should.raise(EC2::ArgumentError)
|
199
|
+
lambda { @ec2.run_instances( :image_id => "ami-60a54009", :base64_encoded => "foo" ) }.should.raise(EC2::ArgumentError)
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
specify "should be able to call run_instances with :user_data and :base64_encoded => true (default is false)" do
|
204
|
+
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "UserData" => "foo", "AddressingType" => 'public').
|
205
|
+
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
206
|
+
@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 EC2::Response
|
207
|
+
end
|
208
|
+
|
209
|
+
|
210
|
+
specify "should be able to call run_instances with :user_data and :base64_encoded => false" do
|
211
|
+
@ec2.stubs(:make_request).with('RunInstances', "ImageId" => "ami-60a54009", "MinCount" => '1', "MaxCount" => '1', "UserData" => "Zm9v", "AddressingType" => 'public').
|
212
|
+
returns stub(:body => @run_instances_response_body, :is_a? => true)
|
213
|
+
@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 EC2::Response
|
214
|
+
end
|
215
|
+
|
216
|
+
|
217
|
+
specify "should be able to be described and return the correct Ruby response class" do
|
218
|
+
@ec2.stubs(:make_request).with('DescribeInstances', {}).
|
219
|
+
returns stub(:body => @describe_instances_response_body, :is_a? => true)
|
220
|
+
@ec2.describe_instances.should.be.an.instance_of EC2::Response
|
221
|
+
response = @ec2.describe_instances
|
222
|
+
response.reservationSet.item[0].reservationId.should.equal "r-44a5402d"
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
specify "should be able to be described with no params and return an array of Items" do
|
227
|
+
@ec2.stubs(:make_request).with('DescribeInstances', {}).
|
228
|
+
returns stub(:body => @describe_instances_response_body, :is_a? => true)
|
229
|
+
@ec2.describe_instances.reservationSet.item.length.should.equal 1
|
230
|
+
response = @ec2.describe_instances
|
231
|
+
response.reservationSet.item[0].reservationId.should.equal "r-44a5402d"
|
232
|
+
response.reservationSet.item[0].ownerId.should.equal "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM"
|
233
|
+
response.reservationSet.item[0].groupSet.item[0].groupId.should.equal "default"
|
234
|
+
response.reservationSet.item[0].instancesSet.item[0].instanceId.should.equal "i-28a64341"
|
235
|
+
response.reservationSet.item[0].instancesSet.item[0].imageId.should.equal "ami-6ea54007"
|
236
|
+
response.reservationSet.item[0].instancesSet.item[0].instanceState.code.should.equal "0"
|
237
|
+
response.reservationSet.item[0].instancesSet.item[0].instanceState.name.should.equal "running"
|
238
|
+
response.reservationSet.item[0].instancesSet.item[0].privateDnsName.should.equal "domU-12-31-35-00-1E-01.z-2.compute-1.internal"
|
239
|
+
response.reservationSet.item[0].instancesSet.item[0].dnsName.should.equal "ec2-72-44-33-4.z-2.compute-1.amazonaws.com"
|
240
|
+
response.reservationSet.item[0].instancesSet.item[0].keyName.should.equal "example-key-name"
|
241
|
+
end
|
242
|
+
|
243
|
+
|
244
|
+
specify "should be able to be described with params of Array of :instance_id's and return an array of Items" do
|
245
|
+
@ec2.stubs(:make_request).with('DescribeInstances', {"InstanceId.1" => "i-28a64341"}).
|
246
|
+
returns stub(:body => @describe_instances_response_body, :is_a? => true)
|
247
|
+
@ec2.describe_instances( :instance_id => "i-28a64341" ).reservationSet.item.length.should.equal 1
|
248
|
+
response = @ec2.describe_instances( :instance_id => "i-28a64341" )
|
249
|
+
response.reservationSet.item[0].reservationId.should.equal "r-44a5402d"
|
250
|
+
response.reservationSet.item[0].ownerId.should.equal "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM"
|
251
|
+
response.reservationSet.item[0].groupSet.item[0].groupId.should.equal "default"
|
252
|
+
response.reservationSet.item[0].instancesSet.item[0].instanceId.should.equal "i-28a64341"
|
253
|
+
response.reservationSet.item[0].instancesSet.item[0].imageId.should.equal "ami-6ea54007"
|
254
|
+
response.reservationSet.item[0].instancesSet.item[0].instanceState.code.should.equal "0"
|
255
|
+
response.reservationSet.item[0].instancesSet.item[0].instanceState.name.should.equal "running"
|
256
|
+
response.reservationSet.item[0].instancesSet.item[0].privateDnsName.should.equal "domU-12-31-35-00-1E-01.z-2.compute-1.internal"
|
257
|
+
response.reservationSet.item[0].instancesSet.item[0].dnsName.should.equal "ec2-72-44-33-4.z-2.compute-1.amazonaws.com"
|
258
|
+
response.reservationSet.item[0].instancesSet.item[0].keyName.should.equal "example-key-name"
|
259
|
+
end
|
260
|
+
|
261
|
+
|
262
|
+
specify "method reboot_instances should raise an exception when called without nil/empty string arguments" do
|
263
|
+
lambda { @ec2.reboot_instances() }.should.raise(EC2::ArgumentError)
|
264
|
+
lambda { @ec2.reboot_instances( :instance_id => nil ) }.should.raise(EC2::ArgumentError)
|
265
|
+
lambda { @ec2.reboot_instances( :instance_id => "" ) }.should.raise(EC2::ArgumentError)
|
266
|
+
end
|
267
|
+
|
268
|
+
|
269
|
+
specify "should be able to be rebooted when provided with an :instance_id" do
|
270
|
+
@ec2.expects(:make_request).with('RebootInstances', {"InstanceId.1"=>"i-2ea64347", "InstanceId.2"=>"i-21a64348"}).
|
271
|
+
returns stub(:body => @reboot_instances_response_body, :is_a? => true)
|
272
|
+
@ec2.reboot_instances( :instance_id => ["i-2ea64347", "i-21a64348"] ).class.should.equal EC2::Response
|
273
|
+
end
|
274
|
+
|
275
|
+
|
276
|
+
specify "method terminate_instances should raise an exception when called without nil/empty string arguments" do
|
277
|
+
lambda { @ec2.terminate_instances() }.should.raise(EC2::ArgumentError)
|
278
|
+
lambda { @ec2.terminate_instances( :instance_id => nil ) }.should.raise(EC2::ArgumentError)
|
279
|
+
lambda { @ec2.terminate_instances( :instance_id => "" ) }.should.raise(EC2::ArgumentError)
|
280
|
+
end
|
281
|
+
|
282
|
+
|
283
|
+
specify "should be able to be terminated when provided with an :instance_id" do
|
284
|
+
@ec2.stubs(:make_request).with('TerminateInstances', {"InstanceId.1"=>"i-28a64341", "InstanceId.2"=>"i-21a64348"}).
|
285
|
+
returns stub(:body => @terminate_instances_response_body, :is_a? => true)
|
286
|
+
@ec2.terminate_instances( :instance_id => ["i-28a64341", "i-21a64348"] ).class.should.equal EC2::Response
|
287
|
+
|
288
|
+
@response = @ec2.terminate_instances( :instance_id => ["i-28a64341", "i-21a64348"] )
|
289
|
+
|
290
|
+
@response.instancesSet.item[0].instanceId.should.equal "i-28a64341"
|
291
|
+
@response.instancesSet.item[0].shutdownState.code.should.equal "32"
|
292
|
+
@response.instancesSet.item[0].shutdownState.name.should.equal "shutting-down"
|
293
|
+
@response.instancesSet.item[0].previousState.code.should.equal "0"
|
294
|
+
@response.instancesSet.item[0].previousState.name.should.equal "pending"
|
295
|
+
|
296
|
+
@response.instancesSet.item[1].instanceId.should.equal "i-21a64348"
|
297
|
+
@response.instancesSet.item[1].shutdownState.code.should.equal "32"
|
298
|
+
@response.instancesSet.item[1].shutdownState.name.should.equal "shutting-down"
|
299
|
+
@response.instancesSet.item[1].previousState.code.should.equal "0"
|
300
|
+
@response.instancesSet.item[1].previousState.name.should.equal "pending"
|
301
|
+
end
|
302
|
+
|
303
|
+
end
|