Search in sources :

Example 36 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class BlockDeviceController method createConsistencyGroup.

@Override
public void createConsistencyGroup(URI storage, URI consistencyGroup, String opId) throws ControllerException {
    TaskCompleter completer = new BlockConsistencyGroupCreateCompleter(consistencyGroup, opId);
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        // Lock the CG for the step duration.
        List<String> lockKeys = new ArrayList<String>();
        lockKeys.add(ControllerLockingUtil.getConsistencyGroupStorageKey(_dbClient, consistencyGroup, storage));
        _workflowService.acquireWorkflowStepLocks(opId, lockKeys, LockTimeoutValue.get(LockType.ARRAY_CG));
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        // Check if already created, if not create, if so just complete.
        BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroup);
        String groupName = ControllerUtils.generateReplicationGroupName(storageObj, cg, null, _dbClient);
        if (!cg.created(storage, groupName)) {
            getDevice(storageObj.getSystemType()).doCreateConsistencyGroup(storageObj, consistencyGroup, groupName, completer);
        } else {
            _log.info(String.format("Consistency group %s (%s) already created", cg.getLabel(), cg.getId()));
            completer.ready(_dbClient);
        }
    } catch (Exception e) {
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        completer.error(_dbClient, serviceError);
        throw DeviceControllerException.exceptions.createConsistencyGroupFailed(e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockConsistencyGroupCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.BlockConsistencyGroupCreateCompleter) ArrayList(java.util.ArrayList) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 37 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class BlockDeviceController method rollBackCreateVolumes.

/**
 * {@inheritDoc} NOTE: The signature here MUST match the Workflow.Method rollbackCreateVolumesMethod just above
 * (except opId).
 */
@Override
public void rollBackCreateVolumes(URI systemURI, List<URI> volumeURIs, String opId) throws ControllerException {
    MultiVolumeTaskCompleter completer = new MultiVolumeTaskCompleter(volumeURIs, opId);
    List<Volume> volumes = new ArrayList<>(volumeURIs.size());
    completer.setRollingBack(true);
    try {
        String logMsg = String.format("rollbackCreateVolume start - Array:%s, Volume:%s", systemURI.toString(), Joiner.on(',').join(volumeURIs));
        _log.info(logMsg.toString());
        WorkflowStepCompleter.stepExecuting(opId);
        volumes.addAll(_dbClient.queryObject(Volume.class, volumeURIs));
        for (Volume volume : volumes) {
            // CTRL-5597 clean volumes which have failed only in a multi-volume request
            if (null != volume.getNativeGuid()) {
                StorageSystem system = _dbClient.queryObject(StorageSystem.class, volume.getStorageController());
                if (Type.xtremio.toString().equalsIgnoreCase(system.getSystemType())) {
                    continue;
                }
            }
            // then we need to clear srdfTargets and personality fields for source
            if (null != volume.getSrdfTargets()) {
                _log.info("Clearing targets for existing source");
                volume.getSrdfTargets().clear();
                _dbClient.updateObject(volume);
                // Clearing Source CG
                URI sourceCgUri = volume.getConsistencyGroup();
                if (null != sourceCgUri) {
                    BlockConsistencyGroup sourceCG = _dbClient.queryObject(BlockConsistencyGroup.class, sourceCgUri);
                    if (null != sourceCG && (null == sourceCG.getTypes() || NullColumnValueGetter.isNullURI(sourceCG.getStorageController()))) {
                        sourceCG.getRequestedTypes().remove(Types.SRDF.name());
                        _dbClient.updateObject(sourceCG);
                    }
                }
            }
            // for change Virtual Pool, if failed, clear targets and personality field for source and also
            if (!NullColumnValueGetter.isNullNamedURI(volume.getSrdfParent())) {
                URI sourceUri = volume.getSrdfParent().getURI();
                Volume sourceVolume = _dbClient.queryObject(Volume.class, sourceUri);
                sourceVolume.setPersonality(NullColumnValueGetter.getNullStr());
                if (null != sourceVolume.getSrdfTargets()) {
                    sourceVolume.getSrdfTargets().clear();
                    _dbClient.updateObject(sourceVolume);
                }
                // Clearing target CG
                URI cgUri = volume.getConsistencyGroup();
                if (null != cgUri) {
                    BlockConsistencyGroup targetCG = _dbClient.queryObject(BlockConsistencyGroup.class, cgUri);
                    if (null != targetCG && (null == targetCG.getTypes() || NullColumnValueGetter.isNullURI(targetCG.getStorageController()))) {
                        _log.info("Set target CG {} inactive", targetCG.getLabel());
                        targetCG.setInactive(true);
                        _dbClient.updateObject(targetCG);
                    }
                    // clear association between target volume and target cg
                    volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                    _dbClient.updateAndReindexObject(volume);
                }
            }
            // Check for loose export groups associated with this rolled-back volume
            URIQueryResultList exportGroupURIs = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeExportGroupConstraint(volume.getId()), exportGroupURIs);
            while (exportGroupURIs.iterator().hasNext()) {
                URI exportGroupURI = exportGroupURIs.iterator().next();
                ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
                if (!exportGroup.getInactive()) {
                    exportGroup.removeVolume(volume.getId());
                    boolean canRemoveGroup = false;
                    List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup);
                    // Make sure the volume is not in an export mask
                    for (ExportMask exportMask : exportMasks) {
                        exportMask.removeVolume(volume.getId());
                        exportMask.removeFromUserCreatedVolumes(volume);
                        exportMask.removeFromExistingVolumes(volume);
                        if (!exportMask.getCreatedBySystem() && !exportMask.hasAnyVolumes() && exportMask.emptyVolumes()) {
                            canRemoveGroup = true;
                            _dbClient.removeObject(exportMask);
                        } else {
                            _dbClient.updateObject(exportMask);
                        }
                    }
                    // If we didn't find that volume in a mask, it's OK to remove it.
                    if (canRemoveGroup && exportMasks.size() == 1 && exportGroup.getVolumes().isEmpty()) {
                        _dbClient.removeObject(exportGroup);
                    } else {
                        _dbClient.updateObject(exportGroup);
                    }
                }
            }
        }
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_013);
        deleteVolumesWithCompleter(systemURI, volumeURIs, completer);
        InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_014);
        logMsg = String.format("rollbackCreateVolume end - Array:%s, Volume:%s", systemURI.toString(), Joiner.on(',').join(volumeURIs));
        _log.info(logMsg.toString());
    } catch (Exception e) {
        _log.error(String.format("rollbackCreateVolume Failed - Array:%s, Volume:%s", systemURI.toString(), Joiner.on(',').join(volumeURIs)));
        handleException(e, completer);
    }
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) 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) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 38 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException 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 39 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class FileDeviceController method expandFS.

