Search in sources :

Example 1 with VolumeRecommendation

use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.

the class AbstractBlockServiceApiImpl method createVolumesAndDescriptors.

@Override
public List<VolumeDescriptor> createVolumesAndDescriptors(List<VolumeDescriptor> descriptors, String name, Long size, Project project, VirtualArray varray, VirtualPool vpool, List<Recommendation> recommendations, TaskList taskList, String task, VirtualPoolCapabilityValuesWrapper vpoolCapabilities) {
    BlockServiceApi api = null;
    List<VolumeDescriptor> volumeDescriptors = new ArrayList<VolumeDescriptor>();
    for (Recommendation recommendation : recommendations) {
        if (recommendation instanceof SRDFRecommendation || recommendation instanceof SRDFCopyRecommendation) {
            api = BlockService.getBlockServiceImpl(DiscoveredDataObject.Type.srdf.name());
        } else if (recommendation instanceof VolumeRecommendation) {
            api = BlockService.getBlockServiceImpl(BlockServiceApi.DEFAULT);
        } else {
            String message = String.format("No BlockServiceApiImpl to handle recommendation of class: ", recommendation.getClass().getName());
            s_logger.error(message);
            throw WorkflowException.exceptions.workflowConstructionError(message);
        }
        volumeDescriptors.addAll(api.createVolumesAndDescriptors(descriptors, name, size, project, varray, vpool, recommendations, taskList, task, vpoolCapabilities));
    }
    return volumeDescriptors;
}
Also used : SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) ArrayList(java.util.ArrayList) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation)

Example 2 with VolumeRecommendation

use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method prepareVolume.

/**
 * Prepare a new Bourne Volume.
 *
 * @param volume pre-created volume (optional)
 * @param size The volume capacity.
 * @param thinVolumePreAllocationSize preallocation size for thin provisioning or 0.
 * @param project A reference to the project.
 * @param vArray A reference to the virtual array
 * @param vPool The requested virtual pool.
 * @param storageSystemURI The URI of the storage system.
 * @param storagePoolURI The URI of the storage pool.
 * @param label The label for the new volume.
 * @param consistencyGroup The consistency group.
 * @param capabilities The virtual pool capabilities
 *
 * @return A reference to the newly persisted Volume.
 */
private Volume prepareVolume(VolumeType volType, Volume volume, long size, long thinVolumePreAllocationSize, Project project, VirtualArray vArray, VirtualPool vPool, URI storageSystemURI, URI storagePoolURI, String label, BlockConsistencyGroup consistencyGroup, VirtualPoolCapabilityValuesWrapper capabilities) {
    // Encapsulate the storage system and storage pool in a
    // volume recommendation and use the default implementation.
    VolumeRecommendation volRecomendation = new VolumeRecommendation(volType, size, vPool, vArray.getId());
    volRecomendation.addStorageSystem(storageSystemURI);
    volRecomendation.addStoragePool(storagePoolURI);
    volume = StorageScheduler.prepareVolume(_dbClient, volume, size, thinVolumePreAllocationSize, project, vArray, vPool, volRecomendation, label, consistencyGroup, capabilities);
    // For VPLEX volumes, the protocol will not be set when the
    // storage scheduler is invoked to prepare the volume because
    // there is no storage pool associated with the volume. So, set
    // it to FC here.
    StringSet protocols = new StringSet();
    protocols.add(StorageProtocol.Block.FC.name());
    volume.setProtocol(protocols);
    _dbClient.updateObject(volume);
    return volume;
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation)

Example 3 with VolumeRecommendation

use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.

the class DefaultBlockFullCopyApiImpl method create.

/**
 * {@inheritDoc}
 */
@Override
public TaskList create(List<BlockObject> fcSourceObjList, VirtualArray varray, String name, boolean createInactive, int count, String taskId) {
    // Get the placement recommendations for the full copies and
    // prepare the ViPR volumes to represent the full copies.
    // TBD We are getting recommendations one at a time instead
    // of for all full copies at the same time as was done
    // previously. However, now we are allowing for creating
    // full copies for multiple volume form a CG. These volumes
    // could have different vpools and sizes. Therefore, I don't
    // see how we can get them at the same time for all volumes
    // as the capabilities could be different. I guess the
    // possible result is that if the volumes are the same, they
    // could be placed in the same storage pool and if the pool
    // is approaching capacity, there may not actually be enough
    // space in the recommended pool.
    int sourceCounter = 0;
    List<Volume> volumesList = new ArrayList<Volume>();
    BlockObject aFCSource = null;
    Map<URI, VirtualArray> vArrayCache = new HashMap<URI, VirtualArray>();
    List<BlockObject> sortedSourceObjectList = sortFullCopySourceList(fcSourceObjList);
    try {
        for (BlockObject fcSourceObj : sortedSourceObjectList) {
            // Make sure when there are multiple source objects,
            // each full copy has a unique name.
            aFCSource = fcSourceObj;
            // volumes in VolumeGroup can be from different vArrays
            varray = getVarrayFromCache(vArrayCache, fcSourceObj.getVirtualArray());
            String copyName = null;
            boolean inApplication = false;
            if (aFCSource instanceof Volume && ((Volume) aFCSource).getApplication(_dbClient) != null) {
                inApplication = true;
            }
            if (NullColumnValueGetter.isNotNullValue(fcSourceObj.getReplicationGroupInstance()) && inApplication) {
                copyName = name + "-" + fcSourceObj.getReplicationGroupInstance() + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
            } else {
                copyName = name + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
            }
            VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(fcSourceObj, _dbClient);
            VirtualPoolCapabilityValuesWrapper capabilities = getCapabilitiesForFullCopyCreate(fcSourceObj, vpool, count);
            List<VolumeRecommendation> placementRecommendations = getPlacementRecommendations(fcSourceObj, capabilities, varray, vpool.getId());
            volumesList.addAll(prepareClonesForEachRecommendation(copyName, name, fcSourceObj, capabilities, createInactive, placementRecommendations));
        }
    } catch (Exception ex) {
        handlePlacementFailure(volumesList);
        throw ex;
    }
    // get volume descriptors
    List<VolumeDescriptor> volumeDescriptors = prepareVolumeDescriptorsForFullCopy(volumesList, createInactive);
    // get all tasks
    TaskList tasks = getTasksForCreateFullCopy(aFCSource, volumesList, taskId);
    try {
        BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
        controller.createFullCopy(volumeDescriptors, taskId);
    } catch (InternalException ie) {
        handleFailedRequest(taskId, tasks, volumesList, ie, true);
    }
    return tasks;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) BlockOrchestrationController(com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController) HashMap(java.util.HashMap) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 4 with VolumeRecommendation

