kunley-amazon-ec2 0.3.4

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.
@@ -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,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kunley-amazon-ec2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.4
5
+ platform: ruby
6
+ authors:
7
+ - Glenn Rempe
8
+ autorequire: EC2
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-11 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: xml-simple
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.11
23
+ version:
24
+ 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.
25
+ email: glenn.rempe@gmail.com
26
+ executables:
27
+ - ec2-gem-example.rb
28
+ - ec2sh
29
+ - setup.rb
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README.rdoc
34
+ - CHANGELOG
35
+ - LICENSE
36
+ files:
37
+ - README.rdoc
38
+ - LICENSE
39
+ - CHANGELOG
40
+ - Rakefile
41
+ - lib/EC2
42
+ - lib/EC2/availability_zones.rb
43
+ - lib/EC2/console.rb
44
+ - lib/EC2/elastic_ips.rb
45
+ - lib/EC2/exceptions.rb
46
+ - lib/EC2/image_attributes.rb
47
+ - lib/EC2/images.rb
48
+ - lib/EC2/instances.rb
49
+ - lib/EC2/keypairs.rb
50
+ - lib/EC2/products.rb
51
+ - lib/EC2/responses.rb
52
+ - lib/EC2/security_groups.rb
53
+ - lib/EC2/snapshots.rb
54
+ - lib/EC2/volumes.rb
55
+ - lib/EC2.rb
56
+ - test/test_EC2.rb
57
+ - test/test_EC2_availability_zones.rb
58
+ - test/test_EC2_console.rb
59
+ - test/test_EC2_elastic_ips.rb
60
+ - test/test_EC2_image_attributes.rb
61
+ - test/test_EC2_images.rb
62
+ - test/test_EC2_instances.rb
63
+ - test/test_EC2_keypairs.rb
64
+ - test/test_EC2_products.rb
65
+ - test/test_EC2_responses.rb
66
+ - test/test_EC2_security_groups.rb
67
+ - test/test_EC2_snapshots.rb
68
+ - test/test_EC2_volumes.rb
69
+ - test/test_helper.rb
70
+ has_rdoc: true
71
+ homepage: http://github.com/grempe/amazon-ec2/
72
+ post_install_message:
73
+ rdoc_options:
74
+ - --quiet
75
+ - --title
76
+ - amazon-ec2 documentation
77
+ - --opname
78
+ - index.html
79
+ - --line-numbers
80
+ - --main
81
+ - README.rdoc
82
+ - --inline-source
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.2.0
101
+ signing_key:
102
+ specification_version: 2
103
+ 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.
104
+ test_files:
105
+ - test/test_EC2.rb
106
+ - test/test_EC2_availability_zones.rb
107
+ - test/test_EC2_console.rb
108
+ - test/test_EC2_elastic_ips.rb
109
+ - test/test_EC2_image_attributes.rb
110
+ - test/test_EC2_images.rb
111
+ - test/test_EC2_instances.rb
112
+ - test/test_EC2_keypairs.rb
113
+ - test/test_EC2_products.rb
114
+ - test/test_EC2_responses.rb
115
+ - test/test_EC2_s3_xmlsimple.rb
116
+ - test/test_EC2_security_groups.rb
117
+ - test/test_EC2_snapshots.rb
118
+ - test/test_EC2_volumes.rb
119
+ - test/test_helper.rb