Search in sources :

Example 21 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class BlockSnapshotRestoreCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, getId());
        Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
        if (_updateAndRecordOp) {
            if (snapshot.getConsistencyGroup() != null) {
                // For snapshot based on a consistency group, set status and send
                // events for all related snaps
                List<BlockSnapshot> snaps = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, dbClient);
                for (BlockSnapshot snap : snaps) {
                    URI uri = snap.getId();
                    BlockSnapshot it = dbClient.queryObject(BlockSnapshot.class, uri);
                    switch(status) {
                        case error:
                            dbClient.error(BlockSnapshot.class, uri, getOpId(), coded);
                            break;
                        default:
                            dbClient.ready(BlockSnapshot.class, uri, getOpId());
                    }
                    recordBlockSnapshotOperation(dbClient, OperationTypeEnum.RESTORE_VOLUME_SNAPSHOT, status, eventMessage(status, volume, it), it, volume);
                    _log.info(String.format("Completed CG snapshot restore of snap %s (%s), with status %s", it.getLabel(), uri.toString(), status.name()));
                }
            } else {
                switch(status) {
                    case error:
                        dbClient.error(BlockSnapshot.class, getId(), getOpId(), coded);
                        break;
                    default:
                        dbClient.ready(BlockSnapshot.class, getId(), getOpId());
                }
                recordBlockSnapshotOperation(dbClient, OperationTypeEnum.RESTORE_VOLUME_SNAPSHOT, status, eventMessage(status, volume, snapshot), snapshot, volume);
            }
        }
        _log.info("Done SnapshotRestore {}, with Status: {}", getOpId(), status.name());
        super.complete(dbClient, status, coded);
    } catch (Exception e) {
        _log.error("Failed updating status. SnapshotRestore {}, for task " + getOpId(), getId(), e);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 22 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class BlockSnapshotResyncCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, getId());
        Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
        if (_updateAndRecordOp) {
            if (snapshot.getConsistencyGroup() != null) {
                // For snapshot based on a consistency group, set status and send
                // events for all related snaps
                List<BlockSnapshot> snaps = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, dbClient);
                for (BlockSnapshot snap : snaps) {
                    URI uri = snap.getId();
                    BlockSnapshot it = dbClient.queryObject(BlockSnapshot.class, uri);
                    switch(status) {
                        case error:
                            dbClient.error(BlockSnapshot.class, uri, getOpId(), coded);
                            break;
                        default:
                            dbClient.ready(BlockSnapshot.class, uri, getOpId());
                    }
                    recordBlockSnapshotOperation(dbClient, OperationTypeEnum.RESYNCHRONIZE_VOLUME_SNAPSHOT, status, eventMessage(status, volume, it), it, volume);
                    _log.info(String.format("Completed CG snapshot resynchronization of snap %s (%s), with status %s", it.getLabel(), uri.toString(), status.name()));
                }
            } else {
                switch(status) {
                    case error:
                        dbClient.error(BlockSnapshot.class, getId(), getOpId(), coded);
                        break;
                    default:
                        dbClient.ready(BlockSnapshot.class, getId(), getOpId());
                }
                recordBlockSnapshotOperation(dbClient, OperationTypeEnum.RESYNCHRONIZE_VOLUME_SNAPSHOT, status, eventMessage(status, volume, snapshot), snapshot, volume);
            }
        }
        _log.info("Done Resync Snapshot {}, with Status: {}", getOpId(), status.name());
        super.complete(dbClient, status, coded);
    } catch (Exception e) {
        _log.error("Failed updating status. SnapshotResync {}, for task " + getOpId(), getId(), e);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 23 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class BlockSnapshotSessionCreateCompleter method complete.

/**
 * {@inheritDoc}
 */
@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, getId());
        // Update the status map of the snapshot session.
        switch(status) {
            case error:
                // Mark any linked targets inactive. This would not
                // normally case when failing to create a snapshot
                // session as targets are not linked when a new
                // snapshot session is prepared in ViPR. However,
                // it could be the case when restoring a source volume
                // form a linked target.
                StringSet linkedTargets = snapSession.getLinkedTargets();
                if ((linkedTargets != null) && (!linkedTargets.isEmpty())) {
                    for (String linkedTarget : linkedTargets) {
                        BlockSnapshot target = dbClient.queryObject(BlockSnapshot.class, URI.create(linkedTarget));
                        if (target != null) {
                            target.setInactive(true);
                            dbClient.updateObject(target);
                        }
                    }
                }
                // Mark ViPR snapshot session inactive on error.
                snapSession.setInactive(true);
                dbClient.updateObject(snapSession);
                break;
            case ready:
                break;
            default:
                String errMsg = String.format("Unexpected status %s for completer for step %s", status.name(), getOpId());
                s_logger.info(errMsg);
                throw DeviceControllerException.exceptions.unexpectedCondition(errMsg);
        }
        s_logger.info("Done snapshot session create step {} with status: {}", getOpId(), status.name());
    } catch (Exception e) {
        s_logger.error("Failed updating status for snapshot session create step {}", getOpId(), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) StringSet(com.emc.storageos.db.client.model.StringSet) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 24 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class BlockSnapshotSessionDeleteWorkflowCompleter method complete.

/**
 * {@inheritDoc}
 */
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    URI snapSessionURI = getId();
    try {
        BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
        List<BlockObject> allSources = getAllSources(snapSession, dbClient);
        BlockObject sourceObj = allSources.get(0);
        // Record the results.
        recordBlockSnapshotSessionOperation(dbClient, OperationTypeEnum.DELETE_SNAPSHOT_SESSION, status, snapSession, sourceObj);
        // Update the status map of the snapshot session.
        switch(status) {
            case error:
                setErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
                break;
            case suspended_error:
                setSuspendedErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
                break;
            case suspended_no_error:
                setSuspendedNoErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
                break;
            case ready:
                setReadyOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
                // Mark snapshot session inactive.
                snapSession.setInactive(true);
                dbClient.updateObject(snapSession);
                break;
            default:
                String errMsg = String.format("Unexpected status %s for completer for task %s", status.name(), getOpId());
                s_logger.info(errMsg);
                throw DeviceControllerException.exceptions.unexpectedCondition(errMsg);
        }
        s_logger.info("Done delete snapshot session task {} with status: {}", getOpId(), status.name());
    } catch (Exception e) {
        s_logger.error("Failed updating status for delete snapshot session task {}", getOpId(), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 25 with DeviceControllerException

use of com.emc.storageos.exceptions.DeviceControllerException in project coprhd-controller by CoprHD.

the class HDSMirrorOperations method detachSingleVolumeMirror.

/**
 * 1. Delete ShadowImage Pair
 * 2. Delete DummyLunPath from secondary volume
 */
@Override
public void detachSingleVolumeMirror(StorageSystem storage, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    NamedURI sourceVolumeURI = null;
    try {
        BlockMirror mirrorObj = dbClient.queryObject(BlockMirror.class, mirror);
        // TODO needs to sync pair and wait for synchronization here
        Volume source = dbClient.queryObject(Volume.class, mirrorObj.getSource());
        sourceVolumeURI = mirrorObj.getSource();
        boolean status = hdsProtectionOperations.modifyShadowImagePair(storage, source.getNativeId(), mirrorObj.getNativeId(), HDSApiProtectionManager.ShadowImageOperationType.split);
        if (status) {
            String taskId = UUID.randomUUID().toString();
            TaskCompleter completer = new SimpleTaskCompleter(BlockMirror.class, mirror, taskId);
            HDSJob syncjob = new HDSReplicationSyncJob(storage.getId(), source.getNativeId(), mirrorObj.getNativeId(), ReplicationStatus.SPLIT, completer);
            hdsCommandHelper.waitForAsyncHDSJob(syncjob);
        } else {
            log.info("Replication info is not available on pair management server");
        }
        hdsProtectionOperations.deleteShadowImagePair(storage, source, mirrorObj);
        hdsProtectionOperations.removeDummyLunPath(storage, mirror);
        taskCompleter.ready(dbClient);
    } catch (Exception e) {
        String errorMsg = String.format(DETACH_ERROR_MSG_FORMAT, mirror, sourceVolumeURI != null ? sourceVolumeURI.toString() : HDSConstants.SPACE_STR);
        log.error(errorMsg, e);
        ServiceError serviceError = DeviceControllerErrors.hds.methodFailed("detachSingleVolumeMirror", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : HDSReplicationSyncJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSReplicationSyncJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HDSException(com.emc.storageos.hds.HDSException)

Aggregations

DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)393 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)211 URI (java.net.URI)157 Volume (com.emc.storageos.db.client.model.Volume)115 ArrayList (java.util.ArrayList)115 WBEMException (javax.wbem.WBEMException)113 CIMObjectPath (javax.cim.CIMObjectPath)104 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)85 ExportMask (com.emc.storageos.db.client.model.ExportMask)83 CIMArgument (javax.cim.CIMArgument)81 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)75 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)63 BlockObject (com.emc.storageos.db.client.model.BlockObject)55 HashMap (java.util.HashMap)54 Initiator (com.emc.storageos.db.client.model.Initiator)52 HashSet (java.util.HashSet)52 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)48 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)46 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)46 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)43