cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wido <...@git.apache.org>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-8302: Removing snapshots on RB...
Date Sun, 20 Dec 2015 09:48:28 GMT
Github user wido commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1230#discussion_r48101628
  
    --- 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.");
    --- End diff --
    
    I would add the path of the snapshot here: pool/image@snap. Logs should be easy to consume


---
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.
---

Mime
View raw message