Github user dmytro-shevchenko commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/1230#discussion_r48097934
  
    --- 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 --
    
    Storage pool type added to messages.


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

Reply via email to