Maor Lipchuk has uploaded a new change for review.

Change subject: core: delete Cinder volumes should be surrounded by try catch.
......................................................................

core: delete Cinder volumes should be surrounded by try catch.

Delete of volume and snapshot from CinderBroker should return a
notification whether it succeeded or not, and should be surrounded with
try catch block to prevent exception when the volume does not exists.

Change-Id: I01811c092f72d8f5409866f308ea7b3c5cfb3ff0
Bug-Url: https://bugzilla.redhat.com/1185826
Signed-off-by: Maor Lipchuk <mlipc...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/CinderBroker.java
1 file changed, 24 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/52/42252/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/CinderBroker.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/CinderBroker.java
index e770119..124cc55 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/CinderBroker.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/CinderBroker.java
@@ -84,12 +84,19 @@
         });
     }
 
-    public Void deleteVolume(final CinderDisk cinderDisk) {
-        return execute(new Callable<Void>() {
+    public boolean deleteVolume(final CinderDisk cinderDisk) {
+        return execute(new Callable<Boolean>() {
             @Override
-            public Void call() {
-                proxy.deleteVolume(cinderDisk.getImageId().toString());
-                return null;
+            public Boolean call() {
+                try {
+                    proxy.deleteVolume(cinderDisk.getImageId().toString());
+                    return true;
+                } catch (OpenStackResponseException ex) {
+                    if (ex.getStatus() == HttpStatus.SC_NOT_FOUND) {
+                        return false;
+                    }
+                    throw ex;
+                }
             }
         });
     }
@@ -128,12 +135,19 @@
         });
     }
 
-    public Void deleteSnapshot(final Guid snapshotId) {
-        return execute(new Callable<Void>() {
+    public boolean deleteSnapshot(final Guid snapshotId) {
+        return execute(new Callable<Boolean>() {
             @Override
-            public Void call() {
-                proxy.deleteSnapshot(snapshotId.toString());
-                return null;
+            public Boolean call() {
+                try {
+                    proxy.deleteSnapshot(snapshotId.toString());
+                    return true;
+                } catch (OpenStackResponseException ex) {
+                    if (ex.getStatus() == HttpStatus.SC_NOT_FOUND) {
+                        return false;
+                    }
+                    throw ex;
+                }
             }
         });
     }


-- 
To view, visit https://gerrit.ovirt.org/42252
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I01811c092f72d8f5409866f308ea7b3c5cfb3ff0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to