deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@redhat.com
Subject [PATCH core 2/2] EC2: Fix storage_volumes not return exception on unknown id
Date Mon, 13 Aug 2012 13:31:32 GMT
From: Michal Fojtik <mfojtik@redhat.com>

* When non-exist storage_volume id was used, the storage_volumes
  returned exception instead of empty arr.

Signed-off-by: Michal fojtik <mfojtik@redhat.com>
---
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 79dd9d2..551bed9 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -627,11 +627,19 @@ module Deltacloud
 
         def storage_snapshots(credentials, opts={})
           ec2 = new_client(credentials)
-          snapshot_list = (opts and opts[:id]) ? [opts[:id]] : []
+          snapshot_list = opts[:id] ? [opts[:id]] : []
           safely do
+            begin
             ec2.describe_snapshots(snapshot_list).collect do |snapshot|
               convert_snapshot(snapshot)
             end
+            rescue => e
+              if e.message =~ /NotFound/
+                []
+              else
+                raise e
+              end
+            end
           end
         end
 
-- 
1.7.10.2


Mime
View raw message