newrelic-amazon-ec2 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/.gitignore +8 -0
  2. data/.yardopts +1 -0
  3. data/ChangeLog +293 -0
  4. data/LICENSE +66 -0
  5. data/README.rdoc +354 -0
  6. data/README_dev.rdoc +12 -0
  7. data/Rakefile +101 -0
  8. data/VERSION +1 -0
  9. data/amazon-ec2.gemspec +134 -0
  10. data/bin/ec2-gem-example.rb +137 -0
  11. data/bin/ec2-gem-profile.rb +10 -0
  12. data/bin/ec2sh +62 -0
  13. data/bin/setup.rb +28 -0
  14. data/deps.rip +1 -0
  15. data/lib/AWS.rb +292 -0
  16. data/lib/AWS/Autoscaling.rb +70 -0
  17. data/lib/AWS/Autoscaling/autoscaling.rb +273 -0
  18. data/lib/AWS/Cloudwatch.rb +32 -0
  19. data/lib/AWS/Cloudwatch/monitoring.rb +89 -0
  20. data/lib/AWS/EC2.rb +33 -0
  21. data/lib/AWS/EC2/availability_zones.rb +21 -0
  22. data/lib/AWS/EC2/console.rb +23 -0
  23. data/lib/AWS/EC2/elastic_ips.rb +81 -0
  24. data/lib/AWS/EC2/image_attributes.rb +133 -0
  25. data/lib/AWS/EC2/images.rb +101 -0
  26. data/lib/AWS/EC2/instances.rb +212 -0
  27. data/lib/AWS/EC2/keypairs.rb +61 -0
  28. data/lib/AWS/EC2/products.rb +21 -0
  29. data/lib/AWS/EC2/security_groups.rb +183 -0
  30. data/lib/AWS/EC2/snapshots.rb +59 -0
  31. data/lib/AWS/EC2/volumes.rb +115 -0
  32. data/lib/AWS/ELB.rb +71 -0
  33. data/lib/AWS/ELB/load_balancers.rb +178 -0
  34. data/lib/AWS/exceptions.rb +122 -0
  35. data/lib/AWS/responses.rb +21 -0
  36. data/newrelic-amazon-ec2.gemspec +136 -0
  37. data/perftools/ec2prof +0 -0
  38. data/perftools/ec2prof-results.dot +132 -0
  39. data/perftools/ec2prof-results.txt +100 -0
  40. data/perftools/ec2prof.symbols +102 -0
  41. data/test/test_Autoscaling_groups.rb +336 -0
  42. data/test/test_EC2.rb +68 -0
  43. data/test/test_EC2_availability_zones.rb +49 -0
  44. data/test/test_EC2_console.rb +54 -0
  45. data/test/test_EC2_elastic_ips.rb +144 -0
  46. data/test/test_EC2_image_attributes.rb +238 -0
  47. data/test/test_EC2_images.rb +197 -0
  48. data/test/test_EC2_instances.rb +429 -0
  49. data/test/test_EC2_keypairs.rb +123 -0
  50. data/test/test_EC2_products.rb +48 -0
  51. data/test/test_EC2_responses.rb +53 -0
  52. data/test/test_EC2_s3_xmlsimple.rb +80 -0
  53. data/test/test_EC2_security_groups.rb +205 -0
  54. data/test/test_EC2_snapshots.rb +83 -0
  55. data/test/test_EC2_volumes.rb +142 -0
  56. data/test/test_ELB_load_balancers.rb +239 -0
  57. data/test/test_helper.rb +23 -0
  58. data/wsdl/2007-08-29.ec2.wsdl +1269 -0
  59. data/wsdl/2008-02-01.ec2.wsdl +1614 -0
  60. data/wsdl/2008-05-05.ec2.wsdl +2052 -0
  61. data/wsdl/2008-12-01.ec2.wsdl +2354 -0
  62. metadata +218 -0
