Permalink
Browse files

r962@mac: glenn | 2006-12-14 10:24:38 -0800

 added code for load to rubyforge.


git-svn-id: svn+ssh://rubyforge.org/var/svn/amazon-ec2/trunk@1 2e111c3a-5438-44ef-9c14-21a960333853
  • Loading branch information...
0 parents commit 2679389cb6ae803379382f2127314436addc0da9 grempe committed Dec 14, 2006
@@ -0,0 +1,6 @@
+=CHANGELOG.txt : Amazon Elastic Compute Cloud (EC2) Ruby Gem
+
+
+==2006.12.13
+* Original sample library released by Amazon Web Services, LLC
+* Library packaged as a gem and RubyForge project 'amazon-ec2' setup by Glenn Rempe
@@ -0,0 +1,8 @@
+=History.txt : Amazon Elastic Compute Cloud (EC2) Ruby Gem
+
+==Version History
+
+===0.0.1 (12/23/2006)
+* Initial release of the Ruby Gem. This includes the version of the library exactly as provided by
+ Amazon Web Services as example code. No changes or enhancements to that code were made other than
+ packaging it as a Ruby Gem.
@@ -0,0 +1,12 @@
+History.txt
+Manifest.txt
+README.txt
+CHANGELOG.txt
+Rakefile
+setup.rb
+lib/EC2.rb
+lib/EC2/version.rb
+test/test_helper.rb
+test/EC2_test.rb
+
+examples/ec2-example.rb
@@ -0,0 +1,186 @@
+=README.txt : Amazon Elastic Compute Cloud (EC2) Ruby Gem
+
+AWS EC2 is an interface library that can be used to interact
+with the Amazon EC2 system. The library exposes one main interface class,
+'AWSAuthConnection'. This class performs all the operations for using using
+the EC2 service including header signing.
+
+==Important note about this project:
+Please note that I am packaging this sample code up as a service to the
+Ruby community and do not plan to be actively maintaining this code
+on a regular basis. If you can contribute documentation or additional tests as
+Subversion patch files I will be happy to incorporate those directly into the library.
+Alternatively, if you are interested in becoming a contributing developer with checkin
+privileges on this source code please feel free to contact me.
+
+==RubyForge Project Info
+This project is hosted on the RubyForge project server. You can find the project at:
+
+ http://amazon-ec2.rubyforge.org/
+ http://rubyforge.org/projects/amazon-ec2/
+
+Please actively report any bugs that you find using the bug tracker found on the RubyForge site. Please submit any patches as well through that mechanism. If you feel you want to help contribute to the project please contact me at:
+
+ grempe @no spam@ rubyforge.org
+
+==Prerequisites:
+
+An Amazon Web Services Developer account which is also signed up for Amazon EC2.
+You will need the AWS Access Key ID and Secret Access Key that they provide when you
+sign up.
+
+
+==Installation:
+
+The specific installation may vary according to your operation system. Some examples are below.
+
+Linux/Mac OS X:
+
+ sudo gem install amazon-ec2
+
+Windows:
+
+ gem install amazon-ec2
+
+
+==Usage:
+
+The public methods on AWSAuthConnection closely mirror the EC2 Query API, and
+as such the Query API Reference in the EC2 Developer Guide should be consulted.
+
+===Example Code Usage (Stand-alone Ruby Application):
+
+ #!/usr/bin/env ruby
+ require 'rubygems'
+ require 'ec2'
+ AWS_ACCESS_KEY_ID = '--YOUR AWS ACCESS KEY ID--'
+ AWS_SECRET_ACCESS_KEY = '--YOUR AWS SECRET ACCESS KEY--'
+ conn = EC2::AWSAuthConnection.new(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
+ puts "----- listing images -----"
+ puts conn.describe_images()
+
+
+An example client is provided as a starting point in this Gem installation which
+you may consult for a few more detailed usage examples.
+
+ examples/ec2-example.rb
+
+
+===Example Code Usage (Ruby on Rails Application):
+
+ config/environment.rb:
+ ...
+ # Include Amazon Web Services EC2 library gem
+ require 'ec2'
+
+ app/controllers/your_controller.rb:
+ conn = EC2::AWSAuthConnection.new(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
+
+ # The .parse method gives you back an array of values you can use in your view
+ @ec2_images = conn.describe_images().parse
+
+ -- OR with some params (in this case specific owner ID's) --
+
+ @ec2_images_mine = ec2.describe_images([],["522821470517"],[]).parse
+
+
+ app/views/your_view.rhtml:
+
+ <%= debug(@ec2_images) %>
+
+ -- OR --
+
+ <% @ec2_images.each do |image| %>
+ <% image.each_with_index do |value, index| %>
+ <%= "#{index} => #{value}" %><br />
+ <% end %>
+ <% end %>
+
+ -- OR --
+
+ <table>
+ <tr>
+ <th>Id</th>
+ <th>Location</th>
+ <th>Owner</th>
+ <th>State</th>
+ <th>Public?</th>
+ </tr>
+
+ <% for ec2_image in @ec2_images %>
+ <tr>
+ <td><%=h ec2_image[1] %></td>
+ <td><%=h ec2_image[2] %></td>
+ <td><%=h ec2_image[3] %></td>
+ <td><%=h ec2_image[4] %></td>
+ <td><%=h ec2_image[5] %></td>
+ </tr>
+ <% end %>
+ </table>
+
+
+==To Do:
+
+* As provided by Amazon, this library has nearly non-existent error handling.
+ All errors from lower libraries are simply passed up. The response code in
+ the returned object needs to be checked after each request to verify
+ whether the request succeeded.
+* Documentation - The code is almost devoid of documentation. RDoc comments in
+ the code would be very useful.
+* Automated Unit Tests - There are currently no unit tests for this code.
+ A suite of tests to help exercise the code would greatly improve our confidence.
+
+
+==Credits:
+
+* The original sample code for this library was provided by Amazon Web Services, LLC.
+ Thanks to them for providing the samples that got this started. They took the wind out
+ of the sails of my own version of this library (which was maybe 75% complete), but they
+ probably saved me some hair that otherwise would have suffered self-inflicted removal.
+
+* Thanks to Dr. Nic Williams and his great 'newgem' Ruby Gem Generator which can be found
+ at http://drnicwilliams.com/2006/10/11/generating-new-gems. This helped me package up
+ this code for distribution in a flash.
+
+
+=Original AWS README for this code (12/13/2006)
+
+http://developer.amazonwebservices.com/connect/entry.jspa?externalID=553
+
+This is one of a collection of interface libraries that can be used to interact
+with the Amazon EC2 system in a number of different languages. They each
+expose one main interface class, AWSAuthConnection. This performs all the
+operations using the appropriate libraries for the language, including header
+signing.
+
+
+==Usage:
+
+The public methods on AWSAuthConnection closely mirror the EC2 Query API, and
+as such the Query API Reference in the EC2 Developer Guide should be consulted.
+
+An example client is provided as a starting point.
+
+
+==Prerequisites:
+
+An Amazon Web Services Developer account signed up for Amazon EC2.
+
+
+==Limitations:
+
+These libraries have nearly non-existent error handling. All errors from lower
+libraries are simply passed up. The response code in the returned object needs
+to be checked after each request to verify whether the request succeeded.
+
+It is our intention that these libraries act as a starting point for future
+development. They are meant to show off the various operations and provide an
+example of how to negotiate the authentication process.
+
+This software code is made available "AS IS" without warranties of any kind.
+You may copy, display, modify and redistribute the software code either by
+itself or as incorporated into your code; provided that you do not remove any
+proprietary notices. Your use of this software code is at your own risk and
+you waive any claim against Amazon Web Services LLC or its affiliates with
+respect to your use of this software code. (c) 2006 Amazon Web Services LLC or
+its affiliates. All rights reserved.
@@ -0,0 +1,57 @@
+require 'rubygems'
+require 'rake'
+require 'rake/clean'
+require 'rake/testtask'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rake/rdoctask'
+require 'rake/contrib/rubyforgepublisher'
+require 'fileutils'
+require 'hoe'
+include FileUtils
+require File.join(File.dirname(__FILE__), 'lib', 'EC2', 'version')
+
+AUTHOR = ["Amazon Web Services LLC", "Glenn Rempe"] # can also be an array of Authors
+EMAIL = "grempe@rubyforge.org"
+DESCRIPTION = "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."
+GEM_NAME = "amazon-ec2" # what ppl will type to install your gem
+RUBYFORGE_PROJECT = "amazon-ec2" # The unix name for your project
+HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
+RELEASE_TYPES = %w( gem ) # can use: gem, tar, zip
+
+
+NAME = "amazon-ec2"
+REV = nil # UNCOMMENT IF REQUIRED: File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
+VERS = ENV['VERSION'] || (EC2::VERSION::STRING + (REV ? ".#{REV}" : ""))
+CLEAN.include ['**/.*.sw?', '*.gem', '.config']
+RDOC_OPTS = ['--quiet', '--title', "AWS EC2 documentation",
+ "--opname", "index.html",
+ "--line-numbers",
+ "--main", "README.txt",
+ "--inline-source"]
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+hoe = Hoe.new(GEM_NAME, VERS) do |p|
+ p.name = NAME
+ p.version = VERS
+ p.author = AUTHOR
+ p.description = DESCRIPTION
+ p.email = EMAIL
+ p.summary = DESCRIPTION
+ p.url = HOMEPATH
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
+ p.test_globs = ["test/**/*_test.rb"]
+ p.clean_globs = CLEAN #An array of file patterns to delete on clean.
+
+ p.spec_extras = {
+ :extra_rdoc_files => ["README.txt", "History.txt", "CHANGELOG.txt"],
+ :rdoc_options => RDOC_OPTS,
+ :autorequire => "EC2"
+ }
+
+ # == Optional
+ #p.changes - A description of the release's latest changes.
+ #p.extra_deps - An array of rubygem dependencies.
+ #p.spec_extras - A hash of extra values to set in the gemspec.
+end
@@ -0,0 +1,45 @@
+#!/usr/bin/env ruby
+
+# This software code is made available "AS IS" without warranties of any
+# kind. You may copy, display, modify and redistribute the software
+# code either by itself or as incorporated into your code; provided that
+# you do not remove any proprietary notices. Your use of this software
+# code is at your own risk and you waive any claim against Amazon Web
+# Services LLC or its affiliates with respect to your use of this software
+# code. (c) 2006 Amazon Web Services LLC or its affiliates. All rights
+# reserved.
+
+require 'rubygems'
+require 'ec2'
+
+AWS_ACCESS_KEY_ID = '--YOUR AWS ACCESS KEY ID--'
+AWS_SECRET_ACCESS_KEY = '--YOUR AWS SECRET ACCESS KEY--'
+
+# remove these next two lines as well, when you've updated your credentials.
+puts "update #{$0} with your AWS credentials"
+exit
+
+SECURITY_GROUP_NAME = "ec2-example-rb-test-group"
+
+conn = EC2::AWSAuthConnection.new(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
+
+puts "----- listing images -----"
+puts conn.describe_images()
+
+puts "----- listing instances -----"
+puts conn.describe_instances()
+
+puts "----- creating a security group -----"
+puts conn.create_securitygroup(SECURITY_GROUP_NAME, "ec-example.rb test group")
+
+puts "----- listing security groups -----"
+puts conn.describe_securitygroups()
+
+puts "----- deleting a security group -----"
+puts conn.delete_securitygroup(SECURITY_GROUP_NAME)
+
+puts "----- listing keypairs (verbose mode) -----"
+conn.verbose = true
+puts conn.describe_keypairs()
+
+
Oops, something went wrong.

0 comments on commit 2679389

Please sign in to comment.