Search in sources :

Example 41 with DeviceControllerException

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

the class BlockSnapshotSessionRelinkTargetCompleter method complete.

/**
 * {@inheritDoc}
 */
@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        switch(status) {
            case error:
                break;
            case ready:
                // Remove the linked targets from the linked targets list for their
                // current snapshot session and add them to the linked targets for
                // the target session.
                BlockSnapshotSession tgtSnapSession = dbClient.queryObject(BlockSnapshotSession.class, getId());
                StringSet tgtSnapSessionTargets = tgtSnapSession.getLinkedTargets();
                List<BlockSnapshotSession> snaphotSessionsList = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getLinkedTargetSnapshotSessionConstraint(_snapshotURI));
                if (snaphotSessionsList.isEmpty()) {
                    // The target is not linked to an active snapshot session.
                    throw DeviceControllerException.exceptions.unexpectedCondition(String.format("Cound not find active snapshot session for linked target %s", _snapshotURI));
                }
                // A target can only be linked to a single session.
                BlockSnapshotSession currentSnapSession = snaphotSessionsList.get(0);
                BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, _snapshotURI);
                List<BlockSnapshot> relatedSnapshots = getRelatedSnapshots(snapshot, dbClient);
                for (BlockSnapshot relatedSnapshot : relatedSnapshots) {
                    // snapshot sessions.
                    if (!currentSnapSession.getId().equals(getId())) {
                        String snapshotId = relatedSnapshot.getId().toString();
                        // Remove from the current snapshot session.
                        StringSet currentSnapSessionTargets = currentSnapSession.getLinkedTargets();
                        currentSnapSessionTargets.remove(snapshotId);
                        dbClient.updateObject(currentSnapSession);
                        // Add to the target snapshot session.
                        if (tgtSnapSessionTargets == null) {
                            tgtSnapSessionTargets = new StringSet();
                            tgtSnapSession.setLinkedTargets(tgtSnapSessionTargets);
                        }
                        tgtSnapSessionTargets.add(snapshotId);
                        dbClient.updateObject(tgtSnapSession);
                    }
                }
                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 re-link target volume step {} with status: {}", getOpId(), status.name());
    } catch (Exception e) {
        s_logger.error("Failed updating status for re-link target volume 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 42 with DeviceControllerException

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

the class BlockSnapshotSessionRestoreWorkflowCompleter method complete.

/**
 * {@inheritDoc}
 */
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    URI snapSessionURI = getId();
    try {
        if (_updateOpStatus) {
            BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
            List<BlockObject> allSources = getAllSources(snapSession, dbClient);
            BlockObject sourceObj = allSources.get(0);
            // Record the results.
            recordBlockSnapshotSessionOperation(dbClient, OperationTypeEnum.RESTORE_SNAPSHOT_SESSION, status, snapSession, sourceObj);
            // Update the status map of the snapshot session.
            switch(status) {
                case error:
                    setErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSession.getId(), coded);
                    break;
                case ready:
                    setReadyOnDataObject(dbClient, BlockSnapshotSession.class, snapSession.getId());
                    break;
                case suspended_error:
                    setSuspendedErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSession.getId(), coded);
                    break;
                case suspended_no_error:
                    setSuspendedNoErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSession.getId());
                    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 restore snapshot session task {} with status: {}", getOpId(), status.name());
    } catch (Exception e) {
        s_logger.error("Failed updating status for restore 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 43 with DeviceControllerException

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

the class BlockSnapshotSessionUnlinkTargetsWorkflowCompleter 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, _opType, status, snapSession, sourceObj);
        // Update the status map of the snapshot session.
        switch(status) {
            case error:
                setErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
                break;
            case ready:
                setReadyOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
                break;
            case suspended_error:
                setSuspendedErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
                break;
            case suspended_no_error:
                setSuspendedNoErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
                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 unlink targets from snapshot session task {} with status: {}", getOpId(), status.name());
    } catch (Exception e) {
        s_logger.error("Failed updating status for unlink targets from 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 44 with DeviceControllerException

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

the class ExportAddInitiatorCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
        Operation operation = new Operation();
        switch(status) {
            case error:
                operation.error(coded);
                break;
            case ready:
                operation.ready();
                break;
            case suspended_no_error:
                operation.suspendedNoError();
                break;
            case suspended_error:
                operation.suspendedError(coded);
                break;
            default:
                break;
        }
        exportGroup.getOpStatus().updateTaskStatus(getOpId(), operation);
        _log.info("export_initiator_add: completed");
        _log.info(String.format("Done ExportMaskAddInitiator - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
        for (URI initiatorURI : _initiatorURIs) {
            Initiator initiator = dbClient.queryObject(Initiator.class, initiatorURI);
            recordBlockExportOperation(dbClient, OperationTypeEnum.ADD_EXPORT_INITIATOR, status, eventMessage(status, initiator, exportGroup), exportGroup, initiator);
            if (status.name().equals(Operation.Status.error.name())) {
                exportGroup.removeInitiator(initiator);
            }
        }
        dbClient.updateObject(exportGroup);
    } catch (Exception e) {
        _log.error(String.format("Failed updating status for ExportMaskAddInitiator - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Initiator(com.emc.storageos.db.client.model.Initiator) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 45 with DeviceControllerException

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

the class ExportChangePortGroupCompleter method complete.

@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        String eventMessage = null;
        log.info("Change port group completer:" + status.name());
        ExportGroup exportGroup = dbClient.queryObject(ExportGroup.class, getId());
        Operation operation = new Operation();
        switch(status) {
            case error:
                operation.error(coded);
                eventMessage = String.format(EXPORT_CHANGE_PORT_GROUP_FAILED_MSG, exportGroup.getLabel());
                break;
            case ready:
                operation.ready();
                updateVolumeExportPathParam(dbClient);
                eventMessage = String.format(EXPORT_CHANGE_PORT_GROUP_MSG, exportGroup.getLabel());
                break;
            case suspended_no_error:
                operation.suspendedNoError();
                eventMessage = String.format(EXPORT_CHANGE_PORT_GROUP_SUSPENDED_MSG, exportGroup.getLabel());
                break;
            case suspended_error:
                operation.suspendedError(coded);
                eventMessage = String.format(EXPORT_CHANGE_PORT_GROUP_SUSPENDED_MSG, exportGroup.getLabel());
                break;
            default:
                break;
        }
        exportGroup.getOpStatus().updateTaskStatus(getOpId(), operation);
        dbClient.updateObject(exportGroup);
        log.info(String.format("Done Export change port group - Id: %s, OpId: %s, status: %s", getId().toString(), getOpId(), status.name()));
        recordBlockExportOperation(dbClient, OperationTypeEnum.EXPORT_CHANGE_PORT_GROUP, status, eventMessage, exportGroup);
    } catch (Exception e) {
        log.error(String.format("Failed updating status for Export change port group - Id: %s, OpId: %s", getId().toString(), getOpId()), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Operation(com.emc.storageos.db.client.model.Operation) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

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