Search in sources :

Example 1 with CinderSnapshotDeleteJob

use of com.emc.storageos.volumecontroller.impl.cinder.job.CinderSnapshotDeleteJob in project coprhd-controller by CoprHD.

the class CinderStorageDevice method doDeleteSnapshot.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteSnapshot
     * (com.emc.storageos.db.client.model.StorageSystem,
     * java.net.URI, com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void doDeleteSnapshot(StorageSystem storageSystem, URI snapshotURI, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Snapshot Start - Array:%s", storageSystem.getSerialNumber()));
        log.info(logMsgBuilder.toString());
        BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, snapshotURI);
        CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
        log.info("Getting the cinder APi for the provider with id " + storageSystem.getActiveProviderURI());
        CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
        try {
            cinderApi.showSnapshot(snapshot.getId().toString());
        } catch (CinderException ce) {
            // This means, the snapshot is not present on the back-end device
            log.info(String.format("Snapshot %s already deleted: ", snapshot.getNativeId()));
            snapshot.setInactive(true);
            dbClient.updateObject(snapshot);
            taskCompleter.ready(dbClient);
        }
        // Now - trigger the delete
        cinderApi.deleteSnapshot(snapshot.getNativeId().toString());
        ControllerServiceImpl.enqueueJob(new QueueJob(new CinderSnapshotDeleteJob(snapshot.getNativeId(), snapshot.getLabel(), storageSystem.getId(), CinderConstants.ComponentType.snapshot.name(), ep, taskCompleter)));
    } catch (Exception e) {
        log.error("Problem in doDeleteVolume: ", e);
        ServiceError error = DeviceControllerErrors.cinder.operationFailed("doDeleteSnapshot", e.getMessage());
        taskCompleter.error(dbClient, error);
    }
}
Also used : CinderException(com.emc.storageos.cinder.errorhandling.CinderException) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CinderApi(com.emc.storageos.cinder.api.CinderApi) CinderSnapshotDeleteJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderSnapshotDeleteJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CinderException(com.emc.storageos.cinder.errorhandling.CinderException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

CinderEndPointInfo (com.emc.storageos.cinder.CinderEndPointInfo)1 CinderApi (com.emc.storageos.cinder.api.CinderApi)1 CinderException (com.emc.storageos.cinder.errorhandling.CinderException)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1 CinderSnapshotDeleteJob (com.emc.storageos.volumecontroller.impl.cinder.job.CinderSnapshotDeleteJob)1 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)1