grempe-amazon-ec2 0.2.14 → 0.2.15
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/README.rdoc +20 -11
- data/lib/EC2/availability_zones.rb +42 -0
- data/test/test_EC2_availability_zones.rb +49 -0
- data/test/test_helper.rb +1 -1
- metadata +8 -6
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -32,20 +32,29 @@ The following gems should be installed automatically as part of your install of
|
|
32
32
|
|
33
33
|
=== Install the amazon-ec2 gem
|
34
34
|
|
35
|
+
# ONE TIME ONLY
|
36
|
+
# It is highly recommended that you are running RubyGems version >= 1.2.0
|
37
|
+
# See : http://blog.segment7.net/articles/2008/06/21/rubygems-1-2-0
|
38
|
+
sudo gem update --system
|
39
|
+
|
35
40
|
# ONE TIME ONLY
|
36
41
|
# Execute this on each machine where you install gems to add GitHub as a gem source
|
37
42
|
# Do this only once or you'll end up with multiple entries in 'gem sources'
|
38
43
|
gem sources -a http://gems.github.com/
|
39
44
|
|
40
|
-
#
|
41
|
-
|
42
|
-
# Say 'Y' to remove all previous versions and all binaries when prompted. It won't hurt to do
|
43
|
-
# this in any case.
|
44
|
-
sudo gem uninstall amazon-ec2
|
45
|
+
# Install the stable release gem from RubyForge
|
46
|
+
sudo gem install amazon-ec2
|
45
47
|
|
46
|
-
#
|
48
|
+
# OR
|
49
|
+
|
50
|
+
# Install the gem from the GitHub bleeding edge as a normal runtime install
|
47
51
|
sudo gem install grempe-amazon-ec2
|
48
52
|
|
53
|
+
# OR
|
54
|
+
|
55
|
+
# Install the gem from the GitHub bleeding edge with all developer dependencies
|
56
|
+
sudo gem install grempe-amazon-ec2 --development
|
57
|
+
|
49
58
|
== Using amazon-ec2
|
50
59
|
|
51
60
|
The library exposes one main interface class EC2::Base. It is through an instance of this class that you will perform all the operations for using the EC2 service including query string header signing.
|
@@ -147,15 +156,15 @@ If you're not in front of a terminal shell now (perhaps you’re browsing this s
|
|
147
156
|
Try out the following bit of code. This should walk through each image returned by a call to #describe_images and print out its key data. Note in the example below that you cannot walk through the results of the #describe_images call with the '.each' iterator (You’ll get errors if you try). You need to instead walk through the Array of items which are in the 'imagesSet' embedded in the response. This reflects exactly the XML hierarchy of data returned from EC2 which we parse to Ruby OpenStruct objects (EC2::Response).
|
148
157
|
|
149
158
|
#!/usr/bin/env ruby
|
150
|
-
|
159
|
+
|
151
160
|
require 'rubygems'
|
152
161
|
require 'ec2'
|
153
|
-
|
162
|
+
|
154
163
|
ACCESS_KEY_ID = '--YOUR AWS ACCESS KEY ID--'
|
155
164
|
SECRET_ACCESS_KEY = '--YOUR AWS SECRET ACCESS KEY--'
|
156
|
-
|
165
|
+
|
157
166
|
ec2 = EC2::Base.new(:access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY)
|
158
|
-
|
167
|
+
|
159
168
|
puts "----- listing images owned by 'amazon' -----"
|
160
169
|
ec2.describe_images(:owner_id => "amazon").imagesSet.item.each do |image|
|
161
170
|
# OpenStruct objects have members!
|
@@ -235,7 +244,7 @@ One of the key benefits of this new version of the library is that all responses
|
|
235
244
|
|
236
245
|
$ ec2sh
|
237
246
|
>> puts @ec2.describe_images(:owner_id => 'amazon').xml
|
238
|
-
|
247
|
+
|
239
248
|
<?xml version="1.0"?>
|
240
249
|
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19/">
|
241
250
|
<imagesSet>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:grempe@rubyforge.org)
|
6
|
+
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://amazon-ec2.rubyforge.org
|
9
|
+
#++
|
10
|
+
|
11
|
+
module EC2
|
12
|
+
|
13
|
+
class Base
|
14
|
+
|
15
|
+
#Amazon Developer Guide Docs:
|
16
|
+
#
|
17
|
+
# The DescribeAvailabilityZones operation describes availability zones that are currently
|
18
|
+
# available to the account and their states.
|
19
|
+
#
|
20
|
+
# An optional list of zone names can be passed.
|
21
|
+
#
|
22
|
+
#Required Arguments:
|
23
|
+
#
|
24
|
+
# none
|
25
|
+
#
|
26
|
+
#Optional Arguments:
|
27
|
+
#
|
28
|
+
# :zone_name => Array (default : [])
|
29
|
+
#
|
30
|
+
|
31
|
+
def describe_availability_zones( options = {} )
|
32
|
+
|
33
|
+
options = { :zone_name => [] }.merge(options)
|
34
|
+
|
35
|
+
params = pathlist("ZoneName", options[:zone_name] )
|
36
|
+
|
37
|
+
return response_generator(:action => "DescribeAvailabilityZones", :params => params)
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#--
|
2
|
+
# Amazon Web Services EC2 Query API Ruby library
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: amazon-ec2
|
5
|
+
# Author:: Glenn Rempe (mailto:grempe@rubyforge.org)
|
6
|
+
# Copyright:: Copyright (c) 2007-2008 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 availability zones" 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_availability_zones_response_body = <<-RESPONSE
|
19
|
+
<DescribeAvailabilityZonesResponse xmlns="http://ec2.amazonaws.com/doc/2008-02-01/">
|
20
|
+
<availabilityZoneInfo>
|
21
|
+
<item>
|
22
|
+
<zoneName>us-east-1a</zoneName>
|
23
|
+
<zoneState>available</zoneState>
|
24
|
+
</item>
|
25
|
+
<item>
|
26
|
+
<zoneName>us-east-1b</zoneName>
|
27
|
+
<zoneState>available</zoneState>
|
28
|
+
</item>
|
29
|
+
</availabilityZoneInfo>
|
30
|
+
</DescribeAvailabilityZonesResponse>
|
31
|
+
RESPONSE
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
specify "should be able to be described with describe_availability_zones" do
|
36
|
+
@ec2.stubs(:make_request).with('DescribeAvailabilityZones', { "ZoneName.1" => "us-east-1a", "ZoneName.2" => "us-east-1b" }).
|
37
|
+
returns stub(:body => @describe_availability_zones_response_body, :is_a? => true)
|
38
|
+
@ec2.describe_availability_zones( :zone_name => ["us-east-1a", "us-east-1b"] ).should.be.an.instance_of EC2::Response
|
39
|
+
|
40
|
+
response = @ec2.describe_availability_zones( :zone_name => ["us-east-1a", "us-east-1b"] )
|
41
|
+
|
42
|
+
response.availabilityZoneInfo.item[0].zoneName.should.equal "us-east-1a"
|
43
|
+
response.availabilityZoneInfo.item[0].zoneState.should.equal "available"
|
44
|
+
|
45
|
+
response.availabilityZoneInfo.item[1].zoneName.should.equal "us-east-1b"
|
46
|
+
response.availabilityZoneInfo.item[1].zoneState.should.equal "available"
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grempe-amazon-ec2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glenn Rempe
|
@@ -9,7 +9,7 @@ autorequire: EC2
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 1.0.11
|
23
23
|
version:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
name: mocha
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
requirements:
|
29
29
|
- - ">="
|
30
30
|
- !ruby/object:Gem::Version
|
31
|
-
version:
|
31
|
+
version: 0.9.0
|
32
32
|
version:
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: test-spec
|
@@ -37,7 +37,7 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.9.0
|
41
41
|
version:
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rcov
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
49
|
+
version: 0.8.1.2.0
|
50
50
|
version:
|
51
51
|
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.
|
52
52
|
email: glenn.rempe@gmail.com
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- CHANGELOG
|
67
67
|
- Rakefile
|
68
68
|
- lib/EC2
|
69
|
+
- lib/EC2/availability_zones.rb
|
69
70
|
- lib/EC2/console.rb
|
70
71
|
- lib/EC2/elastic_ips.rb
|
71
72
|
- lib/EC2/exceptions.rb
|
@@ -78,6 +79,7 @@ files:
|
|
78
79
|
- lib/EC2/security_groups.rb
|
79
80
|
- lib/EC2.rb
|
80
81
|
- test/test_EC2.rb
|
82
|
+
- test/test_EC2_availability_zones.rb
|
81
83
|
- test/test_EC2_console.rb
|
82
84
|
- test/test_EC2_elastic_ips.rb
|
83
85
|
- test/test_EC2_image_attributes.rb
|