amazon-ec2 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,8 @@
1
- === 0.2.0 2007-06-01
1
+
2
+ === 0.2.1 2007-07-03
3
+ * Some minor changes to the RDocs and README.txt
4
+
5
+ === 0.2.0 2007-07-03
2
6
 
3
7
  * MAJOR library changes : THESE CHANGES ARE NOT BACKWARD COMPATIBLE!! You will need to update
4
8
  the way in which you make calls, handle responses, and rescue exceptions from this library.
data/README.txt CHANGED
@@ -6,7 +6,7 @@ Amazon Web Services offers a compute power on demand capability known as the Ela
6
6
 
7
7
  This 'amazon-ec2' Ruby Gem is an interface library that can be used to interact with the Amazon EC2 system using the Query API (No SOAP please...).
8
8
 
9
- For more information please visit the project homepage at: http://amazon-ec2.rubyforge.org or the EC2 website at http://aws.amazon.com/ec2
9
+ For the most complete and up-to date README information please visit the project homepage at: http://amazon-ec2.rubyforge.org or the EC2 website at http://aws.amazon.com/ec2
10
10
 
11
11
 
12
12
  == Installation
@@ -34,48 +34,90 @@ The public methods on EC2::Base closely mirror the EC2 Query API, and as such th
34
34
 
35
35
  === Ruby script usage example:
36
36
 
37
- #!/usr/bin/env ruby
38
-
39
- require 'rubygems'
40
- require 'ec2'
41
-
42
- ACCESS_KEY_ID = '--YOUR AWS ACCESS KEY ID--'
43
- SECRET_ACCESS_KEY = '--YOUR AWS SECRET ACCESS KEY--'
44
-
45
- ec2 = EC2::Base.new(ACCESS_KEY_ID, SECRET_ACCESS_KEY)
46
-
47
- puts "----- listing images -----"
48
- ec2.describe_images.each do |image|
49
- image.members.each do |member|
50
- puts "#{member} => #{image[member]}"
51
- end
52
- end
37
+ 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).
38
+
39
+ #!/usr/bin/env ruby
40
+
41
+ require 'rubygems'
42
+ require 'ec2'
43
+
44
+ ACCESS_KEY_ID = '--YOUR AWS ACCESS KEY ID--'
45
+ SECRET_ACCESS_KEY = '--YOUR AWS SECRET ACCESS KEY--'
46
+
47
+ ec2 = EC2::Base.new(:access_key_id => ACCESS_KEY_ID, :secret_access_key => SECRET_ACCESS_KEY)
48
+
49
+ puts "----- listing images owned by 'amazon' -----"
50
+ ec2.describe_images(:owner_id => "amazon").imagesSet.item.each do |image|
51
+ # OpenStruct objects have members!
52
+ image.members.each do |member|
53
+ puts "#{member} => #{image[member]}"
54
+ end
55
+ end
53
56
 
54
57
  === Ruby on Rails usage example:
55
58
 
56
59
  <b>config/environment.rb</b>
57
60
 
58
- require 'EC2'
61
+ # Require the amazon-ec2 gem and make its methods available in your Rails app
62
+ # Put this at the bottom of your environment.rb
63
+ require 'EC2'
59
64
 
60
65
  <b>app/controllers/my_controller.rb</b>
61
66
 
62
- class MyController < ApplicationController
63
- def index
64
- # Setup connection to Amazon EC2
65
- ec2 = EC2::Base.new("YOUR AWS ACCESS KEY ID", "YOUR AWS SECRET ACCESS KEY")
66
- @ec2_images = ec2.describe_images()
67
- end
68
- end
69
-
67
+ [some controller code ...]
68
+
69
+ ec2 = EC2::Base.new(:access_key_id => "YOUR_AWS_ACCESS_KEY_ID", :secret_access_key => "YOUR_AWS_SECRET_ACCESS_KEY")
70
+
71
+ # get ALL public images
72
+ @ec2_images = ec2.describe_images().imagesSet.item
73
+
74
+ # Get info on all public EC2 images created by the Amazon EC2 team.
75
+ @ec2_images_amazon = ec2.describe_images(:owner_id => "amazon").imagesSet.item
76
+
77
+ [some more controller code ...]
78
+
79
+
70
80
  <b>app/views/my/index.rhtml</b>
71
81
 
72
- <% for image in @ec2_images %>
73
- <% for member in image.members %>
74
- <%= "#{member} => #{image[member]}" %><br />
75
- <% end %>
76
- <br />
77
- <% end %>
78
-
82
+ <h1>EC2 Test#index</h1>
83
+
84
+ <h1>Sample 1 - debug() view</h1>
85
+
86
+ <%= debug(@ec2_images_amazon) %>
87
+
88
+ <h1>Sample 2 - Build a table</h1>
89
+
90
+ <table border='1'>
91
+ <tr>
92
+ <th>image.imageId</th>
93
+ <th>image.imageLocation</th>
94
+ <th>image.imageOwnerId</th>
95
+ <th>image.imageState</th>
96
+ <th>image.isPublic</th>
97
+ </tr>
98
+
99
+ <% for image in @ec2_images_amazon %>
100
+ <tr>
101
+ <td><%=h image.imageId %></td>
102
+ <td><%=h image.imageLocation %></td>
103
+ <td><%=h image.imageOwnerId %></td>
104
+ <td><%=h image.imageState %></td>
105
+ <td><%=h image.isPublic %></td>
106
+ </tr>
107
+ <% end %>
108
+ </table>
109
+
110
+ <h1>Sample 3 - Iterate</h1>
111
+
112
+ <% @ec2_images_amazon.each do |image| %>
113
+ <% image.each_pair do |key, value| %>
114
+ <% unless key == 'parent' %>
115
+ <%= "#{key} => #{value}" %><br />
116
+ <% end %>
117
+ <% end %>
118
+ <br />
119
+ <% end %>
120
+
79
121
 
80
122
  == Additional Resources
81
123
 
@@ -12,7 +12,7 @@ module EC2 #:nodoc:
12
12
  module VERSION #:nodoc:
13
13
  MAJOR = 0
14
14
  MINOR = 2
15
- TINY = 0
15
+ TINY = 1
16
16
  STRING = [MAJOR, MINOR, TINY].join('.')
17
17
  end
18
18
  end
@@ -33,7 +33,7 @@
33
33
  <h1>Amazon Web Services EC2 Ruby Gem</h1>
34
34
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/amazon-ec2"; return false'>
35
35
  Get Version
36
- <a href="http://rubyforge.org/projects/amazon-ec2" class="numbers">0.2.0</a>
36
+ <a href="http://rubyforge.org/projects/amazon-ec2" class="numbers">0.2.1</a>
37
37
  </div>
38
38
  <h2>&#x2192; &#8216;amazon-ec2&#8217;</h2>
39
39
 
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: amazon-ec2
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.0
6
+ version: 0.2.1
7
7
  date: 2007-07-03 00:00:00 -07:00
8
8
  summary: An interface library that allows Ruby or Ruby on Rails applications to easily connect to the HTTP 'Query API' for the Amazon Web Services Elastic Compute Cloud (EC2) and manipulate server instances.
9
9
  require_paths: