amazon-ec2 0.9.10 → 0.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.9.11 2010-04-23
2
+ * RDS#create_db_instance : renamed misspelled :backend_retention_period option to :backup_retention_period.
3
+ * Better handling of FixNum options in a few methods.
4
+ * A few bug fixes.
5
+
1
6
  === 0.9.10 2010-03-26
2
7
  * Enhancements to EC2 register_image to handle registration based on EBS snapshots (jamespharaoh)
3
8
 
data/README.rdoc CHANGED
@@ -348,6 +348,20 @@ The original code for this library was provided by Amazon Web Services, LLC as s
348
348
 
349
349
  Comments, patches, Git pull requests and bug reports are welcome. Send an email to mailto:glenn@rempe.us or join the Google Groups forum.
350
350
 
351
+ == Patches & Pull Requests
352
+
353
+ Please follow these steps if you want to send a patch or a GitHub pull request:
354
+
355
+ * Fork grempe/amazon-ec2
356
+ * Create a topic branch: `git checkout -b my_fix`
357
+ * Make sure you add tests for your changes and that they all pass with 'rake test'
358
+ * Don't change files that you don't own like the gemspec or VERSION
359
+ * Commit your changes, one change/fix per commit
360
+ * Push your fixes branch: `git push origin my_fix`
361
+ * Open an Issue referencing your branch.
362
+ * Please do not push to `master` on your fork. This will make everyone’s life easier.
363
+
364
+
351
365
  Enjoy!
352
366
 
353
367
  Glenn Rempe
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.10
1
+ 0.9.11
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.10"
8
+ s.version = "0.9.11"
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-26}
12
+ s.date = %q{2010-04-25}
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"]
@@ -10,7 +10,7 @@ module AWS
10
10
  # @option options [Integer] :min_count (1) Minimum number of instances to launch. If the value is more than Amazon EC2 can launch, no instances are launched at all.
11
11
  # @option options [Integer] :max_count (1) Maximum number of instances to launch. If the value is more than Amazon EC2 can launch, the largest possible number above minCount will be launched instead.
12
12
  # @option options [optional, String] :key_name (nil) The name of the key pair.
13
- # @option options [optional, Array of Strings or String] :security_group (nil) Name of the security group(s).
13
+ # @option options [optional, Array] :security_group (nil) Name of the security group(s). Array of Strings or String.
14
14
  # @option options [optional, String] :additional_info (nil) Specifies additional information to make available to the instance(s).
15
15
  # @option options [optional, String] :user_data (nil) MIME, Base64-encoded user data.
16
16
  # @option options [optional, String] :instance_type (nil) Specifies the instance type.
@@ -27,6 +27,7 @@ module AWS
27
27
  # @option options [optional,String] :availability_zone (nil) Specifies the placement constraints (Availability Zones) for launching the instances.
28
28
  # @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 => ''},{},...]
29
29
  # @option options [optional, Boolean] :monitoring_enabled (false) Enables monitoring for the instance.
30
+ # @option options [optional, Boolean] :base64_encoded (false)
30
31
  #
31
32
  def request_spot_instances( options = {} )
