kerryb-amazon-ec2 0.3.6
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/CHANGELOG +265 -0
- data/LICENSE +66 -0
- data/README.rdoc +322 -0
- data/Rakefile +35 -0
- data/bin/ec2-gem-example.rb +67 -0
- data/bin/ec2sh +62 -0
- data/bin/setup.rb +25 -0
- data/lib/EC2/availability_zones.rb +41 -0
- data/lib/EC2/console.rb +44 -0
- data/lib/EC2/elastic_ips.rb +153 -0
- data/lib/EC2/exceptions.rb +147 -0
- data/lib/EC2/image_attributes.rb +166 -0
- data/lib/EC2/images.rb +134 -0
- data/lib/EC2/instances.rb +213 -0
- data/lib/EC2/keypairs.rb +94 -0
- data/lib/EC2/products.rb +43 -0
- data/lib/EC2/responses.rb +64 -0
- data/lib/EC2/security_groups.rb +232 -0
- data/lib/EC2/snapshots.rb +94 -0
- data/lib/EC2/volumes.rb +170 -0
- data/lib/EC2.rb +270 -0
- data/test/test_EC2.rb +68 -0
- data/test/test_EC2_availability_zones.rb +49 -0
- data/test/test_EC2_console.rb +54 -0
- data/test/test_EC2_elastic_ips.rb +144 -0
- data/test/test_EC2_image_attributes.rb +238 -0
- data/test/test_EC2_images.rb +197 -0
- data/test/test_EC2_instances.rb +336 -0
- data/test/test_EC2_keypairs.rb +123 -0
- data/test/test_EC2_products.rb +48 -0
- data/test/test_EC2_responses.rb +52 -0
- data/test/test_EC2_s3_xmlsimple.rb +80 -0
- data/test/test_EC2_security_groups.rb +205 -0
- data/test/test_EC2_snapshots.rb +83 -0
- data/test/test_EC2_volumes.rb +142 -0
- data/test/test_helper.rb +19 -0
- metadata +120 -0
@@ -0,0 +1,205 @@
|
|
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 "EC2 security groups " do
|
14
|
+
|
15
|
+
setup do
|
16
|
+
@ec2 = EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@create_security_group_response_body = <<-RESPONSE
|
19
|
+
<CreateSecurityGroupResponse xmlns="http://ec2.amazonaws.com/doc/2007-03-01">
|
20
|
+
<return>true</return>
|
21
|
+
</CreateSecurityGroupResponse>
|
22
|
+
RESPONSE
|
23
|
+
|
24
|
+
@delete_security_group_response_body = <<-RESPONSE
|
25
|
+
<DeleteSecurityGroupResponse xmlns="http://ec2.amazonaws.com/doc/2007-03-01">
|
26
|
+
<return>true</return>
|
27
|
+
</DeleteSecurityGroupResponse>
|
28
|
+
RESPONSE
|
29
|
+
|
30
|
+
@describe_security_groups_response_body = <<-RESPONSE
|
31
|
+
<DescribeSecurityGroupsResponse xm-lns="http://ec2.amazonaws.com/doc/2007-03-01">
|
32
|
+
<securityGroupInfo>
|
33
|
+
<item>
|
34
|
+
<ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>
|
35
|
+
<groupName>WebServers</groupName>
|
36
|
+
<groupDescription>Web</groupDescription>
|
37
|
+
<ipPermissions>
|
38
|
+
<item>
|
39
|
+
<ipProtocol>tcp</ipProtocol>
|
40
|
+
<fromPort>80</fromPort>
|
41
|
+
<toPort>80</toPort>
|
42
|
+
<groups/>
|
43
|
+
<ipRanges>
|
44
|
+
<item>
|
45
|
+
<cidrIp>0.0.0.0/0</cidrIp>
|
46
|
+
</item>
|
47
|
+
</ipRanges>
|
48
|
+
</item>
|
49
|
+
</ipPermissions>
|
50
|
+
</item>
|
51
|
+
<item>
|
52
|
+
<ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>
|
53
|
+
<groupName>RangedPortsBySource</groupName>
|
54
|
+
<groupDescription>A</groupDescription>
|
55
|
+
<ipPermissions>
|
56
|
+
<item>
|
57
|
+
<ipProtocol>tcp</ipProtocol>
|
58
|
+
<fromPort>6000</fromPort>
|
59
|
+
<toPort>7000</toPort>
|
60
|
+
<groups/>
|
61
|
+
<ipRanges/>
|
62
|
+
</item>
|
63
|
+
</ipPermissions>
|
64
|
+
</item>
|
65
|
+
</securityGroupInfo>
|
66
|
+
</DescribeSecurityGroupsResponse>
|
67
|
+
RESPONSE
|
68
|
+
|
69
|
+
@authorize_security_group_ingress_response_body = <<-RESPONSE
|
70
|
+
<AuthorizeSecurityGroupIngressResponse xm-lns="http://ec2.amazonaws.com/doc/2007-03-01">
|
71
|
+
<return>true</return>
|
72
|
+
</AuthorizeSecurityGroupIngressResponse>
|
73
|
+
RESPONSE
|
74
|
+
|
75
|
+
@revoke_security_group_ingress_response_body = <<-RESPONSE
|
76
|
+
<RevokeSecurityGroupIngressResponse xm-lns="http://ec2.amazonaws.com/doc/2007-03-01">
|
77
|
+
<return>true</return>
|
78
|
+
</RevokeSecurityGroupIngressResponse>
|
79
|
+
RESPONSE
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
specify "should be able to be created" do
|
85
|
+
@ec2.stubs(:make_request).with('CreateSecurityGroup', {"GroupName"=>"WebServers", "GroupDescription"=>"Web"}).
|
86
|
+
returns stub(:body => @create_security_group_response_body, :is_a? => true)
|
87
|
+
@ec2.create_security_group( :group_name => "WebServers", :group_description => "Web" ).should.be.an.instance_of Hash
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
specify "method create_security_group should reject bad arguments" do
|
92
|
+
@ec2.stubs(:make_request).with('CreateSecurityGroup', {"GroupName"=>"WebServers", "GroupDescription"=>"Web"}).
|
93
|
+
returns stub(:body => @create_security_group_response_body, :is_a? => true)
|
94
|
+
|
95
|
+
lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => "Web" ) }.should.not.raise(EC2::ArgumentError)
|
96
|
+
lambda { @ec2.create_security_group() }.should.raise(EC2::ArgumentError)
|
97
|
+
|
98
|
+
# :group_name can't be nil or empty
|
99
|
+
lambda { @ec2.create_security_group( :group_name => "", :group_description => "Web" ) }.should.raise(EC2::ArgumentError)
|
100
|
+
lambda { @ec2.create_security_group( :group_name => nil, :group_description => "Web" ) }.should.raise(EC2::ArgumentError)
|
101
|
+
|
102
|
+
# :group_description can't be nil or empty
|
103
|
+
lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => "" ) }.should.raise(EC2::ArgumentError)
|
104
|
+
lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => nil ) }.should.raise(EC2::ArgumentError)
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
specify "should be able to be deleted" do
|
109
|
+
@ec2.stubs(:make_request).with('DeleteSecurityGroup', {"GroupName"=>"WebServers"}).
|
110
|
+
returns stub(:body => @delete_security_group_response_body, :is_a? => true)
|
111
|
+
@ec2.delete_security_group( :group_name => "WebServers" ).should.be.an.instance_of Hash
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
specify "method delete_security_group should reject bad arguments" do
|
116
|
+
@ec2.stubs(:make_request).with('DeleteSecurityGroup', {"GroupName"=>"WebServers"}).
|
117
|
+
returns stub(:body => @delete_security_group_response_body, :is_a? => true)
|
118
|
+
|
119
|
+
lambda { @ec2.delete_security_group( :group_name => "WebServers" ) }.should.not.raise(EC2::ArgumentError)
|
120
|
+
lambda { @ec2.delete_security_group() }.should.raise(EC2::ArgumentError)
|
121
|
+
|
122
|
+
# :group_name can't be nil or empty
|
123
|
+
lambda { @ec2.delete_security_group( :group_name => "" ) }.should.raise(EC2::ArgumentError)
|
124
|
+
lambda { @ec2.delete_security_group( :group_name => nil ) }.should.raise(EC2::ArgumentError)
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
specify "should be able to be described with describe_security_groups" do
|
129
|
+
@ec2.stubs(:make_request).with('DescribeSecurityGroups', { "GroupName.1" => "WebServers", "GroupName.2" => "RangedPortsBySource" }).
|
130
|
+
returns stub(:body => @describe_security_groups_response_body, :is_a? => true)
|
131
|
+
@ec2.describe_security_groups( :group_name => ["WebServers", "RangedPortsBySource"] ).should.be.an.instance_of Hash
|
132
|
+
|
133
|
+
response = @ec2.describe_security_groups( :group_name => ["WebServers", "RangedPortsBySource"] )
|
134
|
+
|
135
|
+
response.securityGroupInfo.item[0].ownerId.should.equal "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM"
|
136
|
+
response.securityGroupInfo.item[0].groupName.should.equal "WebServers"
|
137
|
+
response.securityGroupInfo.item[0].groupDescription.should.equal "Web"
|
138
|
+
response.securityGroupInfo.item[0].ipPermissions.item[0].ipProtocol.should.equal "tcp"
|
139
|
+
response.securityGroupInfo.item[0].ipPermissions.item[0].fromPort.should.equal "80"
|
140
|
+
response.securityGroupInfo.item[0].ipPermissions.item[0].toPort.should.equal "80"
|
141
|
+
response.securityGroupInfo.item[0].ipPermissions.item[0].groups.should.be.nil
|
142
|
+
response.securityGroupInfo.item[0].ipPermissions.item[0].ipRanges.item[0].cidrIp.should.equal "0.0.0.0/0"
|
143
|
+
|
144
|
+
response.securityGroupInfo.item[1].ownerId.should.equal "UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM"
|
145
|
+
response.securityGroupInfo.item[1].groupName.should.equal "RangedPortsBySource"
|
146
|
+
response.securityGroupInfo.item[1].groupDescription.should.equal "A"
|
147
|
+
response.securityGroupInfo.item[1].ipPermissions.item[0].ipProtocol.should.equal "tcp"
|
148
|
+
response.securityGroupInfo.item[1].ipPermissions.item[0].fromPort.should.equal "6000"
|
149
|
+
response.securityGroupInfo.item[1].ipPermissions.item[0].toPort.should.equal "7000"
|
150
|
+
response.securityGroupInfo.item[1].ipPermissions.item[0].groups.should.be.nil
|
151
|
+
response.securityGroupInfo.item[1].ipPermissions.item[0].ipRanges.should.be.nil
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
specify "method describe_security_groups should reject bad arguments" do
|
156
|
+
@ec2.stubs(:make_request).with('DescribeSecurityGroups', {"GroupName.1"=>"WebServers"}).
|
157
|
+
returns stub(:body => @describe_security_groups_response_body, :is_a? => true)
|
158
|
+
|
159
|
+
lambda { @ec2.describe_security_groups( :group_name => "WebServers" ) }.should.not.raise(EC2::ArgumentError)
|
160
|
+
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
specify "permissions should be able to be added to a security group with authorize_security_group_ingress." do
|
165
|
+
@ec2.stubs(:make_request).with('AuthorizeSecurityGroupIngress', { "GroupName"=>"WebServers",
|
166
|
+
"IpProtocol"=>"tcp",
|
167
|
+
"FromPort"=>"8000",
|
168
|
+
"ToPort"=>"80",
|
169
|
+
"CidrIp"=>"0.0.0.0/24",
|
170
|
+
"SourceSecurityGroupName"=>"Source SG Name",
|
171
|
+
"SourceSecurityGroupOwnerId"=>"123"}).
|
172
|
+
returns stub(:body => @authorize_security_group_ingress_response_body, :is_a? => true)
|
173
|
+
|
174
|
+
@ec2.authorize_security_group_ingress( :group_name => "WebServers",
|
175
|
+
:ip_protocol => "tcp",
|
176
|
+
:from_port => "8000",
|
177
|
+
:to_port => "80",
|
178
|
+
:cidr_ip => "0.0.0.0/24",
|
179
|
+
:source_security_group_name => "Source SG Name",
|
180
|
+
:source_security_group_owner_id => "123"
|
181
|
+
).should.be.an.instance_of Hash
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
specify "permissions should be able to be revoked from a security group with revoke_security_group_ingress." do
|
186
|
+
@ec2.stubs(:make_request).with('RevokeSecurityGroupIngress', { "GroupName"=>"WebServers",
|
187
|
+
"IpProtocol"=>"tcp",
|
188
|
+
"FromPort"=>"8000",
|
189
|
+
"ToPort"=>"80",
|
190
|
+
"CidrIp"=>"0.0.0.0/24",
|
191
|
+
"SourceSecurityGroupName"=>"Source SG Name",
|
192
|
+
"SourceSecurityGroupOwnerId"=>"123"}).
|
193
|
+
returns stub(:body => @revoke_security_group_ingress_response_body, :is_a? => true)
|
194
|
+
|
195
|
+
@ec2.revoke_security_group_ingress( :group_name => "WebServers",
|
196
|
+
:ip_protocol => "tcp",
|
197
|
+
:from_port => "8000",
|
198
|
+
:to_port => "80",
|
199
|
+
:cidr_ip => "0.0.0.0/24",
|
200
|
+
:source_security_group_name => "Source SG Name",
|
201
|
+
:source_security_group_owner_id => "123"
|
202
|
+
).should.be.an.instance_of Hash
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library, EBS snapshots 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
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 snaphots " do
|
14
|
+
|
15
|
+
setup do
|
16
|
+
@ec2 = EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@describe_snapshots_response_body = <<-RESPONSE
|
19
|
+
<DescribeSnapshotsResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
20
|
+
<snapshotId>snap-78a54011</snapshotId>
|
21
|
+
<volumeId>vol-4d826724</volumeId>
|
22
|
+
<status>pending</status>
|
23
|
+
<startTime>2008-05-07T12:51:50.000Z</startTime>
|
24
|
+
<progress>80%</progress>
|
25
|
+
</DescribeSnapshotsResponse>
|
26
|
+
RESPONSE
|
27
|
+
|
28
|
+
@create_snapshot_response_body = <<-RESPONSE
|
29
|
+
<CreateSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
30
|
+
<snapshotId>snap-78a54011</snapshotId>
|
31
|
+
<volumeId>vol-4d826724</volumeId>
|
32
|
+
<status>pending</status>
|
33
|
+
<startTime>2008-05-07T12:51:50.000Z</startTime>
|
34
|
+
<progress></progress>
|
35
|
+
</CreateSnapshotResponse>
|
36
|
+
RESPONSE
|
37
|
+
|
38
|
+
@delete_snapshot_response_body = <<-RESPONSE
|
39
|
+
<DeleteSnapshotResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
40
|
+
<return>true</return>
|
41
|
+
</DeleteSnapshotResponse>
|
42
|
+
RESPONSE
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
specify "should be able to be described with describe_snapshots" do
|
48
|
+
@ec2.stubs(:make_request).with('DescribeSnapshots', {"SnapshotId.1"=>"snap-78a54011"}).
|
49
|
+
returns stub(:body => @describe_snapshots_response_body, :is_a? => true)
|
50
|
+
|
51
|
+
@ec2.describe_snapshots( :snapshot_id => "snap-78a54011" ).should.be.an.instance_of Hash
|
52
|
+
|
53
|
+
response = @ec2.describe_snapshots( :snapshot_id => "snap-78a54011" )
|
54
|
+
response.snapshotId.should.equal "snap-78a54011"
|
55
|
+
response.volumeId.should.equal "vol-4d826724"
|
56
|
+
response.status.should.equal "pending"
|
57
|
+
response.progress.should.equal "80%"
|
58
|
+
end
|
59
|
+
|
60
|
+
specify "should be able to be created with a volume_id" do
|
61
|
+
@ec2.stubs(:make_request).with('CreateSnapshot', {"VolumeId" => "vol-4d826724"}).
|
62
|
+
returns stub(:body => @create_snapshot_response_body, :is_a? => true)
|
63
|
+
|
64
|
+
@ec2.create_snapshot( :volume_id => "vol-4d826724" ).should.be.an.instance_of Hash
|
65
|
+
|
66
|
+
response = @ec2.create_snapshot( :volume_id => "vol-4d826724" )
|
67
|
+
response.snapshotId.should.equal "snap-78a54011"
|
68
|
+
response.volumeId.should.equal "vol-4d826724"
|
69
|
+
response.status.should.equal "pending"
|
70
|
+
response.progress.should.equal nil
|
71
|
+
end
|
72
|
+
|
73
|
+
specify "should be able to be deleted with a snapsot_id" do
|
74
|
+
@ec2.stubs(:make_request).with('DeleteSnapshot', {"SnapshotId" => "snap-78a54011"}).
|
75
|
+
returns stub(:body => @delete_snapshot_response_body, :is_a? => true)
|
76
|
+
|
77
|
+
@ec2.delete_snapshot( :snapshot_id => "snap-78a54011" ).should.be.an.instance_of Hash
|
78
|
+
|
79
|
+
response = @ec2.delete_snapshot( :snapshot_id => "snap-78a54011" )
|
80
|
+
response.return.should.equal "true"
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,142 @@
|
|
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
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "EC2 volumes " do
|
14
|
+
|
15
|
+
setup do
|
16
|
+
@ec2 = EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
|
17
|
+
|
18
|
+
@describe_volumes_response_body = <<-RESPONSE
|
19
|
+
<DescribeVolumesResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
20
|
+
<volumeSet>
|
21
|
+
<item>
|
22
|
+
<volumeId>vol-4282672b</volumeId>
|
23
|
+
<size>800</size>
|
24
|
+
<status>in-use</status>
|
25
|
+
<createTime>2008-05-07T11:51:50.000Z</createTime>
|
26
|
+
<attachmentSet>
|
27
|
+
<item>
|
28
|
+
<volumeId>vol-4282672b</volumeId>
|
29
|
+
<instanceId>i-6058a509</instanceId>
|
30
|
+
<size>800</size>
|
31
|
+
<status>attached</status>
|
32
|
+
<attachTime>2008-05-07T12:51:50.000Z</attachTime>
|
33
|
+
</item>
|
34
|
+
</attachmentSet>
|
35
|
+
</item>
|
36
|
+
</volumeSet>
|
37
|
+
</DescribeVolumesResponse>
|
38
|
+
RESPONSE
|
39
|
+
|
40
|
+
@create_volume_response_body = <<-RESPONSE
|
41
|
+
<CreateVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
42
|
+
<volumeId>vol-4d826724</volumeId>
|
43
|
+
<size>800</size>
|
44
|
+
<status>creating</status>
|
45
|
+
<createTime>2008-05-07T11:51:50.000Z</createTime>
|
46
|
+
<zone>us-east-1a</zone>
|
47
|
+
<snapshotId></snapshotId>
|
48
|
+
</CreateVolumeResponse>
|
49
|
+
RESPONSE
|
50
|
+
|
51
|
+
@delete_volume_response_body = <<-RESPONSE
|
52
|
+
<ReleaseAddressResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
53
|
+
<return>true</return>
|
54
|
+
</ReleaseAddressResponse>
|
55
|
+
RESPONSE
|
56
|
+
|
57
|
+
@attach_volume_response_body = <<-RESPONSE
|
58
|
+
<AttachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
59
|
+
<volumeId>vol-4d826724</volumeId>
|
60
|
+
<instanceId>i-6058a509</instanceId>
|
61
|
+
<device>/dev/sdh</device>
|
62
|
+
<status>attaching</status>
|
63
|
+
<attachTime>2008-05-07T11:51:50.000Z</attachTime>
|
64
|
+
</AttachVolumeResponse>
|
65
|
+
RESPONSE
|
66
|
+
|
67
|
+
@detach_volume_response_body = <<-RESPONSE
|
68
|
+
<DetachVolumeResponse xmlns="http://ec2.amazonaws.com/doc/2008-05-05">
|
69
|
+
<volumeId>vol-4d826724</volumeId>
|
70
|
+
<instanceId>i-6058a509</instanceId>
|
71
|
+
<device>/dev/sdh</device>
|
72
|
+
<status>detaching</status>
|
73
|
+
<attachTime>2008-05-08T11:51:50.000Z</attachTime>
|
74
|
+
</DetachVolumeResponse>
|
75
|
+
RESPONSE
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
specify "should be able to be described with describe_volumes" do
|
81
|
+
@ec2.stubs(:make_request).with('DescribeVolumes', {"VolumeId.1"=>"vol-4282672b"}).
|
82
|
+
returns stub(:body => @describe_volumes_response_body, :is_a? => true)
|
83
|
+
|
84
|
+
@ec2.describe_volumes( :volume_id => ["vol-4282672b"] ).should.be.an.instance_of Hash
|
85
|
+
|
86
|
+
response = @ec2.describe_volumes( :volume_id => ["vol-4282672b"] )
|
87
|
+
response.volumeSet.item[0].volumeId.should.equal "vol-4282672b"
|
88
|
+
response.volumeSet.item[0].attachmentSet.item[0]['size'].should.equal "800"
|
89
|
+
response.volumeSet.item[0].attachmentSet.item[0].volumeId.should.equal "vol-4282672b"
|
90
|
+
response.volumeSet.item[0].attachmentSet.item[0].instanceId.should.equal "i-6058a509"
|
91
|
+
end
|
92
|
+
|
93
|
+
specify "should be able to be created with an availability_zone with size" do
|
94
|
+
@ec2.stubs(:make_request).with('CreateVolume', {"AvailabilityZone" => "us-east-1a", "Size"=>"800", "SnapshotId"=>""}).
|
95
|
+
returns stub(:body => @create_volume_response_body, :is_a? => true)
|
96
|
+
|
97
|
+
@ec2.create_volume( :availability_zone => "us-east-1a", :size => "800" ).should.be.an.instance_of Hash
|
98
|
+
|
99
|
+
response = @ec2.create_volume( :availability_zone => "us-east-1a", :size => "800" )
|
100
|
+
response.volumeId.should.equal "vol-4d826724"
|
101
|
+
response['size'].should.equal "800"
|
102
|
+
response.status.should.equal "creating"
|
103
|
+
response.zone.should.equal "us-east-1a"
|
104
|
+
end
|
105
|
+
|
106
|
+
specify "should be able to be deleted with a volume_id" do
|
107
|
+
@ec2.stubs(:make_request).with('DeleteVolume', {"VolumeId" => "vol-4282672b"}).
|
108
|
+
returns stub(:body => @delete_volume_response_body, :is_a? => true)
|
109
|
+
|
110
|
+
@ec2.delete_volume( :volume_id => "vol-4282672b" ).should.be.an.instance_of Hash
|
111
|
+
|
112
|
+
response = @ec2.delete_volume( :volume_id => "vol-4282672b" )
|
113
|
+
response.return.should.equal "true"
|
114
|
+
end
|
115
|
+
|
116
|
+
specify "should be able to be attached with a volume_id with an instance_id with a device" do
|
117
|
+
@ec2.stubs(:make_request).with('AttachVolume', {"VolumeId" => "vol-4d826724", "InstanceId"=>"i-6058a509", "Device"=>"/dev/sdh"}).
|
118
|
+
returns stub(:body => @attach_volume_response_body, :is_a? => true)
|
119
|
+
|
120
|
+
@ec2.attach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509", :device => "/dev/sdh" ).should.be.an.instance_of Hash
|
121
|
+
|
122
|
+
response = @ec2.attach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509", :device => "/dev/sdh" )
|
123
|
+
response.volumeId.should.equal "vol-4d826724"
|
124
|
+
response.instanceId.should.equal "i-6058a509"
|
125
|
+
response.device.should.equal "/dev/sdh"
|
126
|
+
response.status.should.equal "attaching"
|
127
|
+
end
|
128
|
+
|
129
|
+
specify "should be able to be detached with a volume_id with an instance_id" do
|
130
|
+
@ec2.stubs(:make_request).with('DetachVolume', {"VolumeId" => "vol-4d826724", "InstanceId"=>"i-6058a509", "Device"=>"", "Force"=>""}).
|
131
|
+
returns stub(:body => @detach_volume_response_body, :is_a? => true)
|
132
|
+
|
133
|
+
@ec2.detach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509" ).should.be.an.instance_of Hash
|
134
|
+
|
135
|
+
response = @ec2.detach_volume( :volume_id => "vol-4d826724", :instance_id => "i-6058a509" )
|
136
|
+
response.volumeId.should.equal "vol-4d826724"
|
137
|
+
response.instanceId.should.equal "i-6058a509"
|
138
|
+
response.device.should.equal "/dev/sdh"
|
139
|
+
response.status.should.equal "detaching"
|
140
|
+
end
|
141
|
+
|
142
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
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
|
+
%w[ test/unit rubygems test/spec mocha ].each { |f|
|
12
|
+
begin
|
13
|
+
require f
|
14
|
+
rescue LoadError
|
15
|
+
abort "Unable to load required gem for test: #{f}"
|
16
|
+
end
|
17
|
+
}
|
18
|
+
|
19
|
+
require File.dirname(__FILE__) + '/../lib/EC2'
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kerryb-amazon-ec2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Glenn Rempe
|
8
|
+
autorequire: EC2
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-25 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: xml-simple
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.0.11
|
24
|
+
version:
|
25
|
+
description: An interface library that allows Ruby applications to easily connect to the HTTP 'Query API' for the Amazon Web Services Elastic Compute Cloud (EC2) and manipulate cloud servers.
|
26
|
+
email: glenn.rempe@gmail.com
|
27
|
+
executables:
|
28
|
+
- ec2-gem-example.rb
|
29
|
+
- ec2sh
|
30
|
+
- setup.rb
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- README.rdoc
|
35
|
+
- CHANGELOG
|
36
|
+
- LICENSE
|
37
|
+
files:
|
38
|
+
- README.rdoc
|
39
|
+
- LICENSE
|
40
|
+
- CHANGELOG
|
41
|
+
- Rakefile
|
42
|
+
- lib/EC2
|
43
|
+
- lib/EC2/availability_zones.rb
|
44
|
+
- lib/EC2/console.rb
|
45
|
+
- lib/EC2/elastic_ips.rb
|
46
|
+
- lib/EC2/exceptions.rb
|
47
|
+
- lib/EC2/image_attributes.rb
|
48
|
+
- lib/EC2/images.rb
|
49
|
+
- lib/EC2/instances.rb
|
50
|
+
- lib/EC2/keypairs.rb
|
51
|
+
- lib/EC2/products.rb
|
52
|
+
- lib/EC2/responses.rb
|
53
|
+
- lib/EC2/security_groups.rb
|
54
|
+
- lib/EC2/snapshots.rb
|
55
|
+
- lib/EC2/volumes.rb
|
56
|
+
- lib/EC2.rb
|
57
|
+
- test/test_EC2.rb
|
58
|
+
- test/test_EC2_availability_zones.rb
|
59
|
+
- test/test_EC2_console.rb
|
60
|
+
- test/test_EC2_elastic_ips.rb
|
61
|
+
- test/test_EC2_image_attributes.rb
|
62
|
+
- test/test_EC2_images.rb
|
63
|
+
- test/test_EC2_instances.rb
|
64
|
+
- test/test_EC2_keypairs.rb
|
65
|
+
- test/test_EC2_products.rb
|
66
|
+
- test/test_EC2_responses.rb
|
67
|
+
- test/test_EC2_security_groups.rb
|
68
|
+
- test/test_EC2_snapshots.rb
|
69
|
+
- test/test_EC2_volumes.rb
|
70
|
+
- test/test_helper.rb
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: http://github.com/kerryb/amazon-ec2/
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options:
|
75
|
+
- --quiet
|
76
|
+
- --title
|
77
|
+
- amazon-ec2 documentation
|
78
|
+
- --opname
|
79
|
+
- index.html
|
80
|
+
- --line-numbers
|
81
|
+
- --main
|
82
|
+
- README.rdoc
|
83
|
+
- --inline-source
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
version:
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: "0"
|
97
|
+
version:
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.2.0
|
102
|
+
signing_key:
|
103
|
+
specification_version: 2
|
104
|
+
summary: An interface library that allows Ruby applications to easily connect to the HTTP 'Query API' for the Amazon Web Services Elastic Compute Cloud (EC2) and manipulate cloud servers.
|
105
|
+
test_files:
|
106
|
+
- test/test_EC2.rb
|
107
|
+
- test/test_EC2_availability_zones.rb
|
108
|
+
- test/test_EC2_console.rb
|
109
|
+
- test/test_EC2_elastic_ips.rb
|
110
|
+
- test/test_EC2_image_attributes.rb
|
111
|
+
- test/test_EC2_images.rb
|
112
|
+
- test/test_EC2_instances.rb
|
113
|
+
- test/test_EC2_keypairs.rb
|
114
|
+
- test/test_EC2_products.rb
|
115
|
+
- test/test_EC2_responses.rb
|
116
|
+
- test/test_EC2_s3_xmlsimple.rb
|
117
|
+
- test/test_EC2_security_groups.rb
|
118
|
+
- test/test_EC2_snapshots.rb
|
119
|
+
- test/test_EC2_volumes.rb
|
120
|
+
- test/test_helper.rb
|