Search in sources :

Example 1 with VolumeCreateCompleter

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

the class BlockDeviceController method createMetaVolume.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createMetaVolumeMethod just above
 * (except opId).
 */
@Override
public void createMetaVolume(URI systemURI, URI poolURI, URI volumeURI, VirtualPoolCapabilityValuesWrapper capabilities, String opId) throws ControllerException {
    try {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("createMetaVolume start - Array:%s Pool:%s, Volume:%s", systemURI.toString(), poolURI.toString(), volumeURI.toString()));
        _log.info(logMsgBuilder.toString());
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
        Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, poolURI);
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
        MetaVolumeRecommendation recommendation = MetaVolumeUtils.getCreateRecommendation(storageSystem, storagePool, volume.getCapacity(), volume.getThinlyProvisioned(), vpool.getFastExpansion(), capabilities);
        MetaVolumeUtils.prepareMetaVolume(volume, recommendation.getMetaMemberSize(), recommendation.getMetaMemberCount(), recommendation.getMetaVolumeType().toString(), _dbClient);
        VolumeCreateCompleter completer = new VolumeCreateCompleter(volumeURI, opId);
        WorkflowStepCompleter.stepExecuting(completer.getOpId());
        getDevice(storageSystem.getSystemType()).doCreateMetaVolume(storageSystem, storagePool, volume, capabilities, recommendation, completer);
        logMsgBuilder = new StringBuilder(String.format("createMetaVolume end - Array:%s Pool:%s, Volume:%s", systemURI.toString(), poolURI.toString(), volumeURI.toString()));
        _log.info(logMsgBuilder.toString());
    } catch (InternalException e) {
        _log.error(String.format("createMetaVolume Failed - Array:%s Pool:%s, Volume:%s", systemURI.toString(), poolURI.toString(), volumeURI.toString()));
        doFailTask(Volume.class, volumeURI, opId, e);
        WorkflowStepCompleter.stepFailed(opId, e);
    } catch (Exception e) {
        _log.error(String.format("createMetaVolume Failed - Array:%s Pool:%s, Volume:%s", systemURI.toString(), poolURI.toString(), volumeURI.toString()));
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        doFailTask(Volume.class, volumeURI, 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) VolumeCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateCompleter) 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) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 2 with VolumeCreateCompleter

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

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

the class BlockStorageDeviceTest method performOperation.

private void performOperation(Operation operation) {
    String taskId = UUID.randomUUID().toString();
    if (Operation.Create.equals(operation)) {
        List<Volume> volumes = createVolumes();
        VirtualPoolCapabilityValuesWrapper capabilities = new VirtualPoolCapabilityValuesWrapper();
        TaskCompleter taskCompleter = new VolumeCreateCompleter(volumes.get(0).getId(), taskId);
        _deviceController.doCreateVolumes(_storageSystem, _storagePool, taskId, volumes, capabilities, taskCompleter);
    // TODO - assert vols are created
    // update vol labels with real label
    } else if (Operation.Expand.equals(operation)) {
        List<Volume> volumes = getVolumes(_storageSystem);
        Volume volume = volumes.get(0);
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, volume.getPool());
        long size = volume.getProvisionedCapacity() * 2;
        TaskCompleter taskCompleter = new VolumeExpandCompleter(volume.getId(), size, taskId);
        _deviceController.doExpandVolume(_storageSystem, storagePool, volume, size, taskCompleter);
    // TODO - assert original vol's size (provisionedCapacity or
    // capacity??) are changed
    } else if (Operation.Delete.equals(operation)) {
        List<Volume> volumes = getVolumes(_storageSystem);
        List<URI> ids = new ArrayList<URI>(volumes.size());
        List<VolumeTaskCompleter> volumeTaskCompleters = new ArrayList<>(volumes.size());
        for (Volume volume : volumes) {
            URI uri = volume.getId();
            ids.add(uri);
            volumeTaskCompleters.add(new VolumeCreateCompleter(uri, taskId));
        }
        MultiVolumeTaskCompleter multiTaskCompleter = new MultiVolumeTaskCompleter(ids, volumeTaskCompleters, taskId);
        _deviceController.doDeleteVolumes(_storageSystem, taskId, volumes, multiTaskCompleter);
    // TODO - assert vols are deleted from db
    }
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) StoragePool(com.emc.storageos.db.client.model.StoragePool) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) 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) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ExportTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.ExportTaskCompleter) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter)

Example 4 with VolumeCreateCompleter

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

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

the class HDSProtectionOperations method createSecondaryVolumeForClone.

/**
 * Creates secondary volume for ShadowImage pair operations.
 *
 * @param storageSystem
 * @param sourceVolume
 * @param targetVolume
 * @throws Exception
 */
public void createSecondaryVolumeForClone(StorageSystem storageSystem, URI sourceVolume, Volume targetVolume) throws Exception {
    log.info("SecondaryVolume creation operation started");
    String taskId = UUID.randomUUID().toString();
    TaskCompleter taskCompleter = new VolumeCreateCompleter(targetVolume.getId(), taskId);
    String asyncTaskMessageId = null;
    HDSApiClient hdsApiClient = HDSUtils.getHDSApiClient(hdsApiFactory, storageSystem);
    String systemObjectID = HDSUtils.getSystemObjectID(storageSystem);
    BlockObject sourceObj = BlockObject.fetch(dbClient, sourceVolume);
    URI tenantUri = null;
    StoragePool targetPool = dbClient.queryObject(StoragePool.class, targetVolume.getPool());
    if (sourceObj instanceof BlockSnapshot) {
        // In case of snapshot, get the tenant from its parent volume
        NamedURI parentVolUri = ((BlockSnapshot) sourceObj).getParent();
        Volume parentVolume = dbClient.queryObject(Volume.class, parentVolUri);
        tenantUri = parentVolume.getTenant().getURI();
        TenantOrg tenantOrg = dbClient.queryObject(TenantOrg.class, tenantUri);
    // String cloneLabel = generateLabel(tenantOrg, cloneObj);
    } else {
        // This is a default flow
        tenantUri = ((Volume) sourceObj).getTenant().getURI();
    }
    if (targetVolume.getThinlyProvisioned()) {
        asyncTaskMessageId = hdsApiClient.createThinVolumes(systemObjectID, targetPool.getNativeId(), targetVolume.getCapacity(), 1, targetVolume.getLabel(), HDSConstants.QUICK_FORMAT_TYPE, storageSystem.getModel());
    } else {
        String poolObjectID = HDSUtils.getPoolObjectID(targetPool);
        asyncTaskMessageId = hdsApiClient.createThickVolumes(systemObjectID, poolObjectID, targetVolume.getCapacity(), 1, targetVolume.getLabel(), null, storageSystem.getModel(), null);
    }
    if (asyncTaskMessageId != null) {
        HDSJob createHDSJob = new HDSCreateVolumeJob(asyncTaskMessageId, targetVolume.getStorageController(), targetPool.getId(), taskCompleter);
        hdsCommandHelper.waitForAsyncHDSJob(createHDSJob);
    } else {
        throw HDSException.exceptions.asyncTaskFailed("Unable to get async taskId from HiCommand Device Manager for the create volume call");
    }
    log.info("SecondaryVolume creation operation completed successfully");
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) HDSJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSJob) HDSCreateVolumeJob(com.emc.storageos.volumecontroller.impl.hds.prov.job.HDSCreateVolumeJob) NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) VolumeCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateCompleter) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) TaskCompleter(com.emc.storageos.volumecontroller.TaskCompleter) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Aggregations

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