Search in sources :

Example 1 with SRDFCopyRecommendation

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

the class SRDFBlockServiceApiImpl method createVolumesAndDescriptors.

@Override
public List<VolumeDescriptor> createVolumesAndDescriptors(List<VolumeDescriptor> descriptors, String volumeLabel, Long size, Project project, VirtualArray varray, VirtualPool vpool, List<Recommendation> recommendations, TaskList taskList, String task, VirtualPoolCapabilityValuesWrapper capabilities) {
    List<VolumeDescriptor> volumeDescriptors = new ArrayList<VolumeDescriptor>();
    // If processing SRDFCopyRecommendations, then just return the SRDFTargets.
    for (Recommendation recommendation : recommendations) {
        if (recommendation instanceof SRDFCopyRecommendation) {
            SRDFRecommendation srdfRecommendation = (SRDFRecommendation) recommendation.getRecommendation();
            // Get the Target structure
            SRDFRecommendation.Target target = srdfRecommendation.getVirtualArrayTargetMap().get(recommendation.getVirtualArray());
            if (target.getDescriptors() != null) {
                volumeDescriptors.addAll(target.getDescriptors());
            }
        }
        // so if we had SRDFCopyRecommendations, just return their descriptors now.
        if (!volumeDescriptors.isEmpty()) {
            return volumeDescriptors;
        }
    }
    // operation for each volume to be created.
    if (taskList == null) {
        taskList = new TaskList();
    }
    Iterator<Recommendation> recommendationsIter;
    final BlockConsistencyGroup consistencyGroup = capabilities.getBlockConsistencyGroup() == null ? null : _dbClient.queryObject(BlockConsistencyGroup.class, capabilities.getBlockConsistencyGroup());
    // prepare the volumes
    List<URI> volumeURIs = prepareRecommendedVolumes(task, taskList, project, varray, vpool, capabilities.getResourceCount(), recommendations, consistencyGroup, volumeLabel, size.toString());
    // Execute the volume creations requests for each recommendation.
    recommendationsIter = recommendations.iterator();
    while (recommendationsIter.hasNext()) {
        Recommendation recommendation = recommendationsIter.next();
        volumeDescriptors.addAll(createVolumeDescriptors((SRDFRecommendation) recommendation, volumeURIs, capabilities));
        // Log volume descriptor information
        logVolumeDescriptorPrecreateInfo(volumeDescriptors, task);
    }
    return volumeDescriptors;
}
Also used : SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 2 with SRDFCopyRecommendation

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

the class VPlexBlockServiceApiImpl method makeBackendVolumeDescriptors.

/**
 * Takes a list of recommendations and makes the backend volumes and volume descriptors needed to
 * provision. When possible (e.g. for SRDF and Block), All recommendations must be in single varray.
 * calls the underlying storage routine createVolumesAndDescriptors().
 *
 * @param recommendations -- a VPlex recommendation list
 * @param project - Project containing the Vplex volumes
 * @param vplexProject -- private project of the Vplex
 * @param rootVpool -- top level Virtual Pool (VpoolUse.ROOT)
 * @param varrayCount -- instance count of the varray being provisioned
 * @param size -- size of each volume
 * @param backendCG -- the CG to be used on the backend Storage Systems
 * @param vPoolCapabilities - a VirtualPoolCapabilityValuesWrapper containing provisioning arguments
 * @param createTask -- boolean if true creates a task
 * @param task -- Overall task id
 * @return -- list of VolumeDescriptors to be provisioned
 */
