Github user wido commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1230#discussion_r48101631 --- Diff: plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java --- @@ -1274,7 +1274,46 @@ public Answer createVolumeFromSnapshot(final CopyCommand cmd) { @Override public Answer deleteSnapshot(final DeleteCommand cmd) { - return new Answer(cmd); + try { + SnapshotObjectTO snapshotTO = (SnapshotObjectTO) cmd.getData(); + PrimaryDataStoreTO primaryStore = (PrimaryDataStoreTO) snapshotTO.getDataStore(); + VolumeObjectTO volume = snapshotTO.getVolume(); + String snapshotFullPath = snapshotTO.getPath(); + String snapshotName = snapshotFullPath.substring(snapshotFullPath.lastIndexOf("/") + 1); + KVMStoragePool primaryPool = storagePoolMgr.getStoragePool(primaryStore.getPoolType(), primaryStore.getUuid()); + KVMPhysicalDisk disk = storagePoolMgr.getPhysicalDisk(primaryStore.getPoolType(), primaryStore.getUuid(), volume.getPath()); + if (primaryPool.getType() == StoragePoolType.RBD) { + Rados r = new Rados(primaryPool.getAuthUserName()); + r.confSet("mon_host", primaryPool.getSourceHost() + ":" + primaryPool.getSourcePort()); + r.confSet("key", primaryPool.getAuthSecret()); + r.confSet("client_mount_timeout", "30"); + r.connect(); + s_logger.debug("Succesfully connected to Ceph cluster at " + r.confGet("mon_host")); + IoCTX io = r.ioCtxCreate(primaryPool.getSourceDir()); + Rbd rbd = new Rbd(io); + RbdImage image = rbd.open(disk.getName()); + try { + s_logger.info("Attempting to remove RBD snapshot " + disk.getName() + "@" + snapshotName); + if (image.snapIsProtected(snapshotName)) { + s_logger.debug("Unprotecting RBD snapshot " + snapshotFullPath); + image.snapUnprotect(snapshotName); + } + image.snapRemove(snapshotName); + s_logger.info("Snapshot " + snapshotFullPath + " successfully removed from " + + primaryPool.getType().toString() + " pool."); + } finally { + rbd.close(image); + r.ioCtxDestroy(io); + } + } else { + s_logger.warn("Operation not implemented for storage pool type of " + primaryPool.getType().toString()); + throw new InternalErrorException("Operation not implemented for storage pool type of " + primaryPool.getType().toString()); + } + return new Answer(cmd, true, "Snapshot removed successfully."); + } catch (Exception e) { + s_logger.error(e.getMessage()); + return new Answer(cmd, false, "Failed to remove snapshot!"); --- End diff -- Same here. Tell which snapshot couldn't be removed
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---