Search in sources :

Example 41 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class Documenter method createEntries.

public static Collection<DocumenterEntry> createEntries() {
    final List<Class<?>> list = getMessageBundleClasses();
    _log.info("found these classes to document: {}", list);
    final Collection<DocumenterEntry> entries = new ArrayList<DocumenterEntry>();
    for (final Class<?> interfaze : list) {
        final Object proxy = ExceptionMessagesProxy.create(interfaze);
        final Method[] methods = interfaze.getDeclaredMethods();
        for (final Method method : methods) {
            StatusType status;
            try {
                final Object[] parameters = sampleParameters(method);
                final ServiceCoded sce = (ServiceCoded) method.invoke(proxy, parameters);
                if (sce instanceof StatusCoded) {
                    status = ((StatusCoded) sce).getStatus();
                } else {
                    status = sce.isRetryable() ? Status.SERVICE_UNAVAILABLE : Status.INTERNAL_SERVER_ERROR;
                }
                entries.add(new DocumenterEntry(interfaze, method, status, sce, parameters));
            } catch (final Exception e) {
                _log.error(String.format("Fail to create document entry for method: %s", method), e);
            }
        }
    }
    return entries;
}
Also used : ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) URISyntaxException(java.net.URISyntaxException) FileNotFoundException(java.io.FileNotFoundException) StatusType(javax.ws.rs.core.Response.StatusType) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) StatusCoded(com.emc.storageos.svcs.errorhandling.model.StatusCoded)

Example 42 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class VmaxSnapshotOperations method resumeSnapshot.

/**
 * Routine will call SMI-S ModifyReplicaSynchronization to resume a synchronization instance.
 * The operation is a counter-intuitive; it will terminate a RESTORE session between
 * target and source. This was the suggestion based on input from SMI-S team.
 * See OPT 443785.
 *
 * @param storage [in] - StorageSystem object representing the array
 * @param from [in] - Should be the snapshot object
 * @param blockObject [in] - Should be the volume object
 * @param syncObject [in] - A CIMObjectPath representing the SMI-S synchronization object tying
 *            from and blockObject together, along with other related consistency group members
 * @param taskCompleter [in] - TaskCompleter used for updating status of operation
 * @return true if the resume operation was successfully performed on the synchronization
 * @throws WBEMException
 */
private boolean resumeSnapshot(StorageSystem storage, BlockObject from, BlockObject blockObject, CIMObjectPath syncObject, TaskCompleter taskCompleter) throws WBEMException {
    boolean wasResumed = false;
    SmisBlockResumeSnapshotJob job = new SmisBlockResumeSnapshotJob(null, storage.getId(), new TaskCompleter() {

        @Override
        protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
        }
    });
    CIMArgument[] result = new CIMArgument[5];
    try {
        if (storage.checkIfVmax3()) {
            _helper.invokeMethodSynchronously(storage, _cimPath.getControllerReplicationSvcPath(storage), SmisConstants.MODIFY_SETTINGS_DEFINE_STATE, _helper.getEMCResumeInputArguments(syncObject), result, job);
        } else if (storage.getUsingSmis80()) {
            /**
             * VMAX2 managed by 8.* SMIS
             * We need to pass Operation = 16
             */
            _helper.invokeMethodSynchronously(storage, _cimPath.getControllerReplicationSvcPath(storage), SmisConstants.MODIFY_REPLICA_SYNCHRONIZATION, _helper.getResumeSnapshotSynchronizationInputArguments(syncObject), result, job);
        } else {
            /**
             * VMAX2 managed by 4.6.2 SMI provider
             * We need to pass Operation = 14
             */
            _helper.invokeMethodSynchronously(storage, _cimPath.getControllerReplicationSvcPath(storage), SmisConstants.MODIFY_REPLICA_SYNCHRONIZATION, _helper.getResumeSynchronizationInputArguments(syncObject), result, job);
        }
    } catch (Exception e) {
        /*
             * May be ignored if message is about invalid device state, since when
             * dealing with multiple GroupSynchronized instances, we attempt to resume
             * all of them.
             */
        _log.info("Encountered exception which may be ignored: {}", e.getMessage());
    }
    if (job.isSuccess()) {
        _log.info("Synchronization was successfully resumed: {}", syncObject);
        wasResumed = true;
    } else {
        _log.info("Synchronization was not resumed and can be ignored: {}", syncObject);
    }
    return wasResumed;
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) Operation(com.emc.storageos.db.client.model.Operation) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) SmisBlockResumeSnapshotJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockResumeSnapshotJob) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 43 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class VPlexDeviceController method establishVolumeAndFullCopyGroupRelation.

