deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francesco Vollero <fvoll...@redhat.com>
Subject [PATCH core 1/1] EC2: added comments on methods for managing subnets
Date Tue, 26 Feb 2013 15:01:07 GMT

Signed-off-by: Francesco Vollero <fvollero@redhat.com>
---
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 75 +++++++++++++++++--------
 1 file changed, 51 insertions(+), 24 deletions(-)

diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 7f9d588..e66b1b2 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -834,8 +834,9 @@ module Deltacloud
             ec2.manage_security_group_ingress(firewall, from_port, to_port, protocol, "revoke",
addresses, groups)
           end
         end
-
-        #Deltacloud Networks == Amazon VPC
+#--
+#Deltacloud Networks == Amazon VPC
+#--
         def networks(credentials, opts={})
           ec2 = new_client(credentials)
           networks=[]
@@ -863,19 +864,45 @@ module Deltacloud
         end
 
         def subnets(credentials, opts={})
-
+          # Get the list of subnets
+          #
+          # as the gem describe the info
+          # we can get the informations of all the subnets defined
+          # calling describe_subnets without arguments
+          #ec2 = new_client(credentials)
+          #safely do
+          #  ec2.describe_subnets
+          #end
         end
 
         def create_subnet(credentials, opts={})
+          # this method should create the subnet
+          # what he needs is the id of the vpc
+          # and the cidr block you want to allocate
+          # and optionally the availability zone
 
+          #ec2 = new_client(credentials)
+          #safely do
+          #  ec2.create_subnet(opts[:vpc_id], opts[:cidr])
+          #end
         end
 
         def destroy_subnet(credentials, opts={})
+          # this method need to be called
+          # with the subnet_id as parameter
+          # in order to work
 
+          # ec2 = new_client(credentials)
+          # safely do
+          #  ec2.delete_subnet(opts[:id])
+          # end
         end
 
         def ports(credentials, opts={})
-
+          # this method has no direct mapping
+          # on the aws library so my guess is
+          # that we should derive it from something
+          # else that fits. Need to be investigated more.
         end
 
         def providers(credentials, opts={})
@@ -1097,15 +1124,15 @@ module Deltacloud
         def firewall_rule_id(user_id, protocol, from_port, to_port, sources)
           sources_string = ""
           sources.each do |source|
-          if source[:type].to_s == "group"
-            sources_string << "@#{source[:type]},#{source[:owner]},#{source[:name]},"
-          else
-            sources_string << "@#{source[:type]},#{source[:family]},#{source[:address]},#{source[:prefix]},"
+            if source[:type].to_s == "group"
+              sources_string << "@#{source[:type]},#{source[:owner]},#{source[:name]},"
+            else
+              sources_string << "@#{source[:type]},#{source[:family]},#{source[:address]},#{source[:prefix]},"
+            end
           end
-        end
-         #sources_string is @group,297467797945,test@address,ipv4,10.1.1.1,24 etc
-         "#{user_id}~#{protocol}~#{from_port}~#{to_port}~#{sources_string.chomp!(",")}"
-#sources_string.slice(0,sources_string.length-1)}"
+          #sources_string is @group,297467797945,test@address,ipv4,10.1.1.1,24 etc
+          "#{user_id}~#{protocol}~#{from_port}~#{to_port}~#{sources_string.chomp!(",")}"
+          #sources_string.slice(0,sources_string.length-1)}"
         end
 
         #extract params from uid
@@ -1119,26 +1146,26 @@ module Deltacloud
           sources.shift #first match is ""
           addresses = []
           groups = []
-          #@group,297467797945,test@address,ipv4,10.1.1.1,24@address,ipv4,192.168.1.1,24
+          # @group,297467797945,test@address,ipv4,10.1.1.1,24@address,ipv4,192.168.1.1,24
           sources.each do |source|
             current = source.split(",")
             type = current[0]
             case type
-              when 'group'
-                #group,297467797945,test
-                owner = current[1]
-                name = current[2]
-                groups << {'group_name' => name, 'owner' => owner}
-              when 'address'
-                #address,ipv4,10.1.1.1,24
-                address = current[2]
-                address<<"/#{current[3]}"
-                addresses << address
+            when 'group'
+              #group,297467797945,test
+              owner = current[1]
+              name = current[2]
+              groups << {'group_name' => name, 'owner' => owner}
+            when 'address'
+              #address,ipv4,10.1.1.1,24
+              address = current[2]
+              address<<"/#{current[3]}"
+              addresses<<address
             end
           end
           return protocol, from_port, to_port, addresses, groups
         end
-
+        
         #Convert ec2 security group to server/lib/deltacloud/models/firewall
         def convert_security_group(security_group)
           rules = []
-- 
1.8.1.2


Mime
View raw message