use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.

the class DefaultBlockFullCopyApiImpl method prepareClonesForEachRecommendation.

/**
 * Prepares a ViPR volume instance for each full copy.
 *
 * @param name The full copy name.
 * @param cloneSetName
 * @param blockObject The full copy source.
 * @param capabilities The full copy capabilities.
 * @param createInactive true to create the full copies inactive, false otherwise.
 * @param placementRecommendations The placement recommendation for each full copy.
 *
 * @return A list of volumes representing the full copies.
 */
private List<Volume> prepareClonesForEachRecommendation(String name, String cloneSetName, BlockObject blockObject, VirtualPoolCapabilityValuesWrapper capabilities, Boolean createInactive, List<VolumeRecommendation> placementRecommendations) {
    // Prepare clones for each recommendation
    List<Volume> volumesList = new ArrayList<Volume>();
    List<Volume> toUpdate = new ArrayList<Volume>();
    boolean inApplication = false;
    if (blockObject instanceof Volume && ((Volume) blockObject).getApplication(_dbClient) != null) {
        inApplication = true;
    }
    int volumeCounter = (capabilities.getResourceCount() > 1) ? 1 : 0;
    for (VolumeRecommendation recommendation : placementRecommendations) {
        Volume volume = StorageScheduler.prepareFullCopyVolume(_dbClient, name, blockObject, recommendation, volumeCounter, capabilities, createInactive);
        // For Application, set the user provided clone name on all the clones to identify clone set
        if (inApplication) {
            volume.setFullCopySetName(cloneSetName);
            toUpdate.add(volume);
        }
        volumesList.add(volume);
        // set volume Id in the recommendation
        recommendation.setId(volume.getId());
        volumeCounter++;
    }
    // persist changes
    if (!toUpdate.isEmpty()) {
        _dbClient.updateObject(toUpdate);
    }
    return volumesList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation)

Example 5 with VolumeRecommendation

use of com.emc.storageos.api.service.impl.placement.VolumeRecommendation in project coprhd-controller by CoprHD.

the class DefaultBlockFullCopyApiImpl method getPlacementRecommendations.

/**
 * Get the placement recommendations for the passed full copy source.
 *
 * @param blockObject A reference to the full copy source.
 * @param capabilities Encapsulates the copy capabilities
 * @param varray A reference to the virtual array.
 * @param vpoolURI The URI of the virtual pool for the source.
 *
 * @return A list of volume placement recommendations.
 */
private List<VolumeRecommendation> getPlacementRecommendations(BlockObject blockObject, VirtualPoolCapabilityValuesWrapper capabilities, VirtualArray varray, URI vpoolURI) {
    // Find placement for block volume copies
    VirtualPool vPool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
    List<VolumeRecommendation> placementRecommendations = ((StorageScheduler) _scheduler).getRecommendationsForVolumeClones(varray, vPool, blockObject, capabilities);
    if (placementRecommendations.isEmpty()) {
        throw APIException.badRequests.invalidParameterNoStorageFoundForVolume(varray.getId(), vPool.getId(), blockObject.getId());
    }
    return placementRecommendations;
}
Also used : StorageScheduler(com.emc.storageos.api.service.impl.placement.StorageScheduler) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation)

Aggregations

VolumeRecommendation (com.emc.storageos.api.service.impl.placement.VolumeRecommendation)9 ArrayList (java.util.ArrayList)6 Volume (com.emc.storageos.db.client.model.Volume)5 VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)4 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)4 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)4 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 Recommendation (com.emc.storageos.volumecontroller.Recommendation)3 URI (java.net.URI)3 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 Project (com.emc.storageos.db.client.model.Project)2 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)2 TaskList (com.emc.storageos.model.TaskList)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 SRDFCopyRecommendation (com.emc.storageos.volumecontroller.SRDFCopyRecommendation)2 SRDFRecommendation (com.emc.storageos.volumecontroller.SRDFRecommendation)2 HashMap (java.util.HashMap)2 StorageScheduler (com.emc.storageos.api.service.impl.placement.StorageScheduler)1