incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 4/4] Added possibility to lunch multiple instances at once for EC2
Date Tue, 24 Aug 2010 14:04:33 GMT
---
 server/lib/deltacloud/base_driver/features.rb   |    6 ++++++
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb |    3 +++
 2 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/server/lib/deltacloud/base_driver/features.rb b/server/lib/deltacloud/base_driver/features.rb
index 3ed4085..1ed7be7 100644
--- a/server/lib/deltacloud/base_driver/features.rb
+++ b/server/lib/deltacloud/base_driver/features.rb
@@ -162,5 +162,11 @@ module Deltacloud
       description "Size instances according to changes to a hardware profile"
       # The parameters are filled in from the hardware profiles
     end
+
+    declare_feature :instances, :create_multiple_instance do
+      operation :create do
+        param :amount, :string, :optional
+      end
+    end
   end
 end
diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 909eca3..91e7855 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -40,6 +40,7 @@ class EC2Driver < Deltacloud::BaseDriver
   end
 
   feature :instances, :user_data
+  feature :instances, :create_multiple_instance
   feature :instances, :authentication_key
   feature :images, :owner_id
 
@@ -180,6 +181,8 @@ class EC2Driver < Deltacloud::BaseDriver
       hwp = find_hardware_profile(credentials, opts[:hwp_id], image.id)
       ec2_instances = ec2.run_instances(
         :image_id => image.id,
+        :min_count => opts[:amount].to_i || 1,
+        :max_count => opts[:amount].to_i || 1,
         :user_data => opts[:user_data],
         :key_name => opts[:keyname],
         :availability_zone => realm_id,
-- 
1.7.2


Mime
View raw message