amazon-ec2 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +57 -50
- data/VERSION +1 -1
- data/amazon-ec2.gemspec +1 -1
- data/bin/ec2-gem-example.rb +0 -1
- data/lib/EC2/responses.rb +0 -2
- data/test/test_helper.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -32,11 +32,6 @@ 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
|
-
|
40
35
|
# ONE TIME ONLY
|
41
36
|
# Execute this on each machine where you install gems to add GitHub as a gem source
|
42
37
|
# Do this only once or you'll end up with multiple entries in 'gem sources'
|
@@ -55,6 +50,11 @@ The following gems should be installed automatically as part of your install of
|
|
55
50
|
# Install the gem from the GitHub bleeding edge with all developer dependencies
|
56
51
|
sudo gem install grempe-amazon-ec2 --development
|
57
52
|
|
53
|
+
# OR
|
54
|
+
|
55
|
+
# Install using Rip (hellorip.com) instead of RubyGems
|
56
|
+
rip install git://github.com/grempe/amazon-ec2.git
|
57
|
+
|
58
58
|
== Using amazon-ec2
|
59
59
|
|
60
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.
|
@@ -70,6 +70,8 @@ Edit the file ~/.bash_login and add the following to the existing contents:
|
|
70
70
|
|
71
71
|
export RUBYOPT="rubygems"
|
72
72
|
|
73
|
+
Why 'export RUBYOPT'? Because we leave loading libs up to you... See : http://gist.github.com/54177
|
74
|
+
|
73
75
|
# For amazon-ec2 and amazon s3 ruby gems
|
74
76
|
export AMAZON_ACCESS_KEY_ID="YOUR_ACCESS_KEY_ID"
|
75
77
|
export AMAZON_SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY_ID"
|
@@ -144,8 +146,8 @@ If you're not in front of a terminal shell now (perhaps you’re browsing this s
|
|
144
146
|
|
145
147
|
returns : an Array of EC2::Response objects, each an EC2 image and its data
|
146
148
|
>> @ec2.describe_images.imagesSet.item
|
147
|
-
>> @ec2.describe_images.imagesSet.item[0] (
|
148
|
-
>> @ec2.describe_images.imagesSet.item[0].to_s (a String representation of that
|
149
|
+
>> @ec2.describe_images.imagesSet.item[0] (a hash representing a single item in that array)
|
150
|
+
>> @ec2.describe_images.imagesSet.item[0].to_s (a String representation of that item)
|
149
151
|
|
150
152
|
>> @ec2.describe_images.imagesSet.item[0].to_s
|
151
153
|
=> "#<EC2::Response:0x100A465B4 imageId=\"ami-018e6b68\" imageLocation=\"rbuilder-online/phonehome-1.5.6-x86_10132.img.manifest.xml\" imageOwnerId=\"099034111737\" imageState=\"available\" isPublic=\"true\" parent=#<EC2::Response:0x100A469A6 ...>>"
|
@@ -177,70 +179,74 @@ Try out the following bit of code. This should walk through each image returned
|
|
177
179
|
|
178
180
|
<b>config/environment.rb</b>
|
179
181
|
|
180
|
-
|
181
|
-
|
182
|
-
|
182
|
+
Rails::Initializer.run do |config|
|
183
|
+
...
|
184
|
+
# INSERT THIS LINE IN YOUR CONFIG
|
185
|
+
config.gem "amazon-ec2", :lib => "EC2"
|
186
|
+
...
|
187
|
+
end
|
188
|
+
|
183
189
|
|
184
190
|
<b>app/controllers/my_controller.rb</b>
|
185
191
|
|
186
|
-
|
192
|
+
[some controller code ...]
|
187
193
|
|
188
|
-
|
194
|
+
ec2 = EC2::Base.new(:access_key_id => "YOUR_AWS_ACCESS_KEY_ID", :secret_access_key => "YOUR_AWS_SECRET_ACCESS_KEY")
|
189
195
|
|
190
|
-
|
191
|
-
|
196
|
+
# get ALL public images
|
197
|
+
@ec2_images = ec2.describe_images().imagesSet.item
|
192
198
|
|
193
|
-
|
194
|
-
|
199
|
+
# Get info on all public EC2 images created by the Amazon EC2 team.
|
200
|
+
@ec2_images_amazon = ec2.describe_images(:owner_id => "amazon").imagesSet.item
|
195
201
|
|
196
|
-
|
202
|
+
[some more controller code ...]
|
197
203
|
|
198
204
|
|
199
205
|
<b>app/views/my/index.rhtml</b>
|
200
206
|
|
201
|
-
|
207
|
+
<h1>EC2 Test#index</h1>
|
202
208
|
|
203
|
-
|
209
|
+
<h1>Sample 1 - debug() view</h1>
|
204
210
|
|
205
|
-
|
211
|
+
<%= debug(@ec2_images_amazon) %>
|
206
212
|
|
207
|
-
|
213
|
+
<h1>Sample 2 - Build a table</h1>
|
208
214
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
215
|
+
<table border='1'>
|
216
|
+
<tr>
|
217
|
+
<th>image.imageId</th>
|
218
|
+
<th>image.imageLocation</th>
|
219
|
+
<th>image.imageOwnerId</th>
|
220
|
+
<th>image.imageState</th>
|
221
|
+
<th>image.isPublic</th>
|
222
|
+
</tr>
|
217
223
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
224
|
+
<% for image in @ec2_images_amazon %>
|
225
|
+
<tr>
|
226
|
+
<td><%=h image.imageId %></td>
|
227
|
+
<td><%=h image.imageLocation %></td>
|
228
|
+
<td><%=h image.imageOwnerId %></td>
|
229
|
+
<td><%=h image.imageState %></td>
|
230
|
+
<td><%=h image.isPublic %></td>
|
231
|
+
</tr>
|
232
|
+
<% end %>
|
233
|
+
</table>
|
228
234
|
|
229
|
-
|
235
|
+
<h1>Sample 3 - Iterate</h1>
|
230
236
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
237
|
+
<% @ec2_images_amazon.each do |image| %>
|
238
|
+
<% image.each_pair do |key, value| %>
|
239
|
+
<% unless key == 'parent' %>
|
240
|
+
<%= "#{key} => #{value}" %><br />
|
241
|
+
<% end %>
|
242
|
+
<% end %>
|
243
|
+
<br />
|
244
|
+
<% end %>
|
239
245
|
|
240
246
|
|
241
247
|
=== Important notes regarding the structure of EC2::Response Objects
|
242
248
|
|
243
|
-
One of the key benefits of this new version of the library is that all responses from EC2 are bundled up in a real data structure and no longer require parsing of text. The hash returned is populated directly from the XML given to us by EC2 in response to any command we issue. This means that future changes to the API and what is returned by EC2 will
|
249
|
+
One of the key benefits of this new version of the library is that all responses from EC2 are bundled up in a real data structure and no longer require parsing of text. The hash returned is populated directly from the XML given to us by EC2 in response to any command we issue. This means that future changes to the API and what is returned by EC2 will be handled transparently by the gem. This is a huge benefit. What this means though, is that you may have to do a little homework on what actually gets returned by EC2 as XML. For example, when you make a #describe_images call in 'ec2sh' what AWS returns behind the scenes looks like:
|
244
250
|
|
245
251
|
<?xml version="1.0"?>
|
246
252
|
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2007-01-19/">
|
@@ -315,8 +321,9 @@ The original code for this library was provided by Amazon Web Services, LLC as s
|
|
315
321
|
|
316
322
|
== Contact
|
317
323
|
|
318
|
-
Comments, patches, Git pull requests and bug reports are welcome. Send an email to mailto:glenn@
|
324
|
+
Comments, patches, Git pull requests and bug reports are welcome. Send an email to mailto:glenn@rempe.us or use the Google Groups forum for this project.
|
319
325
|
|
320
326
|
Enjoy!
|
321
327
|
|
322
328
|
Glenn Rempe
|
329
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.4
|
data/amazon-ec2.gemspec
CHANGED
data/bin/ec2-gem-example.rb
CHANGED
data/lib/EC2/responses.rb
CHANGED
@@ -34,8 +34,6 @@ module EC2
|
|
34
34
|
# may be raised by this library in YOUR code with a 'rescue' clauses. It is up to you
|
35
35
|
# how gracefully you want to handle these exceptions that are raised.
|
36
36
|
|
37
|
-
|
38
|
-
require 'rubygems'
|
39
37
|
begin
|
40
38
|
require 'xmlsimple' unless defined? XmlSimple
|
41
39
|
rescue Exception => e
|
data/test/test_helper.rb
CHANGED