private List<VolumeDescriptor> makeBackendVolumeDescriptors(List<VPlexRecommendation> recommendations, Project project, Project vplexProject, VirtualPool rootVpool, String volumeLabel, int varrayCount, long size, BlockConsistencyGroup backendCG, VirtualPoolCapabilityValuesWrapper vPoolCapabilities, boolean createTask, String task) {
    VPlexRecommendation firstRecommendation = recommendations.get(0);
    List<VolumeDescriptor> descriptors = new ArrayList<VolumeDescriptor>();
    URI varrayId = firstRecommendation.getVirtualArray();
    VirtualPool vpool = firstRecommendation.getVirtualPool();
    s_logger.info("Generated backend descriptors for {} recommendations varray {}", recommendations.size(), varrayCount);
    vPoolCapabilities.put(VirtualPoolCapabilityValuesWrapper.AUTO_TIER__POLICY_NAME, vpool.getAutoTierPolicyName());
    if (firstRecommendation.getRecommendation() != null) {
        // If these recommendations have lower level recommendation, process them.
        // This path is used for the source side of Distributed Volumes and for Local volumes
        // where we support building on top of SRDF or the BlockStorage as appropriate.
        List<Recommendation> childRecommendations = new ArrayList<Recommendation>();
        Recommendation childRecommendation = null;
        for (VPlexRecommendation recommendation : recommendations) {
            childRecommendation = recommendation.getRecommendation();
            childRecommendations.add(childRecommendation);
        }
        VirtualArray varray = _dbClient.queryObject(VirtualArray.class, varrayId);
        String newVolumeLabel = generateVolumeLabel(volumeLabel, varrayCount, 0, 0);
        boolean srdfTarget = (childRecommendation instanceof SRDFCopyRecommendation);
        boolean srdfSource = (childRecommendation instanceof SRDFRecommendation);
        if (srdfTarget) {
            newVolumeLabel = newVolumeLabel + "-target";
        } else if (srdfSource) {
        } else {
            // nothing special about these volumes, hide them in the vplex project
            // We can't use the vplexProject for SRDF volumes as they determine their RDF group
            // grom the project.
            project = vplexProject;
        }
        TaskList taskList = new TaskList();
        descriptors = super.createVolumesAndDescriptors(descriptors, newVolumeLabel, size, project, varray, vpool, childRecommendations, taskList, task, vPoolCapabilities);
        VolumeDescriptor.Type[] types;
        if (srdfTarget) {
            types = new VolumeDescriptor.Type[] { VolumeDescriptor.Type.SRDF_TARGET };
        } else {
            types = new VolumeDescriptor.Type[] { VolumeDescriptor.Type.BLOCK_DATA, VolumeDescriptor.Type.SRDF_SOURCE, VolumeDescriptor.Type.SRDF_EXISTING_SOURCE };
        }
        descriptors = VolumeDescriptor.filterByType(descriptors, types);
        for (VolumeDescriptor descriptor : descriptors) {
            Volume volume = _dbClient.queryObject(Volume.class, descriptor.getVolumeURI());
            s_logger.info(String.format("Received prepared volume %s (%s, args) type %s", volume.getLabel(), volume.getId(), descriptor.getType().name()));
            volume.addInternalFlags(DataObject.Flag.INTERNAL_OBJECT);
            configureCGAndReplicationGroup(rootVpool, vPoolCapabilities, backendCG, volume);
            _dbClient.updateObject(volume);
        }
        return descriptors;
    }
    // Sum resourceCount across all recommendations
    int totalResourceCount = 0;
    for (VPlexRecommendation recommendation : recommendations) {
        totalResourceCount += recommendation.getResourceCount();
    }
    // The code below is used for the HA side of distributed volumes.
    // The HA side does not currently call the lower level schedulers to get descriptors.
    s_logger.info("Processing recommendations for Virtual Array {}", varrayId);
    int volumeCounter = 0;
    for (VPlexRecommendation recommendation : recommendations) {
        for (int i = 0; i < recommendation.getResourceCount(); i++) {
            vpool = recommendation.getVirtualPool();
            URI storageDeviceURI = recommendation.getSourceStorageSystem();
            URI storagePoolURI = recommendation.getSourceStoragePool();
            String newVolumeLabel = generateVolumeLabel(volumeLabel, varrayCount, volumeCounter, totalResourceCount);
            validateVolumeLabel(newVolumeLabel, project);
            s_logger.info("Volume label is {}", newVolumeLabel);
            VirtualArray varray = _dbClient.queryObject(VirtualArray.class, varrayId);
            // This is also handled in StorageScheduler.prepareRecomendedVolumes
            long thinVolumePreAllocationSize = 0;
            if (null != vpool.getThinVolumePreAllocationPercentage()) {
                thinVolumePreAllocationSize = VirtualPoolUtil.getThinVolumePreAllocationSize(vpool.getThinVolumePreAllocationPercentage(), size);
            }
            Volume volume = prepareVolume(VolumeType.BLOCK_VOLUME, null, size, thinVolumePreAllocationSize, vplexProject, varray, vpool, storageDeviceURI, storagePoolURI, newVolumeLabel, backendCG, vPoolCapabilities);
            configureCGAndReplicationGroup(rootVpool, vPoolCapabilities, backendCG, volume);
            volume.addInternalFlags(Flag.INTERNAL_OBJECT);
            _dbClient.persistObject(volume);
            if (createTask) {
                _dbClient.createTaskOpStatus(Volume.class, volume.getId(), task, ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
            }
            s_logger.info("Prepared volume {} ({}) ", volume.getLabel(), volume.getId());
            VolumeDescriptor descriptor = new VolumeDescriptor(VolumeDescriptor.Type.BLOCK_DATA, storageDeviceURI, volume.getId(), storagePoolURI, backendCG == null ? null : backendCG.getId(), vPoolCapabilities, size);
            descriptors.add(descriptor);
            volumeCounter++;
        }
    }
    return descriptors;
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) VolumeType(com.emc.storageos.api.service.impl.placement.VolumeRecommendation.VolumeType) Volume(com.emc.storageos.db.client.model.Volume)

Example 3 with SRDFCopyRecommendation

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

the class VPlexBlockServiceApiImpl method createVPlexVolumeDescriptors.

/**
 * Create the necessary volume descriptors for Vplex volumes, including the backend
 * volume descriptors and the virtual volume descriptors.
 *
 * @param param
 *            - the VolumeCreate parameters
 * @param project
 *            -- user's project
 * @param vArray
 *            -- virtual array volumes are created in
 * @param vPool
 *            -- virtual pool (ROOT) used to create the volumes
 * @param recommendations
 *            -- recommendations received from placement
 * @param task
 *            -- a task identifier
 * @param vPoolCapabilities
 *            - VirtualPoolCapabilitiesWrapper
 * @param blockConsistencyGroupURI
 *            - the block consistency group URI
 * @param taskList
 *            - OUTPUT list of tasks created
 * @param allVolumes
 *            - OUTPUT - list of volumes created
 * @param createTask
 *            -- boolean flag indicating to create tasks
 * @return
 */
public List<VolumeDescriptor> createVPlexVolumeDescriptors(VolumeCreate param, Project project, final VirtualArray vArray, final VirtualPool vPool, List<Recommendation> recommendations, String task, VirtualPoolCapabilityValuesWrapper vPoolCapabilities, URI blockConsistencyGroupURI, TaskList taskList, List<URI> allVolumes, boolean createTask) {
    s_logger.info("Request to create {} VPlex virtual volume(s)", vPoolCapabilities.getResourceCount());
    // Determine if we're processing an SRDF copy so we can set appropriate name.
    boolean srdfCopy = false;
    if (recommendations.get(0).getRecommendation() != null && recommendations.get(0).getRecommendation() instanceof SRDFCopyRecommendation) {
        srdfCopy = true;
    }
    // Sort the recommendations by VirtualArray. There can be up to two
    // VirtualArrays, the requested VirtualArray and the HA VirtualArray
    // either passed or determined by the placement when HA virtual volumes
    // are being created. We also set the VPlex storage system, which
    // should be the same for all recommendations.
    URI vplexStorageSystemURI = null;
    URI[] vplexSystemURIOut = new URI[1];
    Map<String, List<VPlexRecommendation>> varrayRecommendationsMap = sortRecommendationsByVarray(recommendations, vplexSystemURIOut);
    vplexStorageSystemURI = vplexSystemURIOut[0];
    // for the srdf copies, since they are already pre-created.
    if (!srdfCopy) {
        validateVolumeLabels(param.getName(), project, vPoolCapabilities, varrayRecommendationsMap);
    }
    // Determine the project to be used for the VPlex's artifacts
    StorageSystem vplexStorageSystem = _dbClient.queryObject(StorageSystem.class, vplexStorageSystemURI);
    Project vplexProject = getVplexProject(vplexStorageSystem, _dbClient, _tenantsService);
    // The volume size.
    long size = SizeUtil.translateSize(param.getSize());
    // The consistency group or null when not specified.
    final BlockConsistencyGroup consistencyGroup = blockConsistencyGroupURI == null ? null : _dbClient.queryObject(BlockConsistencyGroup.class, blockConsistencyGroupURI);
    // Find all volumes assigned to the group
    boolean cgContainsVolumes = false;
    if (consistencyGroup != null) {
        final List<Volume> activeCGVolumes = getActiveCGVolumes(consistencyGroup);
        cgContainsVolumes = (activeCGVolumes != null && !activeCGVolumes.isEmpty());
    }
    // If the consistency group is created but does not specify the LOCAL
    // type, the CG must be a CG created prior to 2.2 or an ingested CG. In
    // this case, we don't want a volume creation to result in backend CGs.
    // The only exception is if the CG does not reference any volumes. In
    // this case, if the LOCAL type isn't specified, we can create backend
    // CGs.
    BlockConsistencyGroup backendCG = null;
    if (consistencyGroup != null && (!consistencyGroup.created() || !cgContainsVolumes || consistencyGroup.getTypes().contains(Types.LOCAL.toString()))) {
        backendCG = consistencyGroup;
    }
    // Prepare Bourne volumes to represent the backend volumes for the
    // recommendations in each VirtualArray.
    int varrayCount = 0;
    String volumeLabel = param.getName();
    List<VolumeDescriptor> descriptors = new ArrayList<VolumeDescriptor>();
    URI[][] varrayVolumeURIs = new URI[2][vPoolCapabilities.getResourceCount()];
    Iterator<String> varrayIter = varrayRecommendationsMap.keySet().iterator();
    while (varrayIter.hasNext()) {
        String varrayId = varrayIter.next();
        s_logger.info("Processing backend recommendations for Virtual Array {}", varrayId);
        List<VPlexRecommendation> vplexRecommendations = varrayRecommendationsMap.get(varrayId);
        List<VolumeDescriptor> varrayDescriptors = makeBackendVolumeDescriptors(vplexRecommendations, project, vplexProject, vPool, volumeLabel, varrayCount, size, backendCG, vPoolCapabilities, createTask, task);
        descriptors.addAll(varrayDescriptors);
        List<URI> varrayURIs = VolumeDescriptor.getVolumeURIs(varrayDescriptors);
        allVolumes.addAll(varrayURIs);
        for (int i = 0; i < varrayURIs.size(); i++) {
            varrayVolumeURIs[varrayCount][i] = varrayURIs.get(i);
        }
        varrayCount++;
    }
    // Prepare Bourne volumes to represent the highly available virtual
    // volumes and associate the virtual volumes with their associated
    // backend volumes.
    s_logger.info("Preparing virtual volumes");
    List<URI> virtualVolumeURIs = new ArrayList<URI>();
    URI nullPoolURI = NullColumnValueGetter.getNullURI();
    vPoolCapabilities.put(VirtualPoolCapabilityValuesWrapper.AUTO_TIER__POLICY_NAME, null);
    for (int i = 0; i < vPoolCapabilities.getResourceCount(); i++) {
        // Compute the volume label based on the label of the underlying volume
        String volumeLabelBuilt = null;
        Volume associatedVolume = _dbClient.queryObject(Volume.class, varrayVolumeURIs[0][i]);
        // Get the virtual volume backing replication group instance name, if available.
        String backingReplicationGroupInstance = null;
        if (associatedVolume != null) {
            volumeLabelBuilt = generateLabelFromAssociatedVolume(volumeLabel, associatedVolume);
            backingReplicationGroupInstance = NullColumnValueGetter.isNotNullValue(associatedVolume.getReplicationGroupInstance()) ? associatedVolume.getReplicationGroupInstance() : NullColumnValueGetter.getNullStr();
        } else {
            volumeLabelBuilt = AbstractBlockServiceApiImpl.generateDefaultVolumeLabel(volumeLabel, i, vPoolCapabilities.getResourceCount());
        }
        s_logger.info("Volume label is {}", volumeLabelBuilt);
        Volume volume = StorageScheduler.getPrecreatedVolume(_dbClient, taskList, volumeLabelBuilt);
        boolean volumePrecreated = false;
        if (volume != null) {
            volumePrecreated = true;
        }
        long thinVolumePreAllocationSize = 0;
        if (null != vPool.getThinVolumePreAllocationPercentage()) {
            thinVolumePreAllocationSize = VirtualPoolUtil.getThinVolumePreAllocationSize(vPool.getThinVolumePreAllocationPercentage(), size);
        }
        volume = prepareVolume(VolumeType.VPLEX_VIRTUAL_VOLUME, volume, size, thinVolumePreAllocationSize, project, vArray, vPool, vplexStorageSystemURI, nullPoolURI, volumeLabelBuilt, consistencyGroup, vPoolCapabilities);
        StringSet associatedVolumes = new StringSet();
        associatedVolumes.add(varrayVolumeURIs[0][i].toString());
        s_logger.info("Associating volume {}", varrayVolumeURIs[0][i].toString());
        // associated with the virtual volume.
        if (varrayCount > 1) {
            associatedVolumes.add(varrayVolumeURIs[1][i].toString());
            s_logger.info("Associating volume {}", varrayVolumeURIs[1][i].toString());
        }
        volume.setAssociatedVolumes(associatedVolumes);
        if (null != backingReplicationGroupInstance) {
            s_logger.info("Setting virtual volume backingReplicationGroupInstance to {}", backingReplicationGroupInstance);
            volume.setBackingReplicationGroupInstance(backingReplicationGroupInstance);
        }
        _dbClient.updateObject(volume);
        URI volumeId = volume.getId();
        s_logger.info("Prepared virtual volume {}", volumeId);
        virtualVolumeURIs.add(volumeId);
        allVolumes.add(volumeId);
        if (createTask && !volumePrecreated) {
            Operation op = _dbClient.createTaskOpStatus(Volume.class, volume.getId(), task, ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
            TaskResourceRep volumeTask = toTask(volume, task, op);
            taskList.getTaskList().add(volumeTask);
        }
        VolumeDescriptor descriptor = new VolumeDescriptor(VolumeDescriptor.Type.VPLEX_VIRT_VOLUME, vplexStorageSystemURI, volumeId, null, consistencyGroup == null ? null : consistencyGroup.getId(), vPoolCapabilities, volume.getCapacity());
        // Set the compute resource in the descriptor if the volume to be created will be exported
        // to a host/cluster after it has been created so that the compute resource name can be
        // included in the volume name if the custom volume naming is so configured. Do not set the
        // compute resource if the descriptor is for an SRDF target as the target is not exported
        // to the compute resource.
        URI computeResourceURI = param.getComputeResource();
        if ((computeResourceURI != null) && (!srdfCopy)) {
            s_logger.info(String.format("Volume %s - will be exported to Host/Cluster: %s", volume.getLabel(), computeResourceURI.toString()));
            descriptor.setComputeResource(computeResourceURI);
        }
        descriptors.add(descriptor);
    }
    return descriptors;
}
Also used : ArrayList(java.util.ArrayList) Operation(com.emc.storageos.db.client.model.Operation) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) StringSet(com.emc.storageos.db.client.model.StringSet) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) VolumeGroupVolumeList(com.emc.storageos.model.application.VolumeGroupUpdateParam.VolumeGroupVolumeList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystemConnectivityList(com.emc.storageos.model.systems.StorageSystemConnectivityList) List(java.util.List) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Project(com.emc.storageos.db.client.model.Project) Volume(com.emc.storageos.db.client.model.Volume)

Example 4 with SRDFCopyRecommendation

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

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

the class SRDFScheduler method getRecommendationsForCopy.

/**
 * This routine retrieves recommendations for the SRDF_COPY from previously generated SRDF Source
 * recommendations. The SRDF scheduler generates them together, but upper layers of code need
 * them separately so they can be encapsulated in higher level recommendations such as Vplex.
 * @param vArray - Virtual Array object
 * @param project - Project object
 * @param vPool - Virtual Pool object
 * @param capabilities - VirtualPoolCapabilitiesWrapper contains parameters
 * @param currentRecommendations - Contains the current recommendations that would include SRDFRecommendations.
 * The SrdfCopyRecommendations are generated from them
 * @return - List of Recommendations, specifically, SRDFCopyRecommendations
 */
private List<Recommendation> getRecommendationsForCopy(VirtualArray vArray, Project project, VirtualPool vPool, VirtualPoolCapabilityValuesWrapper capabilities, List<Recommendation> currentRecommendations) {
    List<Recommendation> recommendations = new ArrayList<Recommendation>();
    if (currentRecommendations == null) {
        throw WorkflowException.exceptions.workflowConstructionError("Required parameter currentRecommendations is null");
    }
    // that has has matching varray and vpool.
    for (Recommendation recommendation : currentRecommendations) {
        Recommendation rec = recommendation;
        while (rec != null) {
            if (rec instanceof SRDFRecommendation) {
                SRDFRecommendation srdfrec = (SRDFRecommendation) rec;
                if (srdfrec.getVirtualArrayTargetMap().containsKey(vArray.getId())) {
                    SRDFRecommendation.Target target = srdfrec.getVirtualArrayTargetMap().get(vArray.getId());
                    _log.info(String.format("Found SRDF target recommendation for va %s vpool %s", vArray.getLabel(), vPool.getLabel()));
                    SRDFCopyRecommendation targetRecommendation = new SRDFCopyRecommendation();
                    targetRecommendation.setVirtualArray(vArray.getId());
                    targetRecommendation.setVirtualPool(vPool);
                    targetRecommendation.setSourceStorageSystem(target.getTargetStorageDevice());
                    targetRecommendation.setSourceStoragePool(target.getTargetStoragePool());
                    targetRecommendation.setResourceCount(srdfrec.getResourceCount());
                    targetRecommendation.setRecommendation(srdfrec);
                    recommendations.add(targetRecommendation);
                }
            }
            // Check child recommendations, if any
            rec = rec.getRecommendation();
        }
    }
    return recommendations;
}
Also used : SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) ArrayList(java.util.ArrayList) Target(com.emc.storageos.volumecontroller.SRDFRecommendation.Target) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation)

Aggregations

SRDFCopyRecommendation (com.emc.storageos.volumecontroller.SRDFCopyRecommendation)11 ArrayList (java.util.ArrayList)11 Recommendation (com.emc.storageos.volumecontroller.Recommendation)10 SRDFRecommendation (com.emc.storageos.volumecontroller.SRDFRecommendation)10 NamedURI (com.emc.storageos.db.client.model.NamedURI)9 URI (java.net.URI)9 VPlexRecommendation (com.emc.storageos.volumecontroller.VPlexRecommendation)8 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)7 Project (com.emc.storageos.db.client.model.Project)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 StringSet (com.emc.storageos.db.client.model.StringSet)6 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)6 List (java.util.List)6 VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)5 Network (com.emc.storageos.db.client.model.Network)5 StoragePool (com.emc.storageos.db.client.model.StoragePool)5 StringMap (com.emc.storageos.db.client.model.StringMap)5 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)5 VpoolRemoteCopyProtectionSettings (com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings)5 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)5