@Override
public void expandFS(URI storage, URI uri, long newFSsize, String opId) throws ControllerException {
    ControllerUtils.setThreadLocalLogData(uri, opId);
    FileShare fs = null;
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        fs = _dbClient.queryObject(FileShare.class, uri);
        args.addFSFileObject(fs);
        StoragePool pool = _dbClient.queryObject(StoragePool.class, fs.getPool());
        args.addStoragePool(pool);
        args.setFileOperation(true);
        args.setNewFSCapacity(newFSsize);
        args.setOpId(opId);
        // work flow and we need to add TaskCompleter(TBD for vnxfile)
        WorkflowStepCompleter.stepExecuting(opId);
        // Acquire lock for VNXFILE Storage System
        acquireStepLock(storageObj, opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).doExpandFS(storageObj, args);
        if (result.getCommandPending()) {
            // async operation
            return;
        }
        if (result.isCommandSuccess()) {
            _log.info("FileSystem old capacity :" + args.getFsCapacity() + ":Expanded Size:" + args.getNewFSCapacity());
            args.setFsCapacity(args.getNewFSCapacity());
            _log.info("FileSystem new capacity :" + args.getFsCapacity());
            WorkflowStepCompleter.stepSucceded(opId);
        } else if (!result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        // Set status
        if (!result.isCommandSuccess() && !result.getCommandPending()) {
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        fs.getOpStatus().updateTaskStatus(opId, result.toOperation());
        _dbClient.updateObject(fs);
        String eventMsg = result.isCommandSuccess() ? "" : result.getMessage();
        recordFileDeviceOperation(_dbClient, OperationTypeEnum.EXPAND_FILE_SYSTEM, result.isCommandSuccess(), eventMsg, "", fs, String.valueOf(newFSsize));
    } catch (Exception e) {
        String[] params = { storage.toString(), uri.toString(), String.valueOf(newFSsize), e.getMessage() };
        _log.error("Unable to expand file system: storage {}, FS URI {}, size {}: {}", params);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        updateTaskStatus(opId, fs, e);
        if (fs != null) {
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.EXPAND_FILE_SYSTEM, false, e.getMessage(), "", fs, String.valueOf(newFSsize));
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) 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 40 with ControllerException

use of com.emc.storageos.volumecontroller.ControllerException in project coprhd-controller by CoprHD.

the class FileDeviceController method createFS.

@Override
public void createFS(URI storage, URI pool, URI fs, String nativeId, String opId) throws ControllerException {
    FileObject fileObject = null;
    FileShare fsObj = null;
    StorageSystem storageObj = null;
    try {
        ControllerUtils.setThreadLocalLogData(fs, opId);
        storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        String[] params = { storage.toString(), pool.toString(), fs.toString() };
        _log.info("Create FS: {}, {}, {}", params);
        StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
        fsObj = _dbClient.queryObject(FileShare.class, fs);
        VirtualPool vPool = _dbClient.queryObject(VirtualPool.class, fsObj.getVirtualPool());
        fileObject = fsObj;
        FileDeviceInputOutput args = new FileDeviceInputOutput();
        args.addFileShare(fsObj);
        args.addStoragePool(poolObj);
        args.setVPool(vPool);
        args.setNativeDeviceFsId(nativeId);
        args.setOpId(opId);
        Project proj = _dbClient.queryObject(Project.class, fsObj.getProject());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, fsObj.getTenant());
        setVirtualNASinArgs(fsObj.getVirtualNAS(), args);
        args.setTenantOrg(tenant);
        args.setProject(proj);
        // work flow and we need to add TaskCompleter(TBD for vnxfile)
        WorkflowStepCompleter.stepExecuting(opId);
        acquireStepLock(storageObj, opId);
        BiosCommandResult result = getDevice(storageObj.getSystemType()).doCreateFS(storageObj, args);
        if (!result.getCommandPending()) {
            fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        } else {
            // we need to add task completer
            fsObj.getOpStatus().updateTaskStatus(opId, result.toOperation());
        }
        if (result.isCommandSuccess()) {
            fsObj.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(_dbClient, fsObj));
            fsObj.setInactive(false);
            WorkflowStepCompleter.stepSucceded(opId);
        } else if (!result.getCommandPending()) {
            fsObj.setInactive(true);
            WorkflowStepCompleter.stepFailed(opId, result.getServiceCoded());
        }
        _dbClient.updateObject(fsObj);
        if (!result.getCommandPending()) {
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, result.isCommandSuccess(), "", "", fsObj);
        }
    } catch (Exception e) {
        String[] params = { storage.toString(), pool.toString(), fs.toString(), e.getMessage() };
        _log.error("Unable to create file system: storage {}, pool {}, FS {}: {}", params);
        // work flow fail
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        if ((fsObj != null) && (storageObj != null)) {
            fsObj.setInactive(true);
            _dbClient.updateObject(fsObj);
            recordFileDeviceOperation(_dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM, false, e.getMessage(), "", fsObj, storageObj);
        }
        updateTaskStatus(opId, fileObject, e);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) FileDeviceInputOutput(com.emc.storageos.volumecontroller.FileDeviceInputOutput) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) Project(com.emc.storageos.db.client.model.Project) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) FileObject(com.emc.storageos.db.client.model.FileObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

ControllerException (com.emc.storageos.volumecontroller.ControllerException)299 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)280 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)211 WorkflowException (com.emc.storageos.workflow.WorkflowException)188 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)182 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)151 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)121 ArrayList (java.util.ArrayList)93 URI (java.net.URI)87 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)75 Workflow (com.emc.storageos.workflow.Workflow)68 URISyntaxException (java.net.URISyntaxException)63 Volume (com.emc.storageos.db.client.model.Volume)62 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)61 DataBindingException (javax.xml.bind.DataBindingException)61 VolumeTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter)55 CloneTaskCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.CloneTaskCompleter)52 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)51 NamedURI (com.emc.storageos.db.client.model.NamedURI)50 FileShare (com.emc.storageos.db.client.model.FileShare)49