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.
@@ -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] (an OpenStruct of a single item in that array)
148
- >> @ec2.describe_images.imagesSet.item[0].to_s (a String representation of that OpenStruct item)
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
- # Require the amazon-ec2 gem and make its methods available in your Rails app
181
- # Put this at the bottom of your environment.rb
182
- require 'EC2'
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
- [some controller code ...]
192
+ [some controller code ...]
187
193
 
188
- ec2 = EC2::Base.new(:access_key_id => "YOUR_AWS_ACCESS_KEY_ID", :secret_access_key => "YOUR_AWS_SECRET_ACCESS_KEY")
194
+ ec2 = EC2::Base.new(:access_key_id => "YOUR_AWS_ACCESS_KEY_ID", :secret_access_key => "YOUR_AWS_SECRET_ACCESS_KEY")
189
195
 
190
- # get ALL public images
191
- @ec2_images = ec2.describe_images().imagesSet.item
196
+ # get ALL public images
197
+ @ec2_images = ec2.describe_images().imagesSet.item
192
198
 
193
- # Get info on all public EC2 images created by the Amazon EC2 team.
194
- @ec2_images_amazon = ec2.describe_images(:owner_id => "amazon").imagesSet.item
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
- [some more controller code ...]
202
+ [some more controller code ...]
197
203
 
198
204
 
199
205
  <b>app/views/my/index.rhtml</b>
200
206
 
201
- <h1>EC2 Test#index</h1>
207
+ <h1>EC2 Test#index</h1>
202
208
 
203
- <h1>Sample 1 - debug() view</h1>
209
+ <h1>Sample 1 - debug() view</h1>
204
210
 
205
- <%= debug(@ec2_images_amazon) %>
211
+ <%= debug(@ec2_images_amazon) %>
206
212
 
207
- <h1>Sample 2 - Build a table</h1>
213
+ <h1>Sample 2 - Build a table</h1>
208
214
 
209
- <table border='1'>
210
- <tr>
211
- <th>image.imageId</th>
212
- <th>image.imageLocation</th>
213
- <th>image.imageOwnerId</th>
214
- <th>image.imageState</th>
215
- <th>image.isPublic</th>
216
- </tr>
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
- <% for image in @ec2_images_amazon %>
219
- <tr>
220
- <td><%=h image.imageId %></td>
221
- <td><%=h image.imageLocation %></td>
222
- <td><%=h image.imageOwnerId %></td>
223
- <td><%=h image.imageState %></td>
224
- <td><%=h image.isPublic %></td>
225
- </tr>
226
- <% end %>
227
- </table>
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
- <h1>Sample 3 - Iterate</h1>
235
+ <h1>Sample 3 - Iterate</h1>
230
236
 
231
- <% @ec2_images_amazon.each do |image| %>
232
- <% image.each_pair do |key, value| %>
233
- <% unless key == 'parent' %>
234
- <%= "#{key} => #{value}" %><br />
235
- <% end %>
236
- <% end %>
237
- <br />
238
- <% end %>
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 largely 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:
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@nospam@rempe.us or use the Google Groups forum for this project.
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.3
1
+ 0.4.4
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{amazon-ec2}
5
- s.version = "0.4.3"
5
+ s.version = "0.4.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Glenn Rempe"]
@@ -9,7 +9,6 @@
9
9
  # Home:: http://github.com/grempe/amazon-ec2/tree/master
10
10
  #++
11
11
 
12
- require 'rubygems'
13
12
  require File.dirname(__FILE__) + '/../lib/EC2'
14
13
  require 'pp'
15
14
 
@@ -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
@@ -8,7 +8,7 @@
8
8
  # Home:: http://github.com/grempe/amazon-ec2/tree/master
9
9
  #++
10
10
 
11
- %w[ test/unit rubygems test/spec mocha ].each { |f|
11
+ %w[ test/unit test/spec mocha ].each { |f|
12
12
  begin
13
13
  require f
14
14
  rescue LoadError
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon-ec2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glenn Rempe