rsanheim-amazon-ec2 0.3.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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: rsanheim-amazon-ec2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.6.2
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.us
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/grempe/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