incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 13/13] Expose security_group feature for EC2
Date Tue, 16 Nov 2010 11:41:08 GMT
From: Michal Fojtik <mfojtik@redhat.com>

---
 server/lib/deltacloud/base_driver/features.rb   |    8 ++++++++
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb |    2 ++
 tests/ec2/api.feature                           |    1 +
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/server/lib/deltacloud/base_driver/features.rb b/server/lib/deltacloud/base_driver/features.rb
index 5a8db6c..46f556d 100644
--- a/server/lib/deltacloud/base_driver/features.rb
+++ b/server/lib/deltacloud/base_driver/features.rb
@@ -184,5 +184,13 @@ module Deltacloud
       end
     end
 
+    declare_feature :instances, :security_group do
+      description "Put instance in one or more security groups on launch"
+      operation :create do
+        param :security_group, :array, :optional, nil, "Array of security group names"
+      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 07ae7af..c73b867 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -42,6 +42,7 @@ module Deltacloud
         feature :instances, :user_data
         feature :instances, :authentication_key
         feature :instances, :public_ip
+        feature :instances, :security_group
         feature :images, :owner_id
         feature :buckets, :bucket_location
 
@@ -171,6 +172,7 @@ module Deltacloud
           instance_options.merge!(:key_name => opts[:key_name]) if opts[:key_name]
           instance_options.merge!(:availability_zone => opts[:availability_zone]) if opts[:availability_zone]
           instance_options.merge!(:instance_type => opts[:hwp_id]) if opts[:hwp_id]
+          instance_options.merge!(:group_ids => opts[:security_group]) if opts[:security_group]
           safely do
             new_instance = convert_instance(ec2.launch_instances(image_id, instance_options).first)
             if opts[:public_ip]
diff --git a/tests/ec2/api.feature b/tests/ec2/api.feature
index f289e87..740c511 100644
--- a/tests/ec2/api.feature
+++ b/tests/ec2/api.feature
@@ -51,3 +51,4 @@ Feature: Accessing API entry points
     | authentication_key |
     | user_data |
     | public_ip |
+    | security_group |
-- 
1.7.3.2


Mime
View raw message