32
33
  options = { :instance_count => 1,
@@ -35,6 +36,7 @@ module AWS
35
36
 
36
37
  raise ArgumentError, ":addressing_type has been deprecated." if options[:addressing_type]
37
38
  raise ArgumentError, ":spot_price must be provided" if options[:spot_price].nil? || options[:spot_price].empty?
39
+ raise ArgumentError, ":base64_encoded must be 'true' or 'false'" unless [true, false].include?(options[:base64_encoded])
38
40
 
39
41
  user_data = extract_user_data(options)
40
42
 
@@ -64,7 +66,7 @@ module AWS
64
66
  params["LaunchSpecification.SubnetId"] = options[:subnet_id] unless options[:subnet_id].nil?
65
67
  params["LaunchSpecification.Placement.AvailabilityZone"] = options[:availability_zone] unless options[:availability_zone].nil?
66
68
  params["LaunchSpecification.Monitoring.Enabled"] = options[:monitoring_enabled].to_s unless options[:monitoring_enabled].nil?
67
-
69
+
68
70
  return response_generator(:action => "RequestSpotInstances", :params => params)
69
71
  end
70
72
 
@@ -115,7 +115,7 @@ module AWS
115
115
  raise ArgumentError, "No :instances provided" if options[:instances].nil? || options[:instances].empty?
116
116
  raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty?
117
117
  params = {}
118
- params.merge!(pathlist('Instances.member', [options[:instances]].flatten))
118
+ params.merge!(pathhashlist('Instances.member', options[:instances].flatten.collect{|e| {:instance_id => e}}, {:instance_id => 'InstanceId'}))
119
119
  params['LoadBalancerName'] = options[:load_balancer_name]
120
120
  return response_generator(:action => "DeregisterInstancesFromLoadBalancer", :params => params)
121
121
  end
@@ -125,26 +125,21 @@ module AWS
125
125
  #
126
126
  # Note: Completion of this API does not guarantee that operation has completed. Rather, it means that the request has been registered and the changes will happen shortly.
127
127
  #
128
- # @option options [Hash] :health_check A Hash with the keys (:timeout, :interval, :unhealthy_threshold, :healthy_threshold)
129
128
  # @option options [String] :load_balancer_name The name of the load balancer.
129
+ # @option options [Hash] :health_check A Hash with the key values provided as String or FixNum values (:timeout, :interval, :unhealthy_threshold, :healthy_threshold)
130
130
  #
131
131
  def configure_health_check( options = {} )
132
- raise ArgumentError, "No :health_check provided" if options[:health_check].nil? || options[:health_check].empty?
133
- raise ArgumentError, "No :health_check => :target provided" if options[:health_check][:target].nil? || options[:health_check][:target].empty?
134
- raise ArgumentError, "No :health_check => :timeout provided" if options[:health_check][:timeout].nil? || options[:health_check][:timeout].empty?
135
- raise ArgumentError, "No :health_check => :interval provided" if options[:health_check][:interval].nil? || options[:health_check][:interval].empty?
136
- raise ArgumentError, "No :health_check => :unhealthy_threshold provided" if options[:health_check][:unhealthy_threshold].nil? || options[:health_check][:unhealthy_threshold].empty?
137
- raise ArgumentError, "No :health_check => :healthy_threshold provided" if options[:health_check][:healthy_threshold].nil? || options[:health_check][:healthy_threshold].empty?
138
132
  raise ArgumentError, "No :load_balancer_name provided" if options[:load_balancer_name].nil? || options[:load_balancer_name].empty?
133
+ raise ArgumentError, "No :health_check Hash provided" if options[:health_check].nil? || options[:health_check].empty?
139
134
 
140
135
  params = {}
141
136
 
142
- params['LoadBalancerName'] = options[:load_balancer_name]
143
- params['HealthCheck.Target'] = options[:health_check][:target]
144
- params['HealthCheck.Timeout'] = options[:health_check][:timeout]
145
- params['HealthCheck.Interval'] = options[:health_check][:interval]
146
- params['HealthCheck.UnhealthyThreshold'] = options[:health_check][:unhealthy_threshold]
147
- params['HealthCheck.HealthyThreshold'] = options[:health_check][:healthy_threshold]
137
+ params['LoadBalancerName'] = options[:load_balancer_name]
138
+ params['HealthCheck.Target'] = options[:health_check][:target] unless options[:health_check][:target].nil?
139
+ params['HealthCheck.Timeout'] = options[:health_check][:timeout].to_s unless options[:health_check][:timeout].nil?
140
+ params['HealthCheck.Interval'] = options[:health_check][:interval].to_s unless options[:health_check][:interval].nil?
141
+ params['HealthCheck.UnhealthyThreshold'] = options[:health_check][:unhealthy_threshold].to_s unless options[:health_check][:unhealthy_threshold].nil?
142
+ params['HealthCheck.HealthyThreshold'] = options[:health_check][:healthy_threshold].to_s unless options[:health_check][:healthy_threshold].nil?
148
143
 
149
144
  return response_generator(:action => "ConfigureHealthCheck", :params => params)
150
145
  end
data/lib/AWS/RDS/rds.rb CHANGED
@@ -17,7 +17,7 @@ module AWS
17
17
  # @option options [String] :db_security_groups are the list of db security groups to associate with the instance (nil)
18
18
  # @option options [String] :availability_zone is the availability_zone to create the instance in (nil)
19
19
  # @option options [String] :preferred_maintenance_window in format: ddd:hh24:mi-ddd:hh24:mi (nil)
20
- # @option options [String] :backend_retention_period is the number of days which automated backups are retained (1)
20
+ # @option options [String] :backup_retention_period is the number of days which automated backups are retained (1)
21
21
  # @option options [String] :preferred_backup_window is the daily time range for which automated backups are created
22
22
  #
23
23
  def create_db_instance( options = {})
@@ -29,6 +29,9 @@ module AWS
29
29
  raise ArgumentError, "No :master_user_password provided" if options.does_not_have?(:master_user_password)
30
30
  raise ArgumentError, "No :db_instance_class provided" if options.does_not_have?(:db_instance_class)
31
31
 
32
+ # handle a former argument that was misspelled
33
+ raise ArgumentError, "Perhaps you meant :backup_retention_period" if options.has?(:backend_retention_period)
34
+
32
35
  params = {}
33
36
  params['DBInstanceIdentifier'] = options[:db_instance_identifier]
34
37
  params["AllocatedStorage"] = options[:allocated_storage].to_s
@@ -42,8 +45,8 @@ module AWS
42
45
  params["DBParameterGroup"] = options[:db_parameter_group] if options.has?(:db_parameter_group)
43
46
  params["DBSecurityGroups"] = options[:db_security_groups] if options.has?(:db_security_groups)
44
47
  params["AvailabilityZone"] = options[:availability_zone] if options.has?(:availability_zone)
45
- params["PreferredMaintenanceWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
46
- params["BackupRetentionPeriod"] = options[:backend_retention_period] if options.has?(:backend_retention_period)
48
+ params["PreferredMaintenanceWindow"] = options[:preferred_maintenance_window] if options.has?(:preferred_maintenance_window)
49
+ params["BackupRetentionPeriod"] = options[:backup_retention_period].to_s if options.has?(:backup_retention_period)
47
50
  params["PreferredBackupWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
48
51
 
49
52
  return response_generator(:action => "CreateDBInstance", :params => params)
@@ -363,7 +366,7 @@ module AWS
363
366
  params["DBParameterGroupName"] = options[:db_parameter_group_name] if options.has?(:db_parameter_group_name)
364
367
  params["DBSecurityGroups"] = options[:db_security_groups] if options.has?(:db_security_groups)
365
368
  params["AvailabilityZone"] = options[:availability_zone] if options.has?(:availability_zone)
366
- params["PreferredMaintenanceWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
369
+ params["PreferredMaintenanceWindow"] = options[:preferred_maintenance_window] if options.has?(:preferred_maintenance_window)
367
370
  params["BackupRetentionPeriod"] = options[:backend_retention_period] if options.has?(:backend_retention_period)
368
371
  params["PreferredBackupWindow"] = options[:preferred_backup_window] if options.has?(:preferred_backup_window)
369
372
 
@@ -184,10 +184,10 @@ context "elb load balancers " do
184
184
  lambda { @elb.register_instances_with_load_balancer(@valid_register_instances_with_load_balancer_params.merge(:instances=>[])) }.should.raise(AWS::ArgumentError)
185
185
  end
186
186
 
187
- specify "should be able to degresiter instances from load balancers with degregister_instances_from_load_balancer" do
187
+ specify "should be able to deregister instances from load balancers with deregister_instances_from_load_balancer" do
188
188
  @elb.stubs(:make_request).with('DeregisterInstancesFromLoadBalancer', {
189
189
  'LoadBalancerName' => 'Test Name',
190
- 'Instances.member.1' => 'i-6055fa09'
190
+ 'Instances.member.1.InstanceId' => 'i-6055fa09'
191
191
  }).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
192
192
 
193
193
  response = @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params)
@@ -197,7 +197,7 @@ context "elb load balancers " do
197
197
  specify "method deregister_instances_from_load_balancer should reject bad arguments" do
198
198
  @elb.stubs(:make_request).with('DeregisterInstancesFromLoadBalancer', {
199
199
  'LoadBalancerName' => 'Test Name',
200
- 'Instances.member.1' => 'i-6055fa09'
200
+ 'Instances.member.1.InstanceId' => 'i-6055fa09'
201
201
  }).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
202
202
 
203
203
  lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params) }.should.not.raise(AWS::ArgumentError)
@@ -206,7 +206,7 @@ context "elb load balancers " do
206
206
  lambda { @elb.deregister_instances_from_load_balancer(@valid_deregister_instances_from_load_balancer_params.merge(:instances=>[])) }.should.raise(AWS::ArgumentError)
207
207
  end
208
208
 
209
- specify "should be able to degresiter instances from load balancers with degregister_instances_from_load_balancer" do
209
+ specify "should be able to configure_health_check for instances from load balancers" do
210
210
  @elb.stubs(:make_request).with('ConfigureHealthCheck', {
211
211
  'LoadBalancerName' => 'Test Name',
212
212
  'HealthCheck.Interval' => '5',
@@ -218,8 +218,45 @@ context "elb load balancers " do
218
218
 
219
219
  response = @elb.configure_health_check(@valid_configure_health_check_params)
220
220
  response.should.be.an.instance_of Hash
221
+
222
+ lambda { @elb.configure_health_check(@valid_configure_health_check_params) }.should.not.raise(AWS::ArgumentError)
223
+ lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:load_balancer_name => nil)) }.should.raise(AWS::ArgumentError)
224
+ lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:load_balancer_name => "")) }.should.raise(AWS::ArgumentError)
225
+
226
+ lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check => nil)) }.should.raise(AWS::ArgumentError)
227
+ lambda { @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check => "")) }.should.raise(AWS::ArgumentError)
228
+
221
229
  end
