Search in sources :

Example 1 with VolumeExpandCompleter

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

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

the class HDSVolumeExpandJob method updateStatus.

/**
 * Called to update the job status when the volume expand job completes.
 *
 * @param jobContext
 *            The job context.
 */
@Override
public void updateStatus(JobContext jobContext) throws Exception {
    LogicalUnit logicalUnit = null;
    try {
        if (_status == JobStatus.IN_PROGRESS) {
            return;
        }
        DbClient dbClient = jobContext.getDbClient();
        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
        HDSApiClient hdsApiClient = jobContext.getHdsApiFactory().getClient(HDSUtils.getHDSServerManagementServerInfo(storageSystem), storageSystem.getSmisUserName(), storageSystem.getSmisPassword());
        // from pool's reserved capacity map.
        if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
            StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
            HDSUtils.updateStoragePoolCapacity(dbClient, hdsApiClient, storagePool);
            StringMap reservationMap = storagePool.getReservedCapacityMap();
            URI volumeId = getTaskCompleter().getId();
            // remove from reservation map
            reservationMap.remove(volumeId.toString());
            dbClient.persistObject(storagePool);
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), _status.name(), opId));
        if (_status == JobStatus.SUCCESS) {
            VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
            Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
            // set requested capacity
            volume.setCapacity(taskCompleter.getSize());
            // set meta related properties
            volume.setIsComposite(taskCompleter.isComposite());
            volume.setCompositionType(taskCompleter.getMetaVolumeType());
            logicalUnit = (LogicalUnit) _javaResult.getBean("logicalunit");
            if (null != logicalUnit) {
                long capacityInBytes = (Long.valueOf(logicalUnit.getCapacityInKB())) * 1024L;
                volume.setProvisionedCapacity(capacityInBytes);
                volume.setAllocatedCapacity(capacityInBytes);
            }
            logMsgBuilder.append(String.format("%n   Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
            if (volume.getIsComposite()) {
                logMsgBuilder.append(String.format("%n  Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s", volume.getIsComposite(), volume.getTotalMetaMemberCapacity(), volume.getMetaMemberCount(), volume.getMetaMemberSize()));
            }
            _log.info(logMsgBuilder.toString());
            dbClient.persistObject(volume);
            // Reset list of meta members native ids in WF data (when meta
            // is created meta members are removed from array)
            WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for HDSVolumeExpandJob", e);
        setErrorStatus("Encountered an internal error during volume expand job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 3 with VolumeExpandCompleter

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

the class CinderVolumeExpandJob method updateStatus.

@Override
public void updateStatus(JobContext jobContext) throws Exception {
    DbClient dbClient = jobContext.getDbClient();
    try {
        // Do nothing if the job is not completed yet
        if (status == JobStatus.IN_PROGRESS) {
            return;
        }
        String opId = getTaskCompleter().getOpId();
        _logger.info(String.format("Updating status of job %s to %s", opId, status.name()));
        StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
        CinderApi cinderApi = jobContext.getCinderApiFactory().getApi(storageSystem.getActiveProviderURI(), getEndPointInfo());
        URI volumeId = getTaskCompleter().getId();
        // If terminal state update storage pool capacity and remove reservation for volume capacity
        // from pool's reserved capacity map.
        StoragePool storagePool = null;
        if (status == JobStatus.SUCCESS || status == JobStatus.FAILED) {
            storagePool = dbClient.queryObject(StoragePool.class, storagePoolUri);
            StringMap reservationMap = storagePool.getReservedCapacityMap();
            // remove from reservation map
            reservationMap.remove(volumeId.toString());
            dbClient.persistObject(storagePool);
        }
        if (status == JobStatus.SUCCESS) {
            VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
            Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
            long oldCapacity = volume.getCapacity();
            long newCapacity = taskCompleter.getSize();
            // set requested capacity
            volume.setCapacity(newCapacity / CinderConstants.BYTES_TO_GB);
            volume.setProvisionedCapacity(taskCompleter.getSize());
            volume.setAllocatedCapacity(taskCompleter.getSize());
            dbClient.persistObject(volume);
            long increasedCapacity = newCapacity - oldCapacity;
            CinderUtils.updateStoragePoolCapacity(dbClient, cinderApi, storagePool, String.valueOf(increasedCapacity / CinderConstants.BYTES_TO_GB), false);
        }
    } catch (Exception e) {
        _logger.error("Caught an exception while trying to updateStatus for CinderExpandVolumeJob", e);
        setErrorStatus("Encountered an internal error during expand volume job status processing : " + e.getMessage());
    } finally {
        super.updateStatus(jobContext);
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) Volume(com.emc.storageos.db.client.model.Volume) CinderApi(com.emc.storageos.cinder.api.CinderApi) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 4 with VolumeExpandCompleter

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

the class SmisVolumeExpandJob method updateStatus.

/**
 * Called to update the job status when the volume expand job completes.
 *
 * @param jobContext The job context.
 */
public void updateStatus(JobContext jobContext) throws Exception {
    CloseableIterator<CIMObjectPath> associatorIterator = null;
    CloseableIterator<CIMInstance> instanceIterator = null;
    JobStatus jobStatus = getJobStatus();
    try {
        if (jobStatus == JobStatus.IN_PROGRESS) {
            return;
        }
        DbClient dbClient = jobContext.getDbClient();
        CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
        WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
        // from pool's reserved capacity map.
        if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
            SmisUtils.updateStoragePoolCapacity(dbClient, client, _storagePoolURI);
            StoragePool pool = dbClient.queryObject(StoragePool.class, _storagePoolURI);
            StringMap reservationMap = pool.getReservedCapacityMap();
            URI volumeId = getTaskCompleter().getId();
            // remove from reservation map
            reservationMap.remove(volumeId.toString());
            dbClient.persistObject(pool);
        }
        String opId = getTaskCompleter().getOpId();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s, task: %s", this.getJobName(), jobStatus.name(), opId));
        if (jobStatus == JobStatus.SUCCESS) {
            VolumeExpandCompleter taskCompleter = (VolumeExpandCompleter) getTaskCompleter();
            Volume volume = dbClient.queryObject(Volume.class, taskCompleter.getId());
            // set requested capacity
            volume.setCapacity(taskCompleter.getSize());
            // set meta related properties
            volume.setTotalMetaMemberCapacity(taskCompleter.getTotalMetaMembersSize());
            volume.setMetaMemberCount(taskCompleter.getMetaMemberCount());
            volume.setMetaMemberSize(taskCompleter.getMetaMemberSize());
            volume.setIsComposite(taskCompleter.isComposite());
            volume.setCompositionType(taskCompleter.getMetaVolumeType());
            // set provisioned capacity
            associatorIterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
            if (associatorIterator.hasNext()) {
                CIMObjectPath volumePath = associatorIterator.next();
                CIMInstance volumeInstance = client.getInstance(volumePath, true, false, null);
                if (volumeInstance != null) {
                    CIMProperty consumableBlocks = volumeInstance.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
                    CIMProperty blockSize = volumeInstance.getProperty(SmisConstants.CP_BLOCK_SIZE);
                    // calculate provisionedCapacity = consumableBlocks * block size
                    Long provisionedCapacity = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
                    volume.setProvisionedCapacity(provisionedCapacity);
                }
                // set allocated capacity
                instanceIterator = client.referenceInstances(volumePath, SmisConstants.CIM_ALLOCATED_FROM_STORAGEPOOL, null, false, SmisConstants.PS_SPACE_CONSUMED);
                if (instanceIterator.hasNext()) {
                    CIMInstance allocatedFromStoragePoolPath = instanceIterator.next();
                    CIMProperty spaceConsumed = allocatedFromStoragePoolPath.getProperty(SmisConstants.CP_SPACE_CONSUMED);
                    if (null != spaceConsumed) {
                        volume.setAllocatedCapacity(Long.valueOf(spaceConsumed.getValue().toString()));
                    }
                }
            }
            logMsgBuilder.append(String.format("%n   Capacity: %s, Provisioned capacity: %s, Allocated Capacity: %s", volume.getCapacity(), volume.getProvisionedCapacity(), volume.getAllocatedCapacity()));
            if (volume.getIsComposite()) {
                logMsgBuilder.append(String.format("%n   Is Meta: %s, Total meta member capacity: %s, Meta member count %s, Meta member size: %s", volume.getIsComposite(), volume.getTotalMetaMemberCapacity(), volume.getMetaMemberCount(), volume.getMetaMemberSize()));
            }
            _log.info(logMsgBuilder.toString());
            // Reset list of meta member volumes in the volume
            if (volume.getMetaVolumeMembers() != null) {
                volume.getMetaVolumeMembers().clear();
            }
            StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, volume.getStorageController());
            // set the RP tag on the volume if the volume is RP protected
            if (volume.checkForRp()) {
                SmisCommandHelper helper = jobContext.getSmisCommandHelper();
                boolean tagSet = helper.doApplyRecoverPointTag(storageSystem, volume, true);
                if (!tagSet) {
                    _log.error("Encountered an error while trying to enable the RecoverPoint tag.");
                    jobStatus = JobStatus.FAILED;
                }
            }
            dbClient.persistObject(volume);
            // Reset list of meta members native ids in WF data (when meta is created meta members are removed from array)
            WorkflowService.getInstance().storeStepData(opId, new ArrayList<String>());
        }
    } catch (Exception e) {
        _log.error("Caught an exception while trying to updateStatus for SmisVolumeExpandJob", e);
        setPostProcessingErrorStatus("Encountered an internal error during volume expand job status processing : " + e.getMessage());
    } finally {
        _metaVolumeTaskCompleter.setLastStepStatus(jobStatus);
        if (associatorIterator != null) {
            associatorIterator.close();
        }
        if (instanceIterator != null) {
            instanceIterator.close();
        }
        super.updateStatus(jobContext);
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) SmisCommandHelper(com.emc.storageos.volumecontroller.impl.smis.SmisCommandHelper) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 5 with VolumeExpandCompleter

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

Aggregations

StoragePool (com.emc.storageos.db.client.model.StoragePool)5 Volume (com.emc.storageos.db.client.model.Volume)5 VolumeExpandCompleter (com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)4 URI (java.net.URI)4 DbClient (com.emc.storageos.db.client.DbClient)3 StringMap (com.emc.storageos.db.client.model.StringMap)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 CinderApi (com.emc.storageos.cinder.api.CinderApi)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 HDSApiClient (com.emc.storageos.hds.api.HDSApiClient)1 LogicalUnit (com.emc.storageos.hds.model.LogicalUnit)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)1