amazon-ec2 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.9.10 2010-03-26
2
+ * Enhancements to EC2 register_image to handle registration based on EBS snapshots (jamespharaoh)
3
+
4
+ === 0.9.9 2010-03-19
5
+ * Bugfix in signing algorithm (wlach)
6
+
1
7
  === 0.9.7 2010-03-14
2
8
  * Added EC2 describe_subnets support (petitbon)
3
9
 
data/README.rdoc CHANGED
@@ -148,12 +148,7 @@ If you're not in front of a terminal shell now (perhaps you're browsing this sit
148
148
  The EC2 connection is wired to the class instance '@ec2'. Make method calls
149
149
  on this to execute commands on EC2. Adding a #to_s
150
150
  at the end of any command should give you a full String representation of the
151
- response. The #xml data is available for each response
152
- which allows you to view the full and complete XML response returned by
153
- EC2 without any parsing applied. This is useful for viewing the
154
- hierarchy of an entire response in a friendly way (if XML is friendly
155
- to you!). Understanding the hierarchy of the XML response is critical
156
- to making effective use of this library.
151
+ response.
157
152
 
158
153
  Examples to try:
159
154
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.9
1
+ 0.9.10
data/amazon-ec2.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{amazon-ec2}
8
- s.version = "0.9.9"
8
+ s.version = "0.9.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Glenn Rempe"]
12
- s.date = %q{2010-03-19}
12
+ s.date = %q{2010-03-26}
13
13
  s.description = %q{A Ruby library for accessing the Amazon Web Services EC2, ELB, RDS, Cloudwatch, and Autoscaling APIs.}
14
14
  s.email = %q{glenn@rempe.us}
15
15
  s.executables = ["ec2-gem-example.rb", "ec2-gem-profile.rb", "ec2sh", "setup.rb"]
@@ -43,21 +43,54 @@ module AWS
43
43
  end
44
44
 
45
45
 
46
- # The RegisterImage operation registers an AMI with Amazon EC2. Images must be registered before
47
- # they can be launched. Each AMI is associated with an unique ID which is provided by the EC2
48
- # service via the Registerimage operation. As part of the registration process, Amazon EC2 will
49
- # retrieve the specified image manifest from Amazon S3 and verify that the image is owned by the
50
- # user requesting image registration. The image manifest is retrieved once and stored within the
51
- # Amazon EC2 network. Any modifications to an image in Amazon S3 invalidate this registration.
52
- # If you do have to make changes and upload a new image deregister the previous image and register
53
- # the new image.
46
+ # Registers an AMI with Amazon EC2. Images must be registered before they can be launched.
47
+ # To launch instances, use the RunInstances operation. Each AMI is associated with an unique ID
48
+ # which is provided by the Amazon EC2 service through this operation. If needed, you can deregister
49
+ # an AMI at any time.
54
50
  #
55
- # @option options [String] :image_location ("")
51
+ # AMIs backed by Amazon EBS are automatically registered when you create the image.
52
+ # However, you can use this to register a snapshot of an instance backed by Amazon EBS.
53
+ #
54
+ # Amazon EBS snapshots are not guaranteed to be bootable. For information on creating AMIs
55
+ # backed by Amazon EBS, go to the Amazon Elastic Compute Cloud Developer Guide or Amazon
56
+ # Elastic Compute Cloud User Guide.
57
+ #
58
+ # Any modifications to an AMI backed by Amazon S3 invalidates this registration.
59
+ # If you make changes to an image, deregister the previous image and register the new image.
60
+ #
61
+ # If an :image_location is specified then an old-style S3-backed AMI is created. If the other
62
+ # parameters are used then a new style EBS-backed AMI is created from a pre-existing snapshot.
63
+ #
64
+ # @option options [optional, String] :image_location ("") S3 URL for the XML manifest
65
+ # @option options [optional, String] :name ("") Name of EBS image
66
+ # @option options [optional, String] :description ("") Description of EBS image
67
+ # @option options [optional, String] :architecture ("") Architecture of EBS image, currently 'i386' or 'x86_64'
68
+ # @option options [optional, String] :kernel_id ("") Kernel ID of EBS image
69
+ # @option options [optional, String] :ramdisk_id ("") Ramdisk ID of EBS image
70
+ # @option options [optional, String] :root_device_name ("") Root device name of EBS image, eg '/dev/sda1'
71
+ # @option options [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 => ''},{},...]
56
72
  #
57
73
  def register_image( options = {} )