@Override
public void establishVolumeAndFullCopyGroupRelation(URI storage, URI sourceVolume, URI fullCopy, String opId) throws InternalException {
    try {
        // Generate the Workflow.
        Workflow workflow = _workflowService.getNewWorkflow(this, VOLUME_FULLCOPY_GROUP_RELATION_WF, false, opId);
        _log.info("Created establish volume  and full copy group relation workflow with operation id {}", opId);
        // Get the VPLEX and backend full copy volumes.
        Volume fullCopyVolume = getDataObject(Volume.class, fullCopy, _dbClient);
        Volume nativeFullCopyVolume = VPlexUtil.getVPLEXBackendVolume(fullCopyVolume, true, _dbClient);
        URI nativeSourceVolumeURI = nativeFullCopyVolume.getAssociatedSourceVolume();
        URI nativeSystemURI = nativeFullCopyVolume.getStorageController();
        StorageSystem nativeSystem = getDataObject(StorageSystem.class, nativeSystemURI, _dbClient);
        Workflow.Method establishRelationMethod = new Workflow.Method(VOLUME_FULLCOPY_RELATION_METHOD, nativeSystemURI, nativeSourceVolumeURI, nativeFullCopyVolume.getId());
        workflow.createStep(VOLUME_FULLCOPY_GROUP_RELATION_STEP, "create group relation between Volume group and Full copy group", null, nativeSystemURI, nativeSystem.getSystemType(), BlockDeviceController.class, establishRelationMethod, rollbackMethodNullMethod(), null);
        TaskCompleter completer = new CloneTaskCompleter(fullCopy, opId);
        String successMsg = String.format("Establish volume and full copy %s group relation completed successfully", fullCopy);
        FullCopyOperationCompleteCallback wfCompleteCB = new FullCopyOperationCompleteCallback();
        workflow.executePlan(completer, successMsg, wfCompleteCB, new Object[] { Arrays.asList(fullCopy) }, null, null);
        _log.info("Workflow plan executing");
    } catch (Exception e) {
        String failMsg = String.format("Establish volume and full copy %s group relation failed", fullCopy);
        _log.error(failMsg, e);
        TaskCompleter completer = new CloneTaskCompleter(fullCopy, opId);
        ServiceCoded sc = VPlexApiException.exceptions.establishVolumeFullCopyGroupRelationFailed(fullCopy.toString(), e);
        failStep(completer, opId, sc);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) Workflow(com.emc.storageos.workflow.Workflow) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) MigrationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) MigrationOperationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationOperationTaskCompleter) CacheStatusTaskCompleter(com.emc.storageos.vplexcontroller.completers.CacheStatusTaskCompleter) VplexMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VplexMirrorTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) VolumeGroupUpdateTaskCompleter(com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WorkflowTaskCompleter(com.emc.storageos.workflow.WorkflowTaskCompleter) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 44 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class VPlexDeviceController method restoreFromFullCopy.

/**
 * {@inheritDoc}
 */
@Override
public void restoreFromFullCopy(URI vplexURI, List<URI> fullCopyURIs, String opId) throws InternalException {
    TaskCompleter completer = null;
    try {
        completer = new CloneRestoreCompleter(fullCopyURIs, opId);
        // Generate the Workflow.
        Workflow workflow = _workflowService.getNewWorkflow(this, RESTORE_VOLUME_WF_NAME, false, opId);
        _log.info("Created restore volume workflow with operation id {}", opId);
        // add CG to taskCompleter
        Volume firstFullCopy = getDataObject(Volume.class, fullCopyURIs.get(0), _dbClient);
        BlockObject firstSource = BlockObject.fetch(_dbClient, firstFullCopy.getAssociatedSourceVolume());
        if (!NullColumnValueGetter.isNullURI(firstSource.getConsistencyGroup())) {
            completer.addConsistencyGroupId(firstSource.getConsistencyGroup());
        }
        // Get the VPLEX and backend full copy volumes.
        URI nativeSystemURI = null;
        Map<URI, Volume> vplexFullCopyMap = new HashMap<URI, Volume>();
        Map<URI, Volume> nativeFullCopyMap = new HashMap<URI, Volume>();
        for (URI fullCopyURI : fullCopyURIs) {
            Volume fullCopyVolume = getDataObject(Volume.class, fullCopyURI, _dbClient);
            vplexFullCopyMap.put(fullCopyURI, fullCopyVolume);
            Volume nativeFullCopyVolume = VPlexUtil.getVPLEXBackendVolume(fullCopyVolume, true, _dbClient);
            nativeFullCopyMap.put(nativeFullCopyVolume.getId(), nativeFullCopyVolume);
            if (nativeSystemURI == null) {
                nativeSystemURI = nativeFullCopyVolume.getStorageController();
            }
        }
        // We'll need a list of the native full copy URIs.
        List<URI> nativeFullCopyURIs = new ArrayList<URI>(nativeFullCopyMap.keySet());
        // Get the native system.
        StorageSystem nativeSystem = getDataObject(StorageSystem.class, nativeSystemURI, _dbClient);
        // Maps Vplex volume that needs to be flushed to underlying array volume
        Map<Volume, Volume> vplexToArrayVolumesToFlush = new HashMap<Volume, Volume>();
        for (Volume vplexFullCopyVolume : vplexFullCopyMap.values()) {
            Volume fcSourceVolume = getDataObject(Volume.class, vplexFullCopyVolume.getAssociatedSourceVolume(), _dbClient);
            Volume arrayVolumeToBeRestored = VPlexUtil.getVPLEXBackendVolume(fcSourceVolume, true, _dbClient);
            vplexToArrayVolumesToFlush.put(fcSourceVolume, arrayVolumeToBeRestored);
        }
        Map<URI, String> vplexVolumeIdToDetachStep = new HashMap<URI, String>();
        // Generate pre restore steps
        String waitFor = addPreRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, null);
        // Now create a workflow step to natively restore the backend
        // source volumes from the backend full copies. We execute this
        // after the invalidate cache steps.
        waitFor = createWorkflowStepForRestoreNativeFullCopy(workflow, nativeSystem, nativeFullCopyURIs, waitFor, rollbackMethodNullMethod());
        // Generate post restore steps
        waitFor = addPostRestoreResyncSteps(workflow, vplexToArrayVolumesToFlush, vplexVolumeIdToDetachStep, waitFor);
        // Execute the workflow.
        _log.info("Executing workflow plan");
        String successMsg = String.format("Restore full copy volumes %s completed successfully", fullCopyURIs);
        FullCopyOperationCompleteCallback wfCompleteCB = new FullCopyOperationCompleteCallback();
        workflow.executePlan(completer, successMsg, wfCompleteCB, new Object[] { fullCopyURIs }, null, null);
        _log.info("Workflow plan executing");
    } catch (Exception e) {
        String failMsg = String.format("Restore full copy volumes %s failed", fullCopyURIs);
        _log.error(failMsg, e);
        ServiceCoded sc = VPlexApiException.exceptions.restoreFromFullCopyFailed(fullCopyURIs.toString(), e);
        failStep(completer, opId, sc);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CloneRestoreCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneRestoreCompleter) Volume(com.emc.storageos.db.client.model.Volume) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) MigrationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) MigrationOperationTaskCompleter(com.emc.storageos.vplexcontroller.completers.MigrationOperationTaskCompleter) CacheStatusTaskCompleter(com.emc.storageos.vplexcontroller.completers.CacheStatusTaskCompleter) VplexMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VplexMirrorTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) VolumeGroupUpdateTaskCompleter(com.emc.storageos.vplexcontroller.completers.VolumeGroupUpdateTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) WorkflowTaskCompleter(com.emc.storageos.workflow.WorkflowTaskCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 45 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class VPlexDeviceController method forgetVolumes.

/**
 * Uses the VPLREX client for the VPLEX storage system with the passed URI to
 * tell the VPLERX system to forget the volumes with the passed URIs.
 *
 * @param vplexSystemURI
 *            The URI of the VPLEX storage system.
 * @param volumeInfo
 *            The native volume information for the volumes to be forgotten.
 * @param stepId
 *            The id of the workflow step that invoked this method.
 */
public void forgetVolumes(URI vplexSystemURI, List<VolumeInfo> volumeInfo, String stepId) {
    String warnMsg = null;
    String vplexSystemName = null;
    try {
        // Workflow step is executing.
        WorkflowStepCompleter.stepExecuting(stepId);
        // Get the VPLEX client for this VPLEX system.
        StorageSystem vplexSystem = _dbClient.queryObject(StorageSystem.class, vplexSystemURI);
        vplexSystemName = vplexSystem.getLabel();
        VPlexApiClient client = getVPlexAPIClient(_vplexApiFactory, vplexSystem, _dbClient);
        // Tell the VPLEX system to forget about these volumes.
        client.forgetVolumes(volumeInfo);
    } catch (Exception ex) {
        StringBuffer forgottenVolumeInfo = new StringBuffer();
        for (VolumeInfo vInfo : volumeInfo) {
            if (forgottenVolumeInfo.length() != 0) {
                forgottenVolumeInfo.append(", ");
            }
            forgottenVolumeInfo.append(vInfo.getVolumeWWN());
        }
        ServiceCoded sc = VPlexApiException.exceptions.forgetVolumesFailed(forgottenVolumeInfo.toString(), vplexSystemName, ex.getMessage(), ex);
        warnMsg = sc.getMessage();
        _log.warn(warnMsg);
    }
    // This is a cleanup step that we don't want to impact the
    // workflow execution if it fails.
    WorkflowStepCompleter.stepSucceeded(stepId, warnMsg);
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) VPlexApiClient(com.emc.storageos.vplex.api.VPlexApiClient) VolumeInfo(com.emc.storageos.vplex.api.clientdata.VolumeInfo) VPlexVirtualVolumeInfo(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)94 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)48 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)44 URI (java.net.URI)41 Volume (com.emc.storageos.db.client.model.Volume)31 ControllerException (com.emc.storageos.volumecontroller.ControllerException)27 NamedURI (com.emc.storageos.db.client.model.NamedURI)26 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)22 WorkflowException (com.emc.storageos.workflow.WorkflowException)22 ArrayList (java.util.ArrayList)22 BlockObject (com.emc.storageos.db.client.model.BlockObject)18 Operation (com.emc.storageos.db.client.model.Operation)17 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)17 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)16 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)15 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)14 HashMap (java.util.HashMap)14 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)13 URISyntaxException (java.net.URISyntaxException)13 Host (com.emc.storageos.db.client.model.Host)12