Search in sources :

Example 76 with ServiceError

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

the class BlockDeviceController method expandVolume.

@Override
public void expandVolume(URI storage, URI pool, URI volume, Long size, String opId) throws ControllerException {
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        Volume volumeObj = _dbClient.queryObject(Volume.class, volume);
        _log.info(String.format("expandVolume start - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, OldSize: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getCapacity(), size));
        StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
        VolumeExpandCompleter completer = new VolumeExpandCompleter(volume, size, opId);
        long metaMemberSize = volumeObj.getIsComposite() ? volumeObj.getMetaMemberSize() : volumeObj.getCapacity();
        long metaCapacity = volumeObj.getIsComposite() ? volumeObj.getTotalMetaMemberCapacity() : volumeObj.getCapacity();
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volumeObj.getVirtualPool());
        boolean isThinlyProvisioned = volumeObj.getThinlyProvisioned();
        MetaVolumeRecommendation recommendation = MetaVolumeUtils.getExpandRecommendation(storageObj, poolObj, metaCapacity, size, metaMemberSize, isThinlyProvisioned, vpool.getFastExpansion());
        if (recommendation.isCreateMetaVolumes()) {
            // Also check that this is not recovery to clean dangling meta volumes with zero-capacity expansion.
            if (recommendation.getMetaMemberCount() == 0 && (volumeObj.getMetaVolumeMembers() == null || volumeObj.getMetaVolumeMembers().isEmpty())) {
                volumeObj.setCapacity(size);
                _dbClient.updateObject(volumeObj);
                _log.info(String.format("Expanded volume within its total meta volume capacity (simple case) - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, Total meta volume capacity: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getTotalMetaMemberCapacity(), volumeObj.getCapacity()));
                completer.ready(_dbClient);
            } else {
                // set meta related data in task completer
                long metaMemberCount = volumeObj.getIsComposite() ? recommendation.getMetaMemberCount() + volumeObj.getMetaMemberCount() : recommendation.getMetaMemberCount() + 1;
                completer.setMetaMemberSize(recommendation.getMetaMemberSize());
                completer.setMetaMemberCount((int) metaMemberCount);
                completer.setTotalMetaMembersSize(metaMemberCount * recommendation.getMetaMemberSize());
                completer.setComposite(true);
                completer.setMetaVolumeType(recommendation.getMetaVolumeType().toString());
                getDevice(storageObj.getSystemType()).doExpandAsMetaVolume(storageObj, poolObj, volumeObj, size, recommendation, completer);
            }
        } else {
            // expand as regular volume
            InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_080);
            getDevice(storageObj.getSystemType()).doExpandVolume(storageObj, poolObj, volumeObj, size, completer);
        }
        _log.info(String.format("expandVolume end - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()));
    } catch (Exception e) {
        _log.error(String.format("expandVolume Failed - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        List<URI> volumes = Arrays.asList(volume);
        doFailTask(Volume.class, volumes, opId, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) Arrays.asList(java.util.Arrays.asList) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 77 with ServiceError

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

the class BlockDeviceController method rollbackListSnapshot.

public void rollbackListSnapshot(URI storage, List<URI> snapshotList, String taskId) {
    WorkflowStepCompleter.stepExecuting(taskId);
    try {
        List<BlockSnapshot> snapshotsNoRollback = new ArrayList<BlockSnapshot>();
        List<BlockSnapshot> snapshotsToRollback = new ArrayList<BlockSnapshot>();
        Iterator<BlockSnapshot> itr = _dbClient.queryIterativeObjects(BlockSnapshot.class, snapshotList);
        while (itr.hasNext()) {
            BlockSnapshot snapshot = itr.next();
            if (snapshot != null && !snapshot.getInactive()) {
                if (isNullOrEmpty(snapshot.getNativeId())) {
                    snapshot.setInactive(true);
                    snapshotsNoRollback.add(snapshot);
                } else {
                    snapshotsToRollback.add(snapshot);
                }
            }
        }
        if (!snapshotsNoRollback.isEmpty()) {
            _dbClient.updateObject(snapshotsNoRollback);
        }
        if (!snapshotsToRollback.isEmpty()) {
            List<URI> snapshotURIsToRollback = new ArrayList<URI>(transform(snapshotsToRollback, fctnDataObjectToID()));
            String snapshotNativeIds = Joiner.on(", ").join(transform(snapshotsToRollback, fctnBlockObjectToNativeID()));
            _log.info("Attempting to delete {} for rollback", snapshotNativeIds);
            for (URI snapshotURI : snapshotURIsToRollback) {
                deleteSelectedSnapshot(storage, snapshotURI, generateStepIdForDependentCallDuringRollback());
            }
        }
        WorkflowStepCompleter.stepSucceded(taskId);
    } catch (InternalException ie) {
        _log.error(String.format("rollbackListSnapshot failed - Array:%s, Snapshots:%s", storage, Joiner.on("\t").join(snapshotList)));
        doFailTask(BlockSnapshot.class, snapshotList, taskId, ie);
        WorkflowStepCompleter.stepFailed(taskId, ie);
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(taskId, serviceError);
        doFailTask(BlockSnapshot.class, snapshotList, taskId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) 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) 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)

Example 78 with ServiceError

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

the class BlockDeviceController method removeMirrorFromGroup.

public void removeMirrorFromGroup(URI storage, List<URI> mirrorList, String opId) throws ControllerException {
    TaskCompleter completer = null;
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        completer = new BlockMirrorTaskCompleter(BlockMirror.class, mirrorList, opId);
        getDevice(storageObj.getSystemType()).doRemoveMirrorFromDeviceMaskingGroup(storageObj, mirrorList, completer);
    } catch (Exception e) {
        if (completer != null) {
            ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
            completer.error(_dbClient, serviceError);
        }
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockMirrorTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockMirrorTaskCompleter) 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) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 79 with ServiceError

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

the class BlockDeviceController method createMetaVolumes.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createMetaVolumesMethod just above
 * (except opId).
 */
@Override
public void createMetaVolumes(URI systemURI, URI poolURI, List<URI> volumeURIs, VirtualPoolCapabilityValuesWrapper capabilities, String opId) throws ControllerException {
    boolean opCreateFailed = false;
    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("createMetaVolumes 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);
        Volume volume = volumes.get(0);
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
        // All volumes are in the same storage pool with the same capacity. Get recommendation for the first volume.
        MetaVolumeRecommendation recommendation = MetaVolumeUtils.getCreateRecommendation(storageSystem, storagePool, volume.getCapacity(), volume.getThinlyProvisioned(), vpool.getFastExpansion(), capabilities);
        for (Volume metaVolume : volumes) {
            MetaVolumeUtils.prepareMetaVolume(metaVolume, recommendation.getMetaMemberSize(), recommendation.getMetaMemberCount(), recommendation.getMetaVolumeType().toString(), _dbClient);
        }
        WorkflowStepCompleter.stepExecuting(completer.getOpId());
        getDevice(storageSystem.getSystemType()).doCreateMetaVolumes(storageSystem, storagePool, volumes, capabilities, recommendation, completer);
        logMsgBuilder = new StringBuilder(String.format("createMetaVolumes 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("createMetaVolumes 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);
        opCreateFailed = true;
    } catch (Exception e) {
        _log.error(String.format("createMetaVolumes 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);
        opCreateFailed = true;
    }
    if (opCreateFailed) {
        for (Volume volume : volumes) {
            volume.setInactive(true);
            _dbClient.updateObject(volume);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) 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) VolumeCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateCompleter) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 80 with ServiceError

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

the class BlockDeviceController method detachFullCopies.

public void detachFullCopies(URI storage, List<URI> fullCopyVolumes, String taskId) throws ControllerException {
    _log.info("detach FullCopy: {}", fullCopyVolumes);
    try {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storage);
        TaskCompleter taskCompleter = new VolumeDetachCloneCompleter(fullCopyVolumes, taskId);
        if (checkCloneConsistencyGroup(fullCopyVolumes.get(0), _dbClient, taskCompleter)) {
            _log.info("detach group full copy");
            getDevice(storageSystem.getSystemType()).doDetachGroupClone(storageSystem, fullCopyVolumes, taskCompleter);
        } else {
            getDevice(storageSystem.getSystemType()).doDetachClone(storageSystem, fullCopyVolumes.get(0), taskCompleter);
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(taskId, serviceError);
        doFailTask(Volume.class, fullCopyVolumes, taskId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) VolumeDetachCloneCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeDetachCloneCompleter) 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) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)707 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)625 ControllerException (com.emc.storageos.volumecontroller.ControllerException)345 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)289 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)270 WorkflowException (com.emc.storageos.workflow.WorkflowException)258 URI (java.net.URI)250 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)246 ArrayList (java.util.ArrayList)238 Volume (com.emc.storageos.db.client.model.Volume)206 Workflow (com.emc.storageos.workflow.Workflow)127 WBEMException (javax.wbem.WBEMException)124 CIMObjectPath (javax.cim.CIMObjectPath)118 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)113 ExportMask (com.emc.storageos.db.client.model.ExportMask)107 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)105 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)104 URISyntaxException (java.net.URISyntaxException)94 HashMap (java.util.HashMap)86 NamedURI (com.emc.storageos.db.client.model.NamedURI)82