Search in sources :

Example 6 with VolumeTaskCompleter

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

the class SmisStorageDevice method doDeleteVolumes.

@Override
public void doDeleteVolumes(final StorageSystem storageSystem, final String opId, final List<Volume> volumes, final TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        List<String> volumeNativeIds = new ArrayList<String>();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getSerialNumber()));
        MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
        Set<CIMInstance> parkingSLOStorageGroups = new HashSet<>();
        Set<Volume> cloneVolumes = new HashSet<Volume>();
        _helper.callRefreshSystem(storageSystem, null, false);
        Iterator<Volume> volumeItr = volumes.iterator();
        Set<String> nativeIdsForParkingSG = new HashSet<String>();
        // Flag to indicate whether or not we need to use the EMCForce flag on this operation.
        // We currently use this flag when dealing with RP Volumes as they are tagged for RP and the
        // operation on these volumes would fail otherwise.
        boolean forceFlag = false;
        while (volumeItr.hasNext()) {
            Volume volume = volumeItr.next();
            logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
            // check if the volume is on array, if not, no operation on array side
            CIMInstance volumeInstance = _helper.checkExists(storageSystem, _cimPath.getBlockObjectPath(storageSystem, volume), false, false);
            if (volumeInstance == null) {
                // related volume state (if any) has been deleted. skip processing, if already
                // deleted from array.
                _log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
                volume.setInactive(true);
                _dbClient.updateObject(volume);
                // remove the volume from the processing list
                volumeItr.remove();
                VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
                deleteTaskCompleter.ready(_dbClient);
                continue;
            }
            nativeIdsForParkingSG.add(volume.getNativeId());
            if (!forceFlag) {
                forceFlag = ExportUtils.useEMCForceFlag(_dbClient, volume.getId());
            }
        }
        if (storageSystem.checkIfVmax3()) {
            parkingSLOStorageGroups = _helper.removeVolumeFromParkingSLOStorageGroup(storageSystem, nativeIdsForParkingSG.toArray(new String[] {}), forceFlag);
            _log.info("Done invoking remove volumes from parking SLO storage group");
            // delete operation.
            if (!parkingSLOStorageGroups.isEmpty()) {
                _helper.deleteParkingSLOStorageGroupsIfEmpty(storageSystem, parkingSLOStorageGroups);
            }
        }
        for (Volume volume : volumes) {
            if (volume.getConsistencyGroup() != null || NullColumnValueGetter.isNotNullValue(volume.getReplicationGroupInstance())) {
                _log.info(String.format("Volume [%s](%s) is a part of CG (%s), extra cleanup operations may be needed.", volume.getLabel(), volume.getId(), volume.getConsistencyGroup()));
                // Clean up any group backup snapshots (VNX only), if there are none this step will be skipped.
                if (storageSystem.deviceIsType(Type.vnxblock)) {
                    cleanupAnyGroupBackupSnapshots(storageSystem, volume);
                }
                // Remove the volume from the backend CG, if it's not actually in a backend CG this step will be skipped.
                removeVolumeFromConsistencyGroup(storageSystem, volume);
                // Clean up any volume backup snapshots, if there are none this step will be skipped.
                cleanupAnyBackupSnapshots(storageSystem, volume);
            } else {
                // for VMAX3, clean up unlinked snapshot session, which is possible for ingested volume
                if (storageSystem.deviceIsType(Type.vnxblock) || storageSystem.checkIfVmax3()) {
                    cleanupAnyBackupSnapshots(storageSystem, volume);
                }
            }
            if (storageSystem.deviceIsType(Type.vmax)) {
                // VMAX2 & VMAX3 - remove volume from Storage Groups if volume is not in any MaskingView
                // COP-16705, COP-21770 - Ingested non-exported Volume may be associated with SG outside of ViPR.
                _helper.removeVolumeFromStorageGroupsIfVolumeIsNotInAnyMV(storageSystem, volume);
            }
            _helper.doApplyRecoverPointTag(storageSystem, volume, false);
            // Compare the volume labels of the to-be-deleted and existing volumes
            /**
             * This will fail in the case when the user just changes the label of the
             * volume...until we subscribe to indications from the provider, we will live with
             * that.
             */
            String volToDeleteLabel = volume.getDeviceLabel();
            CIMInstance volumeInstance = _helper.checkExists(storageSystem, _cimPath.getBlockObjectPath(storageSystem, volume), false, false);
            String volInstanceLabel = CIMPropertyFactory.getPropertyValue(volumeInstance, SmisConstants.CP_ELEMENT_NAME);
            if (volToDeleteLabel != null && volInstanceLabel != null && !volToDeleteLabel.equals(volInstanceLabel)) {
                // related volume state (if any) has been deleted. skip processing, if already
                // deleted from array.
                _log.info("VolToDeleteLabel {} : volInstancelabel {}", volToDeleteLabel, volInstanceLabel);
                _log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
                volume.setInactive(true);
                // clear the associated consistency group from the volume
                volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                _dbClient.updateObject(volume);
                VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
                deleteTaskCompleter.ready(_dbClient);
                continue;
            }
            // dangling meta members as a result of expansion failure (and rollback failure).
            if (!storageSystem.checkIfVmax3()) {
                boolean cleanupSuccess = cleanupDanglingMetaMembers(storageSystem, volume);
                if (!cleanupSuccess) {
                    // cannot delete volume
                    String errorMessage = String.format("Failed to delete meta volume: %s ,  nativeId: %s .\n" + "Could not cleanup dangling meta members.", volume.getId(), volume.getNativeId());
                    ServiceError error = DeviceControllerErrors.smis.methodFailed("doDeleteVolume", errorMessage);
                    VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
                    deleteTaskCompleter.error(_dbClient, error);
                    _log.error(String.format(errorMessage));
                    continue;
                }
            }
            if (!NullColumnValueGetter.isNullURI(volume.getAssociatedSourceVolume())) {
                cloneVolumes.add(volume);
            }
            volumeNativeIds.add(volume.getNativeId());
        }
        _log.info(logMsgBuilder.toString());
        // execute SMI-S Call , only if any Volumes left for deletion.
        if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
            if (!cloneVolumes.isEmpty()) {
                processClonesBeforeDeletion(storageSystem, cloneVolumes);
            }
            CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
            CIMArgument[] inArgs = _helper.getDeleteVolumesInputArguments(storageSystem, volumeNativeIds.toArray(new String[0]));
            CIMArgument[] outArgs = new CIMArgument[5];
            String returnElementsMethod;
            if (storageSystem.getUsingSmis80()) {
                returnElementsMethod = SmisConstants.RETURN_ELEMENTS_TO_STORAGE_POOL;
            } else {
                returnElementsMethod = SmisConstants.EMC_RETURN_TO_STORAGE_POOL;
            }
            _helper.invokeMethod(storageSystem, configSvcPath, returnElementsMethod, inArgs, outArgs);
            CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new SmisDeleteVolumeJob(job, storageSystem.getId(), taskCompleter)));
            }
        } else {
            // If we are here, there are no volumes to delete, we have
            // invoked ready() for the VolumeDeleteCompleter, and told
            // the multiVolumeTaskCompleter to skip these completers.
            // In this case, the multiVolumeTaskCompleter complete()
            // method will not be invoked and the result is that the
            // workflow that initiated this delete request will never
            // be updated. So, here we just call complete() on the
            // multiVolumeTaskCompleter to ensure the workflow status is
            // updated.
            multiVolumeTaskCompleter.ready(_dbClient);
        }
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
    } catch (Exception e) {
        _log.error("Problem in doDeleteVolume: ", e);
        // Check to see if an Asynchronous job will now handle the task status.
        if (!taskCompleter.isAsynchronous()) {
            ServiceError error = DeviceControllerErrors.smis.methodFailed("doDeleteVolume", e.getMessage());
            taskCompleter.error(_dbClient, error);
        }
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getSerialNumber()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    _log.info(logMsgBuilder.toString());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) CIMInstance(javax.cim.CIMInstance) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) SmisDeleteVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisDeleteVolumeJob) MetaVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MetaVolumeTaskCompleter) 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) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) HashSet(java.util.HashSet) CIMArgument(javax.cim.CIMArgument)

