Search in sources :

Example 1 with VNXeBlockDeleteSnapshotJob

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

the class VNXeSnapshotOperation method deleteGroupSnapshots.

@Override
public void deleteGroupSnapshots(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        List<BlockSnapshot> snapshots = _dbClient.queryObject(BlockSnapshot.class, Arrays.asList(snapshot));
        BlockSnapshot snapshotObj = snapshots.get(0);
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeLunGroupSnap lunGroupSnap = apiClient.getLunGroupSnapshot(snapshotObj.getReplicationGroupInstance());
        if (lunGroupSnap != null) {
            VNXeCommandJob job = apiClient.deleteLunGroupSnap(lunGroupSnap.getId());
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockDeleteSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
            } else {
                // Should not take this path, but treat as an error if we do
                // happen to get a null job due to some error in the client.
                _log.error("Unexpected null job from VNXe client call to delete group snapshot.");
                ServiceCoded sc = DeviceControllerExceptions.vnxe.nullJobForDeleteGroupSnapshot(snapshotObj.forDisplay(), snapshotObj.getReplicationGroupInstance());
                taskCompleter.error(_dbClient, sc);
            }
        } else {
            // Treat as in the single volume snapshot case and presume
            // the group snapshot has already been deleted.
            List<BlockSnapshot> grpSnapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
            for (BlockSnapshot grpSnapshot : grpSnapshots) {
                grpSnapshot.setInactive(true);
                grpSnapshot.setIsSyncActive(false);
            }
            _dbClient.updateObject(grpSnapshots);
            taskCompleter.ready(_dbClient);
        }
    } catch (VNXeException e) {
        _log.error("Delete group snapshot got the exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _log.error("Delete group snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeletGroupSnapshot", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) VNXeLunGroupSnap(com.emc.storageos.vnxe.models.VNXeLunGroupSnap) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) VNXeException(com.emc.storageos.vnxe.VNXeException) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VNXeBlockDeleteSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockDeleteSnapshotJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 2 with VNXeBlockDeleteSnapshotJob

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

the class VNXeSnapshotOperation method deleteSingleVolumeSnapshot.

@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snap = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeLunSnap lunSnap = apiClient.getLunSnapshot(snap.getNativeId());
        if (lunSnap != null) {
            VNXeCommandJob job = apiClient.deleteLunSnap(lunSnap.getId());
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockDeleteSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
            }
        } else {
            // Perhaps, it's already been deleted or was deleted on the array.
            // In that case, we'll just say all is well, so that this operation
            // is idempotent.
            snap.setInactive(true);
            snap.setIsSyncActive(false);
            _dbClient.updateObject(snap);
            taskCompleter.ready(_dbClient);
        }
    } catch (VNXeException e) {
        _log.error("Delete volume snapshot got the exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _log.error("Delete volume snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteSnapshot", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VNXeBlockDeleteSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockDeleteSnapshotJob) VNXeLunSnap(com.emc.storageos.vnxe.models.VNXeLunSnap) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)2 VNXeException (com.emc.storageos.vnxe.VNXeException)2 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)2 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)2 VNXeBlockDeleteSnapshotJob (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockDeleteSnapshotJob)2 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 VNXeLunGroupSnap (com.emc.storageos.vnxe.models.VNXeLunGroupSnap)1 VNXeLunSnap (com.emc.storageos.vnxe.models.VNXeLunSnap)1