deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1232906 - in /deltacloud/trunk/server/lib/deltacloud: drivers/ec2/ec2_driver.rb server.rb
Date Wed, 18 Jan 2012 14:33:04 GMT
Author: mfojtik
Date: Wed Jan 18 14:33:04 2012
New Revision: 1232906

URL: http://svn.apache.org/viewvc?rev=1232906&view=rev
Log:
EC2: A full list of created instances should be now returned when use specified the 'instance_count'
parameter. (DTACLOUD-79)

Modified:
    deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
    deltacloud/trunk/server/lib/deltacloud/server.rb

Modified: deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb?rev=1232906&r1=1232905&r2=1232906&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb Wed Jan 18 14:33:04 2012
@@ -231,8 +231,14 @@ module Deltacloud
             }]
           end
           safely do
-            new_instance = convert_instance(ec2.launch_instances(image_id, instance_options).first)
-            new_instance
+            new_instances = ec2.launch_instances(image_id, instance_options).collect do |i|
+              convert_instance(i)
+            end
+            if new_instances.size == 1
+              new_instances.first
+            else
+              new_instances
+            end
           end
         end
 

Modified: deltacloud/trunk/server/lib/deltacloud/server.rb
URL: http://svn.apache.org/viewvc/deltacloud/trunk/server/lib/deltacloud/server.rb?rev=1232906&r1=1232905&r2=1232906&view=diff
==============================================================================
--- deltacloud/trunk/server/lib/deltacloud/server.rb (original)
+++ deltacloud/trunk/server/lib/deltacloud/server.rb Wed Jan 18 14:33:04 2012
@@ -476,14 +476,32 @@ END
     param :hwp_id,       :string, :optional
     control do
       @instance = driver.create_instance(credentials, params[:image_id], params)
+      if @instance.kind_of? Array
+        @instances = @instance
+        action_handler = "index"
+      else
+        response['Location'] = instance_url(@instance.id)
+        action_handler = "show"
+      end
       status 201  # Created
-      response['Location'] = instance_url(@instance.id)
       respond_to do |format|
-        format.xml  { haml :"instances/show" }
-        format.json { convert_to_json(:instance, @instance) }
+        format.xml  { haml :"instances/#{action_handler}" }
+        format.json do
+          if @instances
+            convert_to_json(:instances, @instances)
+          else
+            convert_to_json(:instance, @instance)
+          end
+        end
         format.html do
-          redirect instance_url(@instance.id) if @instance and @instance.id
-          redirect instances_url
+          if @instances
+            haml :"instances/index"
+          elsif @instance and @instance.id
+            response['Location'] = instance_url(@instance.id)
+            redirect instance_url(@instance.id)
+          else
+            redirect instances_url
+          end
         end
       end
     end



Mime
View raw message