Search in sources :

Example 1 with VNXeBlockRestoreSnapshotJob

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

the class VNXeSnapshotOperation method restoreGroupSnapshots.

@Override
public void restoreGroupSnapshots(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeLunGroupSnap lunGroupSnap = apiClient.getLunGroupSnapshot(snapshotObj.getReplicationGroupInstance());
        // Error out if the snapshot is attached
        if (lunGroupSnap.getIsAttached()) {
            _log.error("Snapshot {})is attached and cannot be used for restore", snapshotObj.getLabel());
            ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshot.toString());
            taskCompleter.error(_dbClient, error);
        }
        VNXeCommandJob job = apiClient.restoreLunGroupSnap(lunGroupSnap.getId());
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
        }
    } catch (VNXeException e) {
        _log.error("Restore group snapshot got the exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _log.error("Restore group snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("RestoreSnapshotJob", 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) VNXeBlockRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockRestoreSnapshotJob) VNXeException(com.emc.storageos.vnxe.VNXeException) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 2 with VNXeBlockRestoreSnapshotJob

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

the class VNXeSnapshotOperation method restoreSingleVolumeSnapshot.

@Override
public void restoreSingleVolumeSnapshot(StorageSystem storage, URI volume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeLunSnap lunSnap = apiClient.getLunSnapshot(snapshotObj.getNativeId());
        // Error out if the snapshot is attached
        if (lunSnap.getIsAttached()) {
            _log.error("Snapshot {})is attached and cannot be used for restore", snapshotObj.getLabel());
            ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshot.toString());
            taskCompleter.error(_dbClient, error);
        }
        VNXeCommandJob job = apiClient.restoreLunSnap(lunSnap.getId());
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
        }
    } catch (VNXeException e) {
        _log.error("Restore snapshot got the exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _log.error("Restore snapshot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("RestoreSnapshotJob", 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) VNXeBlockRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockRestoreSnapshotJob) VNXeException(com.emc.storageos.vnxe.VNXeException) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) 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 VNXeBlockRestoreSnapshotJob (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeBlockRestoreSnapshotJob)2 VNXeLunGroupSnap (com.emc.storageos.vnxe.models.VNXeLunGroupSnap)1 VNXeLunSnap (com.emc.storageos.vnxe.models.VNXeLunSnap)1