Search in sources :

Example 1 with VNXUnityRestoreSnapshotJob

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

the class VNXUnitySnapshotOperations 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);
        Snap groupSnap = apiClient.getSnapshot(snapshotObj.getReplicationGroupInstance());
        Snap snap = apiClient.getSnapshot(snapshotObj.getNativeId());
        // Error out if the snapshot is attached
        if (snap.isAttached()) {
            log.error("Snapshot {})is exported and cannot be used for restore", snapshotObj.getLabel());
            ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshotObj.getLabel());
            taskCompleter.error(_dbClient, error);
        }
        VNXeCommandJob job = apiClient.restoreSnap(groupSnap.getId());
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new VNXUnityRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
        }
    } 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) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXUnityRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityRestoreSnapshotJob) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Snap(com.emc.storageos.vnxe.models.Snap) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 2 with VNXUnityRestoreSnapshotJob

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

the class VNXUnitySnapshotOperations 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);
        Snap snap = apiClient.getSnapshot(snapshotObj.getNativeId());
        // Error out if the snapshot is attached
        if (snap.isAttached()) {
            log.error("Snapshot {})is exported and cannot be used for restore, please unexport it first", snapshotObj.getLabel());
            ServiceError error = DeviceControllerErrors.vnxe.cannotRestoreAttachedSnapshot(snapshotObj.getLabel());
            taskCompleter.error(_dbClient, error);
        }
        VNXeCommandJob job = apiClient.restoreSnap(snap.getId());
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new VNXUnityRestoreSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
        }
    } 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) VNXUnityRestoreSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityRestoreSnapshotJob) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Snap(com.emc.storageos.vnxe.models.Snap) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) 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 Snap (com.emc.storageos.vnxe.models.Snap)2 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)2 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)2 VNXUnityRestoreSnapshotJob (com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityRestoreSnapshotJob)2