@@ -0,0 +1,48 @@
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 "An EC2 instance " do
14
+
15
+ before do
16
+ @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
17
+
18
+ @confirm_product_instance_response_body = <<-RESPONSE
19
+ <ConfirmProductInstanceResponse xmlns="http://ec2.amazonaws.com/doc/2007-03-01">
20
+ <result>true</result>
21
+ <ownerId>254933287430</ownerId>
22
+ </ConfirmProductInstanceResponse>
23
+ RESPONSE
24
+
25
+ end
26
+
27
+
28
+ specify "should indicate whether a product code is attached to an instance" do
29
+ @ec2.stubs(:make_request).with('ConfirmProductInstance', {"ProductCode"=>"774F4FF8", "InstanceId"=>"i-10a64379"}).
30
+ returns stub(:body => @confirm_product_instance_response_body, :is_a? => true)
31
+
32
+ @ec2.confirm_product_instance( :product_code => "774F4FF8", :instance_id => "i-10a64379" ).should.be.an.instance_of Hash
33
+ response = @ec2.confirm_product_instance( :product_code => "774F4FF8", :instance_id => "i-10a64379" )
34
+ response.ownerId.should.equal "254933287430"
35
+ response.result.should.equal "true"
36
+ end
37
+
38
+
39
+ specify "method get_console_output should raise an exception when called without nil/empty string arguments" do
40
+ lambda { @ec2.confirm_product_instance() }.should.raise(AWS::ArgumentError)
41
+ lambda { @ec2.confirm_product_instance(:product_code => "774F4FF8", :instance_id => nil) }.should.raise(AWS::ArgumentError)
42
+ lambda { @ec2.confirm_product_instance(:product_code => "774F4FF8", :instance_id => "") }.should.raise(AWS::ArgumentError)
43
+ lambda { @ec2.confirm_product_instance(:product_code => nil, :instance_id => "i-10a64379") }.should.raise(AWS::ArgumentError)
44
+ lambda { @ec2.confirm_product_instance(:product_code => "", :instance_id => "i-10a64379") }.should.raise(AWS::ArgumentError)
45
+ end
46
+
47
+
48
+ end
@@ -0,0 +1,53 @@
1
+ #--
2
+ # Amazon Web Services EC2 Query API Ruby library
3
+ #
4
+ # Ruby Gem Name:: amazon-ec2
5
+ # Author:: Glenn Rempe (mailto:glenn@rempe.us)
6
+ # Copyright:: Copyright (c) 2007-2008 Glenn Rempe
7
+ # License:: Distributes under the same terms as Ruby
8
+ # Home:: http://github.com/grempe/amazon-ec2/tree/master
9
+ #++
10
+
11
+ require File.dirname(__FILE__) + '/test_helper.rb'
12
+
13
+ context "The Response classes " do
14
+
15
+
16
+ before do
17
+ @http_xml = <<-RESPONSE
18
+ <RebootInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2007-03-01">
19
+ <return>true</return>
20
+ </RebootInstancesResponse>
21
+ RESPONSE
22
+
23
+ @response = AWS::Response.parse(:xml => @http_xml)
24
+ end
25
+
26
+
27
+ specify "should show the response as a formatted string when calling #inspect" do
28
+ # sorting the response hash first since ruby 1.8.6 and ruby 1.9.1 sort the hash differently before the inspect
29
+ @response.sort.inspect.should.equal %{[[\"return\", \"true\"], [\"xmlns\", \"http://ec2.amazonaws.com/doc/2007-03-01\"]]}
30
+ end
31
+
32
+
33
+ specify "should be a Hash" do
34
+ @response.kind_of?(Hash).should.equal true
35
+ end
36
+
37
+
38
+ specify "should return its members" do
39
+ @response.keys.length.should.equal 2
40
+ test_array = ["return", "xmlns"].sort
41
+ @response.keys.sort.should.equal test_array
42
+ end
43
+
44
+
45
+ # Note: since we are now returning a hash of the xml, there should be no need for anyone to re-parse the xml.
46
+ # Therefore storing the xml on the object is a waste of memory, and is not done.
47
+ #
48
+ # specify "should return the original amazon XML response in the 'xml' attribute of the response object." do
49
+ # @response.xml.should.equal @http_xml
50
+ # end
51
+
52
+
53
+ end
@@ -0,0 +1,80 @@
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
+ # NOTE : These tests exercise amazon-ec2 when used with the aws/s3 gem
14
+ # which was demonstrating some breaking behavior. The fix was to
15
+ # add the XmlSimple option "'keeproot' => false" in responses.rb
16
+
17
+ context "EC2 aws-s3 compat test" do
18
+
19
+ before do
20
+ @ec2 = AWS::EC2::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret" )
21
+
22
+ @describe_instances_response_body = <<-RESPONSE
23
+ <DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2007-08-29">
24
+ <reservationSet>
25
+ <item>
26
+ <reservationId>r-44a5402d</reservationId>
27
+ <ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>
28
+ <groupSet>
29
+ <item>
30
+ <groupId>default</groupId>
31
+ </item>
32
+ </groupSet>
33
+ <instancesSet>
34
+ <item>
35
+ <instanceId>i-28a64341</instanceId>
36
+ <imageId>ami-6ea54007</imageId>
37
+ <instanceState>
38
+ <code>0</code>
39
+ <name>running</name>
40
+ </instanceState>
41
+ <privateDnsName>domU-12-31-35-00-1E-01.z-2.compute-1.internal</privateDnsName>
42
+ <dnsName>ec2-72-44-33-4.z-2.compute-1.amazonaws.com</dnsName>
43
+ <keyName>example-key-name</keyName>
44
+ <productCodesSet>
45
+ <item><productCode>774F4FF8</productCode></item>
46
+ </productCodesSet>
47
+ <instanceType>m1.small</instanceType>
48
+ <launchTime>2007-08-07T11:54:42.000Z</launchTime>
49
+ </item>
50
+ </instancesSet>
51
+ </item>
52
+ </reservationSet>
53
+ </DescribeInstancesResponse>
54
+ RESPONSE
55
+
56
+ end
57
+
58
+ specify "should be able to be described and return the correct Ruby response class" do
59
+ @ec2.stubs(:make_request).with('DescribeInstances', {}).
60
+ returns stub(:body => @describe_instances_response_body, :is_a? => true)
61
+ @ec2.describe_instances.should.be.an.instance_of Hash
62
+ response = @ec2.describe_instances
63
+ response.reservationSet.item[0].reservationId.should.equal "r-44a5402d"
64
+ end
65
+
66
+ specify "should be able to be described and return the correct Ruby response class when the aws/s3 lib is required" do
67
+ begin
68
+ require 'aws/s3s'
69
+ @ec2.stubs(:make_request).with('DescribeInstances', {}).
70
+ returns stub(:body => @describe_instances_response_body, :is_a? => true)
71
+ @ec2.describe_instances.should.be.an.instance_of Hash
72
+ response = @ec2.describe_instances
73
+ response.reservationSet.item[0].reservationId.should.equal "r-44a5402d"
74
+ rescue LoadError
75
+ # do nothing. no aws/s3 gem installed to test against
76
+ end
77
+ end
78
+
79
+ end
80
+
@@ -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
+ before do
16
+ @ec2 = AWS::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(AWS::ArgumentError)
96
+ lambda { @ec2.create_security_group() }.should.raise(AWS::ArgumentError)
97
+
98
+ # :group_name can't be nil or empty
99
+ lambda { @ec2.create_security_group( :group_name => "", :group_description => "Web" ) }.should.raise(AWS::ArgumentError)
100
+ lambda { @ec2.create_security_group( :group_name => nil, :group_description => "Web" ) }.should.raise(AWS::ArgumentError)
101
+
102
+ # :group_description can't be nil or empty
103
+ lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => "" ) }.should.raise(AWS::ArgumentError)
104
+ lambda { @ec2.create_security_group( :group_name => "WebServers", :group_description => nil ) }.should.raise(AWS::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(AWS::ArgumentError)
120
+ lambda { @ec2.delete_security_group() }.should.raise(AWS::ArgumentError)
121
+
122
+ # :group_name can't be nil or empty
123
+ lambda { @ec2.delete_security_group( :group_name => "" ) }.should.raise(AWS::ArgumentError)
124
+ lambda { @ec2.delete_security_group( :group_name => nil ) }.should.raise(AWS::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(AWS::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
+ before do
16
+ @ec2 = AWS::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