deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvl...@redhat.com
Subject [PATCH 1/2] Proposed fix for DTACLOUD-379
Date Tue, 11 Dec 2012 22:27:12 GMT
From: marios <marios@redhat.com>

https://issues.apache.org/jira/browse/DTACLOUD-379

Signed-off-by: marios <marios@redhat.com>
TrackedAt: http://tracker-mfojtik.rhcloud.com/patch/6e465c4a530f4715cc11a2db14b84a1c349e513b
---
 server/lib/deltacloud/drivers/exceptions.rb         | 8 ++++++++
 server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb | 8 +++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/server/lib/deltacloud/drivers/exceptions.rb b/server/lib/deltacloud/drivers/exceptions.rb
index 7bbf510..5663dae 100644
--- a/server/lib/deltacloud/drivers/exceptions.rb
+++ b/server/lib/deltacloud/drivers/exceptions.rb
@@ -58,6 +58,13 @@ module Deltacloud
       end
     end
 
+    class Conflict < DeltacloudException
+      def initialize(e, message=nil)
+        message ||= e.message
+        super(409, e.class.name, message, e.backtrace)
+      end
+    end
+
     class MethodNotAllowed < DeltacloudException
       def initialize(e, message=nil)
         message ||= e.message
@@ -157,6 +164,7 @@ module Deltacloud
           when 406 then UnknownMediaTypeError.new(e, @message)
           when 405 then MethodNotAllowed.new(e, @message)
           when 400 then ValidationFailure.new(e, @message)
+          when 409 then Conflict.new(e, @message)
           when 500 then BackendError.new(e, @message)
           when 501 then NotImplemented.new(e, @message)
           when 502 then ProviderError.new(e, @message)
diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index 37e6622..7709be4 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -118,9 +118,7 @@ class RhevmDriver < Deltacloud::BaseDriver
   def destroy_image(credentials, image_id)
     client = new_client(credentials)
     safely do
-      unless client.destroy_template(image_id)
-        raise "ERROR: Unable to remove image"
-      end
+      client.destroy_template(image_id)
     end
   end
 
@@ -342,6 +340,10 @@ class RhevmDriver < Deltacloud::BaseDriver
       status 404
     end
 
+    on /(Cannot delete Template. Template is being used)/ do
+      status 409
+    end
+
     on /(RestClient|RHEVM|OVIRT)/ do
       status 500
     end
-- 
1.7.11.7


Mime
View raw message