incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject svn commit: r1055010 - in /incubator/deltacloud/trunk: server/lib/deltacloud/drivers/ec2/ec2_driver.rb tests/ec2/api.feature
Date Tue, 04 Jan 2011 12:49:05 GMT
Author: mfojtik
Date: Tue Jan  4 12:49:05 2011
New Revision: 1055010

URL: http://svn.apache.org/viewvc?rev=1055010&view=rev
Log:
Imported endpoint patches from Tobi from previous EC2 gem

Modified:
    incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
    incubator/deltacloud/trunk/tests/ec2/api.feature

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb?rev=1055010&r1=1055009&r2=1055010&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/drivers/ec2/ec2_driver.rb Tue Jan  4
12:49:05 2011
@@ -44,6 +44,8 @@ module Deltacloud
         feature :images, :owner_id
         feature :buckets, :bucket_location
 
+        DEFAULT_REGION = 'us-east-1'
+
         define_hardware_profile('t1.micro') do
           cpu                1
           memory             0.63 * 1024
@@ -183,9 +185,6 @@ module Deltacloud
           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]
-              ec2.associate_address(new_instance.id, opts[:public_ip])
-            end
             if opts[:name]
               tag_instance(credentials, new_instance, opts[:name])
             end
@@ -226,10 +225,6 @@ module Deltacloud
           end
         end
 
-        def key(credentials, opts={})
-          keys(credentials, :id => opts[:id]).first
-        end
-
         def create_key(credentials, opts={})
           ec2 = new_client(credentials)
           safely do
@@ -324,14 +319,18 @@ module Deltacloud
         #--  
         def delete_blob(credentials, bucket_id, blob_id, opts=nil)
           s3_client = new_client(credentials, :s3)
-          s3_client.interface.delete(bucket_id, blob_id)
+          safely do
+            s3_client.interface.delete(bucket_id, blob_id)
+          end
         end
 
 
         def blob_data(credentials, bucket_id, blob_id, opts)
           s3_client = new_client(credentials, :s3)
-          s3_client.interface.get(bucket_id, blob_id) do |chunk|
-            yield chunk
+          safely do
+            s3_client.interface.get(bucket_id, blob_id) do |chunk|
+              yield chunk
+            end
           end
         end
 
@@ -420,11 +419,24 @@ module Deltacloud
 
         def new_client(credentials, type = :ec2)
           case type
-            when :ec2 then Aws::Ec2.new(credentials.user, credentials.password)
-            when :s3 then Aws::S3.new(credentials.user, credentials.password)
+            when :ec2 then Aws::Ec2.new(credentials.user, credentials.password, :endpoint_url
=> endpoint_for_service(:ec2))
+            when :s3 then Aws::S3.new(credentials.user, credentials.password, :endpoint_url
=> endpoint_for_service(:s3))
           end
         end
 
+        def endpoint_for_service(service)
+          url = ""
+          url << case service
+            when :ec2
+              'ec2.'
+            when :elb
+              'elasticloadbalancing.'
+            end 
+          url << (Thread.current[:provider] || ENV['API_PROVIDER'] || DEFAULT_REGION)
+          url << '.amazonaws.com'
+          url
+        end
+
         def tag_instance(credentials, instance, name)
           ec2 = new_client(credentials)
           safely do

Modified: incubator/deltacloud/trunk/tests/ec2/api.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/ec2/api.feature?rev=1055010&r1=1055009&r2=1055010&view=diff
==============================================================================
--- incubator/deltacloud/trunk/tests/ec2/api.feature (original)
+++ incubator/deltacloud/trunk/tests/ec2/api.feature Tue Jan  4 12:49:05 2011
@@ -50,5 +50,4 @@ Feature: Accessing API entry points
     Then client should get list of features inside 'instances':
     | authentication_key |
     | user_data |
-    | public_ip |
     | security_group |



Mime
View raw message