58
- options = {:image_location => ""}.merge(options)
59
- raise ArgumentError, "No :image_location provided" if options[:image_location].nil? || options[:image_location].empty?
60
- params = { "ImageLocation" => options[:image_location] }
74
+ params = {}
75
+ if options.does_not_have?(:image_location) && options.does_not_have?(:root_device_name)
76
+ raise ArgumentError, "No :image_location or :root_device_name"
77
+ end
78
+ params["ImageLocation"] = options[:image_location].to_s unless options[:image_location].nil?
79
+ params["Name"] = options[:name].to_s unless options[:name].nil?
80
+ params["Description"] = options[:description].to_s unless options[:description].nil?
81
+ params["Architecture"] = options[:architecture].to_s unless options[:architecture].nil?
82
+ params["KernelId"] = options[:kernel_id].to_s unless options[:kernel_id].nil?
83
+ params["RamdiskId"] = options[:ramdisk_id].to_s unless options[:ramdisk_id].nil?
84
+ params["RootDeviceName"] = options[:root_device_name].to_s unless options[:root_device_name].nil?
85
+ if options[:block_device_mapping]
86
+ params.merge!(pathhashlist("BlockDeviceMapping", options[:block_device_mapping].flatten, {
87
+ :device_name => "DeviceName",
88
+ :virtual_name => "VirtualName",
89
+ :ebs_snapshot_id => "Ebs.SnapshotId",
90
+ :ebs_volume_size => "Ebs.VolumeSize",
91
+ :ebs_delete_on_termination => "Ebs.DeleteOnTermination"
92
+ }))
93
+ end
61
94
  return response_generator(:action => "RegisterImage", :params => params)
62
95
  end
63
96
 
@@ -88,7 +88,7 @@ context "An EC2 image " do
88
88
  end
89
89
 
90
90
 
91
- specify "should be able to be registered" do
91
+ specify "should be able to be registered with manifest" do
92
92
  @ec2.stubs(:make_request).with('RegisterImage', {"ImageLocation"=>"mybucket-myimage.manifest.xml"}).
93
93
  returns stub(:body => @register_image_response_body, :is_a? => true)
94
94
  @ec2.register_image(:image_location => "mybucket-myimage.manifest.xml").imageId.should.equal "ami-61a54008"
@@ -96,9 +96,37 @@ context "An EC2 image " do
96
96
  end
97
97
 
98
98
 
99
- specify "method register_image should raise an exception when called without nil/empty string arguments" do
99
+ specify "should be able to be registered with snapshot" do
100
+ @ec2.stubs(:make_request).with('RegisterImage', {
101
+ "Name" => "image_name",
102
+ "Architecture" => "i386",
103
+ "KernelId" => "aki-01234567",
104
+ "RamdiskId" => "ari-01234567",
105
+ "RootDeviceName" => "/dev/sda1",
106
+ "BlockDeviceMapping.1.DeviceName" => "/dev/sda1",
107
+ "BlockDeviceMapping.1.Ebs.SnapshotId" => "snap-01234567",
108
+ "BlockDeviceMapping.1.Ebs.DeleteOnTermination" => "true",
109
+ }).returns stub(:body => @register_image_response_body, :is_a? => true)
110
+ ret = @ec2.register_image({
111
+ :name => "image_name",
112
+ :architecture => "i386",
113
+ :kernel_id => "aki-01234567",
114
+ :ramdisk_id => "ari-01234567",
115
+ :root_device_name => "/dev/sda1",
116
+ :block_device_mapping => [{
117
+ :device_name => "/dev/sda1",
118
+ :ebs_snapshot_id => "snap-01234567",
119
+ :ebs_delete_on_termination => true,
120
+ }]
121
+ })
122
+ ret.imageId.should.equal "ami-61a54008"
123
+ ret.should.be.an.instance_of Hash
124
+ end
125
+
126
+
127
+ specify "method register_image should raise an exception when called without :name or :root_device_name" do
100
128
  lambda { @ec2.register_image() }.should.raise(AWS::ArgumentError)
101
- lambda { @ec2.register_image(:image_location => "") }.should.raise(AWS::ArgumentError)
129
+ lambda { @ec2.register_image(:image_location => "", :root_device_name => "") }.should.raise(AWS::ArgumentError)
102
130
  end
103
131
 
104
132
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 9
9
- version: 0.9.9
8
+ - 10
9
+ version: 0.9.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Glenn Rempe
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-19 00:00:00 -07:00
17
+ date: 2010-03-26 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency