CLOUDSTACK-4665: Check if a snapshot is protected before trying to unprotect

Otherwise a RBDException will be thrown with the message that the snapshot
isn't protected.

Conflicts:

	plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
This commit is contained in:
Wido den Hollander 2014-04-10 05:28:56 +02:00
parent 4e9810dd51
commit 75792bf08e
1 changed files with 7 additions and 1 deletions

View File

@ -764,7 +764,13 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
RbdImage image = rbd.open(uuid);
List<RbdSnapInfo> snaps = image.snapList();
for (RbdSnapInfo snap : snaps) {
image.snapUnprotect(snap.name);
if (image.snapIsProtected(snap.name)) {
s_logger.debug("Unprotecting snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name);
image.snapUnprotect(snap.name);
} else {
s_logger.debug("Snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name + " is not protected.");
}
s_logger.debug("Removing snapshot " + pool.getSourceDir() + "/" + uuid + "@" + snap.name);
image.snapRemove(snap.name);
}