Return-Path: X-Original-To: apmail-cloudstack-dev-archive@www.apache.org Delivered-To: apmail-cloudstack-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D4488181D8 for ; Fri, 18 Dec 2015 13:39:05 +0000 (UTC) Received: (qmail 85375 invoked by uid 500); 18 Dec 2015 13:39:05 -0000 Delivered-To: apmail-cloudstack-dev-archive@cloudstack.apache.org Received: (qmail 85318 invoked by uid 500); 18 Dec 2015 13:39:05 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 85307 invoked by uid 99); 18 Dec 2015 13:39:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Dec 2015 13:39:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E5D14DFF93; Fri, 18 Dec 2015 13:39:04 +0000 (UTC) From: voloshanenko To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request: CLOUDSTACK-8302: Removing snapshots on RB... Content-Type: text/plain Message-Id: <20151218133904.E5D14DFF93@git1-us-west.apache.org> Date: Fri, 18 Dec 2015 13:39:04 +0000 (UTC) Github user voloshanenko commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1230#discussion_r48025223 --- Diff: plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java --- @@ -1274,7 +1274,45 @@ 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 snapshot " + snapshotFullPath); + image.snapUnprotect(snapshotName); + } + image.snapRemove(snapshotName); + s_logger.info("Snapshot " + snapshotFullPath + " successfully removed."); + } finally { + rbd.close(image); + r.ioCtxDestroy(io); + } + } else { + s_logger.warn("Operation not implemented!"); + throw new InternalErrorException("Operation not implemented!"); --- End diff -- Wido, what do your mean? Improve s_logger.info messages? And include shared/dedicated message for pool type? Because if you mean RBD pool type - it's already included into message " .. remove RBD sn..." --- 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 infrastructure@apache.org or file a JIRA ticket with INFRA. ---