Search in sources :

Example 11 with MultiVolumeTaskCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter in project coprhd-controller by CoprHD.

the class BlockDeviceController method createVolumes.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createVolumesMethod just above (except
 * opId).
 */
@Override
public void createVolumes(URI systemURI, URI poolURI, List<URI> volumeURIs, VirtualPoolCapabilityValuesWrapper capabilities, String opId) throws ControllerException {
    List<Volume> volumes = new ArrayList<Volume>();
    try {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
        List<VolumeTaskCompleter> volumeCompleters = new ArrayList<VolumeTaskCompleter>();
        Iterator<URI> volumeURIsIter = volumeURIs.iterator();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("createVolumes start - Array:%s Pool:%s", systemURI.toString(), poolURI.toString()));
        while (volumeURIsIter.hasNext()) {
            URI volumeURI = volumeURIsIter.next();
            logMsgBuilder.append(String.format("%nVolume:%s", volumeURI.toString()));
            Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
            volumes.add(volume);
            VolumeCreateCompleter volumeCompleter = new VolumeCreateCompleter(volumeURI, opId);
            volumeCompleters.add(volumeCompleter);
        }
        _log.info(logMsgBuilder.toString());
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, poolURI);
        MultiVolumeTaskCompleter completer = new MultiVolumeTaskCompleter(volumeURIs, volumeCompleters, opId);
        WorkflowStepCompleter.stepExecuting(completer.getOpId());
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_005);
        getDevice(storageSystem.getSystemType()).doCreateVolumes(storageSystem, storagePool, opId, volumes, capabilities, completer);
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_006);
        logMsgBuilder = new StringBuilder(String.format("createVolumes end - Array:%s Pool:%s", systemURI.toString(), poolURI.toString()));
        volumeURIsIter = volumeURIs.iterator();
        while (volumeURIsIter.hasNext()) {
            logMsgBuilder.append(String.format("%nVolume:%s", volumeURIsIter.next().toString()));
        }
        _log.info(logMsgBuilder.toString());
    } catch (Exception e) {
        _log.error(String.format("createVolume Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)), e);
        Workflow workflow = WorkflowService.getInstance().getWorkflowFromStepId(opId);
        if (workflow != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
            doFailTask(Volume.class, volumeURIs, opId, serviceError);
            WorkflowStepCompleter.stepFailed(opId, serviceError);
            _dbClient.markForDeletion(volumes);
        } else {
            _log.info("Workflow is null which means that the workflow has already completed. Not performing any error handling");
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) Workflow(com.emc.storageos.workflow.Workflow) NamedURI(com.emc.storageos.db.client.model.NamedURI) FCTN_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI) URI(java.net.URI) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) VolumeCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 12 with MultiVolumeTaskCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter in project coprhd-controller by CoprHD.

the class BlockDeviceController method untagVolumes.

/**
 * Performs an untag operation on all volumes.
 *
 * @param systemURI
 *            Underlying system to perform the untag operation on
 * @param volumeURIs
 *            Volumes to untag
 * @param opId
 *            The opId
 * @throws ControllerException
 */
public void untagVolumes(URI systemURI, List<URI> volumeURIs, String opId) throws ControllerException {
    try {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
        List<Volume> volumes = new ArrayList<Volume>();
        List<VolumeTaskCompleter> volumeCompleters = new ArrayList<VolumeTaskCompleter>();
        Iterator<URI> volumeURIsIter = volumeURIs.iterator();
        String arrayName = systemURI.toString();
        StringBuilder entryLogMsgBuilder = new StringBuilder(String.format("untagVolume start - Array:%s", arrayName));
        StringBuilder exitLogMsgBuilder = new StringBuilder(String.format("untagVolume end - Array:%s", arrayName));
        while (volumeURIsIter.hasNext()) {
            URI volumeURI = volumeURIsIter.next();
            Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
            if (volume != null) {
                entryLogMsgBuilder.append(String.format("%nUntag operation: Volume: [%s](%s)", volume.getLabel(), volumeURI.toString()));
                exitLogMsgBuilder.append(String.format("%nUntag operation: Volume: [%s](%s)", volume.getLabel(), volumeURI.toString()));
                if (!volume.getInactive()) {
                    volumes.add(volume);
                } else {
                    // Nothing to do for an inactive volume
                    continue;
                }
                // Generic completer is fine here
                VolumeWorkflowCompleter volumeCompleter = new VolumeWorkflowCompleter(volumeURI, opId);
                volumeCompleters.add(volumeCompleter);
            }
        }
        _log.info(entryLogMsgBuilder.toString());
        if (!volumes.isEmpty()) {
            WorkflowStepCompleter.stepExecuting(opId);
            TaskCompleter completer = new MultiVolumeTaskCompleter(volumeURIs, volumeCompleters, opId);
            getDevice(storageSystem.getSystemType()).doUntagVolumes(storageSystem, opId, volumes, completer);
        }
        doSuccessTask(Volume.class, volumeURIs, opId);
        WorkflowStepCompleter.stepSucceded(opId);
        _log.info(exitLogMsgBuilder.toString());
    } catch (InternalException e) {
        doFailTask(Volume.class, volumeURIs, opId, e);
        WorkflowStepCompleter.stepFailed(opId, e);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        doFailTask(Volume.class, volumeURIs, opId, serviceError);
        WorkflowStepCompleter.stepFailed(opId, DeviceControllerException.exceptions.unexpectedCondition(e.getMessage()));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VolumeWorkflowCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeWorkflowCompleter) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) FCTN_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI) URI(java.net.URI) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) ScanTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.ScanTaskCompleter) BlockSnapshotEstablishGroupTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockSnapshotEstablishGroupTaskCompleter) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) CloneTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter) ApplicationTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ApplicationTaskCompleter) SimpleTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.SimpleTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) DiscoverTaskCompleter(com.emc.storageos.volumecontroller.impl.plugins.discovery.smis.DiscoverTaskCompleter) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

MultiVolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter)12 Volume (com.emc.storageos.db.client.model.Volume)11 VolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter)10 ArrayList (java.util.ArrayList)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)9 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)9 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)9 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)9 NamedURI (com.emc.storageos.db.client.model.NamedURI)6 URI (java.net.URI)6 StoragePool (com.emc.storageos.db.client.model.StoragePool)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 FCTN_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI)5 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)5 ControllerException (com.emc.storageos.volumecontroller.ControllerException)5 WorkflowException (com.emc.storageos.workflow.WorkflowException)5 DataBindingException (javax.xml.bind.DataBindingException)5 VolumeCreateCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateCompleter)3 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2