Example 7 with VolumeTaskCompleter

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

the class XIVSmisStorageDevice method doDeleteVolumes.

/*
     * (non-Javadoc)
     * 
     * @see
     * com.emc.storageos.volumecontroller.BlockStorageDevice#doDeleteVolumes
     * (com.emc.storageos.db.client.model.StorageSystem, java.lang.String,
     * java.util.List, com.emc.storageos.volumecontroller.TaskCompleter)
     * 
     * Note: assume volumes could be from different consistency groups
     */
@Override
public void doDeleteVolumes(final StorageSystem storageSystem, final String opId, final List<Volume> volumes, final TaskCompleter taskCompleter) throws DeviceControllerException {
    try {
        List<String> volumeNativeIds = new ArrayList<String>();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume Start - Array:%s", storageSystem.getLabel()));
        MultiVolumeTaskCompleter multiVolumeTaskCompleter = (MultiVolumeTaskCompleter) taskCompleter;
        for (Volume volume : volumes) {
            logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
            if (volume.getConsistencyGroup() != null) {
                BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, volume.getConsistencyGroup());
                if (cg != null && cg.getTypes() != null && cg.getTypes().contains(BlockConsistencyGroup.Types.LOCAL.name())) {
                    removeVolumeFromConsistencyGroup(storageSystem, cg, volume);
                }
            }
            CIMInstance volumeInstance = _helper.checkExists(storageSystem, volume, false, false);
            if (volumeInstance == null) {
                // related volume state (if any) has been deleted. skip
                // processing, if already
                // deleted from array.
                _log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
                volume.setInactive(true);
                _dbClient.persistObject(volume);
                VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
                deleteTaskCompleter.ready(_dbClient);
                continue;
            }
            // Compare the volume labels of the to-be-deleted and existing
            // volumes
            /**
             * This will fail in the case when the user just changes the
             * label of the volume...till we subscribe to indications from
             * the provider, we will live with that.
             */
            String volToDeleteLabel = volume.getDeviceLabel();
            String volInstanceLabel = CIMPropertyFactory.getPropertyValue(volumeInstance, SmisConstants.CP_ELEMENT_NAME);
            if (volToDeleteLabel != null && volInstanceLabel != null && !volToDeleteLabel.equals(volInstanceLabel)) {
                // related volume state (if any) has been deleted. skip
                // processing, if already
                // deleted from array.
                _log.info("VolToDeleteLabel {} : volInstancelabel {}", volToDeleteLabel, volInstanceLabel);
                _log.info(String.format("Volume %s already deleted: ", volume.getNativeId()));
                volume.setInactive(true);
                // clear the associated consistency groups from the volume
                volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                // TODO - is this needed, or just persistObject? use bulk
                // update
                _dbClient.updateAndReindexObject(volume);
                VolumeTaskCompleter deleteTaskCompleter = multiVolumeTaskCompleter.skipTaskCompleter(volume.getId());
                deleteTaskCompleter.ready(_dbClient);
                continue;
            }
            volumeNativeIds.add(volume.getNativeId());
        }
        _log.info(logMsgBuilder.toString());
        // execute SMI-S Call , only if any Volumes left for deletion.
        if (!multiVolumeTaskCompleter.isVolumeTaskCompletersEmpty()) {
            CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
            CIMArgument[] inArgs = _helper.getDeleteVolumesInputArguments(storageSystem, volumeNativeIds.toArray(new String[volumeNativeIds.size()]));
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.invokeMethod(storageSystem, configSvcPath, SmisConstants.RETURN_ELEMENTS_TO_STORAGE_POOL, inArgs, outArgs);
            _smisStorageDevicePostProcessor.processVolumeDeletion(storageSystem, volumes, outArgs, multiVolumeTaskCompleter);
        }
        // If we are here, there are no more volumes to delete, we have
        // invoked ready() for the VolumeDeleteCompleter, and told
        // the multiVolumeTaskCompleter to skip these completers.
        // In this case, the multiVolumeTaskCompleter complete()
        // method will not be invoked and the result is that the
        // workflow that initiated this delete request will never
        // be updated. So, here we just call complete() on the
        // multiVolumeTaskCompleter to ensure the workflow status is
        // updated.
        multiVolumeTaskCompleter.ready(_dbClient);
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        ServiceError error = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, error);
    } catch (DeviceControllerException e) {
        taskCompleter.error(_dbClient, e);
    } catch (Exception e) {
        _log.error("Problem in doDeleteVolume: ", e);
        ServiceError error = DeviceControllerErrors.smis.methodFailed("doDeleteVolume", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete Volume End - Array: %s", storageSystem.getLabel()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    _log.info(logMsgBuilder.toString());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) CIMInstance(javax.cim.CIMInstance) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) 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) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 8 with VolumeTaskCompleter

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

the class BlockDeviceController method modifyVolumes.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method modifyVolumesMethod just above (except
 * opId).
 * Currently this workflow step is used only for Hitachi Thin Volumes modification to update volume tieringPolicy.
 * Hitachi allows setting of tieringpolicy at LDEV level, hence We should have a LDEV id of a LogicalUnit.
 * But LDEV is only created after we LogicalUnit is created. Hence createVolumes workflow includes creation of LU
 * (i.e. LDEV)
 * And LDEV modification (to set tieringPolicy.)
 */
@Override
public void modifyVolumes(URI systemURI, URI poolURI, List<URI> volumeURIs, 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("moidfyVolumes 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);
            VolumeUpdateCompleter volumeCompleter = new VolumeUpdateCompleter(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());
        getDevice(storageSystem.getSystemType()).doModifyVolumes(storageSystem, storagePool, opId, volumes, completer);
        logMsgBuilder = new StringBuilder(String.format("modifyVolumes 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 (InternalException e) {
        _log.error(String.format("modifyVolumes Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)));
        doFailTask(Volume.class, volumeURIs, opId, e);
        WorkflowStepCompleter.stepFailed(opId, e);
    } catch (Exception e) {
        _log.error(String.format("modifyVolumes Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)));
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        doFailTask(Volume.class, volumeURIs, opId, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) 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) VolumeUpdateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeUpdateCompleter) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with VolumeTaskCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter 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 10 with VolumeTaskCompleter

use of com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter 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

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