fog/fog — pull request #787 by rjackson (2012-03-09 23:04:40+00:00)
Title: Handle multiple instances with spot request

Previously (current HEAD) you could instantiate many spot requests by using instance_count, but only the first was added to the SpotRequests collection and returned.

This pull request updates Fog::Compute::AWS::SpotRequest#save so that it initializes and adds all newly created spot requests to the Fog::Compute::AWS::SpotRequests collection. If instance_count is 1 (which is the default) it returns the generated spot_request. If instance_count is greater than 1 it will return an array of the newly created spot requests.

(Please note: this does not change the result of spot_requests.create because Fog::Collection#create automatically returns the object created when SpotRequest.new is called (not the result of SpotRequest#save).

This pull request also updates Fog::Compute::AWS::SpotRequests#bootstrap to allow it to bootstrap multiple servers at once if instance_count is more than one. Fog::Compute::AWS::SpotRequests#bootstrap will then return an array of Fog::Compute::AWS::Server objects (when instance_count == 1) or it will return the first Fog::Compute::AWS::Server (when instance_count == 1).

I do not see any tests specific to Fog::Compute::AWS::SpotRequests or Fog::Compute::AWS::SpotRequest, but I certainly can try to add some testing with a bit of direction.

In the default case of instance_count == 1 both Fog::Compute::AWS::SpotRequests#bootstrap and Fog::Compute::AWS::SpotRequest#save return the same value as current HEAD.