Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

ADDED: Support for registering EBS-based images. (See rudy-ec2 images…

… -h)
  • Loading branch information...
commit 654726013f4a3d720ba1465a7c1a6ed83ce2920c 1 parent bf407d1
Delano Mandelbaum delano authored
4 CHANGES.txt
View
@@ -1,6 +1,10 @@
RUDY, CHANGES
+#### 0.9.8.018 (2010-11-27) #######################
+
+* ADDED: Support for registering EBS-based images. (See rudy-ec2 images -h)
+
#### 0.9.8.017 (2010-11-11) #######################
* FIXED: adduser handler checks for root before using sudo
5 bin/rudy-ec2
View
@@ -108,6 +108,11 @@ module RudyCLI_EC2
option :o, :owner, String, "Amazon Account Number or one of: amazon, self"
option :l, :all, "Display all registered machine images (warning: slow)"
#option :p, :private, "Private images only"
+ option :r, :ramdisk, String, "Ramdisk ID (EBS only)"
+ option :k, :kernel, String, "Kernel ID (EBS only)"
+ option :s, :snapshot, String, "Snapshot ID (EBS only)"
+ option :a, :arch, String, "Architecture. One of: i386, x86_64 (EBS only)"
+ option :d, :description, String, "A description of the image (EBS only)"
action :R, :register, "Register an image"
action :D, :destroy, "Deregister an image (does not remove image files from S3)"
argv :ami
2  lib/rudy.rb
View
@@ -44,7 +44,7 @@ module VERSION #:nodoc:
MAJOR = 0.freeze
MINOR = 9.freeze
TINY = 8.freeze
- PATCH = '017'.freeze
+ PATCH = '018'.freeze
end
def self.to_s; [MAJOR, MINOR, TINY, PATCH].join('.'); end
def self.to_f; self.to_s.to_f; end
25 lib/rudy/aws/ec2/image.rb
View
@@ -82,12 +82,25 @@ def deregister(id)
true
end
- # +path+ the S3 path to the manifest (bucket/file.manifest.xml)
- # Returns the AMI ID when successful, otherwise throws an exception.
- def register(path)
- opts = {
- :image_location => path
- }
+ # +opts+ can be the S3 path to the manifest (bucket/file.manifest.xml)
+ # or a hash containing the following options:
+ #
+ # [optional, String] :image_location ("") S3 URL for the XML manifest
+ # [optional, String] :name ("") Name of EBS image
+ # [optional, String] :description ("") Description of EBS image
+ # [optional, String] :architecture ("") Architecture of EBS image, currently 'i386' or 'x86_64'
+ # [optional, String] :kernel_id ("") Kernel ID of EBS image
+ # [optional, String] :ramdisk_id ("") Ramdisk ID of EBS image
+ # [optional, String] :root_device_name ("") Root device name of EBS image, eg '/dev/sda1'
+ # [optional, Array] :block_device_mapping ([]) An array of Hashes representing the elements of the block device mapping. e.g. [{:device_name => '/dev/sdh', :virtual_name => '', :ebs_snapshot_id => '', :ebs_volume_size => '', :ebs_delete_on_termination => ''},{},...]
+ # i.e.
+ # :block_device_mapping => [{
+ # :device_name => "/dev/sda1",
+ # :ebs_snapshot_id => "snap-01234567",
+ # :ebs_delete_on_termination => true,
+ # }]
+ def register(opts)
+ opts = Hash === opts ? opts : { :image_location => opts }
ret = @@ec2.register_image(opts)
return nil unless ret && ret.is_a?(Hash)
ret['imageId']
24 lib/rudy/cli/aws/ec2/images.rb
View
@@ -14,12 +14,10 @@ def images_valid?
true
end
def images
-
unless @option.all
@option.owner ||= 'amazon'
li "Images owned by #{@option.owner.bright}" unless @argv.awsid
end
-
images = Rudy::AWS::EC2::Images.list(@option.owner, @argv) || []
print_stobjects images
end
@@ -41,7 +39,27 @@ def register_images_valid?
true
end
def register_images
- li Rudy::AWS::EC2::Images.register(@argv.first)
+ if @option.snapshot
+ opts = {
+ :name => @argv.first,
+ :architecture => @option.arch || 'i386',
+ :description => @option.description || 'Made with Rudy',
+ :root_device_name => "/dev/sda1",
+ :block_device_mapping => [{
+ :device_name => "/dev/sda1",
+ :ebs_snapshot_id => @option.snapshot,
+ :ebs_delete_on_termination => true
+ }]
+ }
+ opts[:kernel_id] = @option.kernel if @option.kernel
+ opts[:ramdisk_id] = @option.ramdisk if @option.ramdisk
+ else
+ opts = {
+ :image_location => @argv.first
+ }
+ end
+ p opts if Rudy.debug?
+ li Rudy::AWS::EC2::Images.register(opts)
end
2  rudy.gemspec
View
@@ -1,7 +1,7 @@
@spec = Gem::Specification.new do |s|
s.name = "rudy"
s.rubyforge_project = 'rudy'
- s.version = "0.9.8.017"
+ s.version = "0.9.8.018"
s.summary = "Rudy: Not your grandparents' EC2 deployment tool."
s.description = s.summary
s.author = "Delano Mandelbaum"
Please sign in to comment.
Something went wrong with that request. Please try again.