222
230
 
231
+ specify "should be able to configure_health_check for instances from load balancers with string health check args" do
232
+ @elb.stubs(:make_request).with('ConfigureHealthCheck', {
233
+ 'LoadBalancerName' => 'Test Name',
234
+ 'HealthCheck.Interval' => '5',
235
+ 'HealthCheck.Target' => 'HTTP:80/servlets-examples/servlet/',
236
+ 'HealthCheck.HealthyThreshold' => '2',
237
+ 'HealthCheck.Timeout' => '2',
238
+ 'HealthCheck.UnhealthyThreshold' => '2'
239
+ }).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
240
+
241
+ response = @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check => {:target => 'HTTP:80/servlets-examples/servlet/', :timeout => '2', :interval => '5', :unhealthy_threshold => '2', :healthy_threshold => '2' }))
242
+ response.should.be.an.instance_of Hash
243
+ end
244
+
245
+ specify "should be able to configure_health_check for instances from load balancers with FixNum health check args" do
246
+ @elb.stubs(:make_request).with('ConfigureHealthCheck', {
247
+ 'LoadBalancerName' => 'Test Name',
248
+ 'HealthCheck.Interval' => '5',
249
+ 'HealthCheck.Target' => 'HTTP:80/servlets-examples/servlet/',
250
+ 'HealthCheck.HealthyThreshold' => '2',
251
+ 'HealthCheck.Timeout' => '2',
252
+ 'HealthCheck.UnhealthyThreshold' => '2'
253
+ }).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
254
+
255
+ response = @elb.configure_health_check(@valid_configure_health_check_params.merge(:health_check => {:target => 'HTTP:80/servlets-examples/servlet/', :timeout => 2, :interval => 5, :unhealthy_threshold => 2, :healthy_threshold => 2 }))
256
+ response.should.be.an.instance_of Hash
257
+ end
258
+
259
+
223
260
  specify "method degregister_instances_from_load_balancer should reject bad arguments" do
224
261
  @elb.stubs(:make_request).with('ConfigureHealthCheck', {
225
262
  'LoadBalancerName' => 'Test Name',
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 10
9
- version: 0.9.10
8
+ - 11
9
+ version: 0.9.11
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-26 00:00:00 -07:00
17
+ date: 2010-04-25 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency