incubator-deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 10/14] Fixed some small bugs in EC2 driver
Date Mon, 15 Nov 2010 12:46:52 GMT
From: Michal Fojtik <mfojtik@redhat.com>

---
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index a0fd919..c58c1b4 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -143,7 +143,7 @@ module Deltacloud
 
         def realms(credentials, opts={})
           ec2 = new_client(credentials)
-          zone_id = opts ? opts[:id] : []
+          zone_id = opts ? opts[:id] : nil
           safely do
             return ec2.describe_availability_zones(zone_id).collect do |realm|
               convert_realm(realm)
@@ -200,7 +200,7 @@ module Deltacloud
           ec2 = new_client(credentials)
           opts ||= {}
           safely do
-            ec2.describe_key_pairs(opts[:id] || []).collect do |key|
+            ec2.describe_key_pairs(opts[:id] || nil).collect do |key|
               convert_key(key)
             end
           end
@@ -212,12 +212,21 @@ module Deltacloud
 
         def create_key(credentials, opts={})
           ec2 = new_client(credentials)
-          puts opts.inspect
           safely do
             convert_key(ec2.create_key_pair(opts[:key_name]))
           end
         end
 
+        def destroy_key(credentials, opts={})
+          ec2 = new_client(credentials)
+          original_key = key(credentials, opts)
+          safely do
+            ec2.delete_key_pair(original_key.id)
+            original_key= original_key.state = "DELETED"
+          end
+          original_key
+        end
+
         def buckets(credentials, opts)
           buckets = []
           safely do
@@ -273,7 +282,7 @@ module Deltacloud
 
         def storage_volumes(credentials, opts={})
           ec2 = new_client( credentials )
-          volume_list = (opts and opts[:id]) ? opts[:id] : []
+          volume_list = (opts and opts[:id]) ? opts[:id] : nil
           safely do
             ec2.describe_volumes(volume_list).collect do |volume|
               convert_volume(volume)
@@ -409,7 +418,8 @@ module Deltacloud
             :id => key[:aws_key_name],
             :fingerprint => key[:aws_fingerprint],
             :credential_type => :key,
-            :pem_rsa_key => key[:aws_material]
+            :pem_rsa_key => key[:aws_material],
+            :state => "AVAILABLE"
           )
         end
 
-- 
1.7.3.2


Mime
View raw message