Search in sources :

Example 26 with RPRecommendation

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

the class RPBlockServiceApiImpl method addJournalCapacity.

/**
 * Add additional journal volume(s) to an existing recoverpoint
 * consistency group copy
 *
 * @param param - journal volume(s) creation parameters
 * @param project - the project
 * @param journalVarray - the virtual array for the journal(s)
 * @param journalVpool - the virtual pool for the journal(s)
 * @param consistencyGroup - the recoverpoint consistency group
 * @param capabilities - parameters for the journal volume(s)
 * @param task - the task identifier
 * @return TaskList
 */
public TaskList addJournalCapacity(VolumeCreate param, Project project, VirtualArray journalVarray, VirtualPool journalVpool, BlockConsistencyGroup consistencyGroup, VirtualPoolCapabilityValuesWrapper capabilities, String task) {
    ProtectionSystem protectionSystem = getBlockScheduler().getCgProtectionSystem(consistencyGroup.getId());
    if (protectionSystem != null) {
        _log.info("Narrowing down placement to use protection system {}, which is currently used by RecoverPoint consistency group {}.", protectionSystem.getLabel(), consistencyGroup);
    } else {
        throw APIException.badRequests.noProtectionSystemAssociatedWithTheCG(consistencyGroup.getId().toString());
    }
    // copy name to add the journal volume to
    String copyName = param.getName();
    // rp cluster internal site name of the copy
    String internalSiteName = null;
    // adding journal to a source copy
    boolean isSource = false;
    // adding journal to a target copy
    boolean isTarget = false;
    // adding journal to a metropoint standby copy
    boolean isMPStandby = copyName.contains("Standby");
    // get the list of source and target volumes; for metropoint, source volumes include both sides of the source
    // metro volume
    List<Volume> sourceVolumes = RPHelper.getCgSourceVolumes(consistencyGroup.getId(), _dbClient);
    if (sourceVolumes.isEmpty()) {
        throw APIException.badRequests.noSourceVolumesInCG(consistencyGroup.getLabel());
    }
    // only need one source volume to set up parameters for the operation
    Volume firstSrc = sourceVolumes.get(0);
    StringSet sourceInternalSiteNames = new StringSet();
    // both the active and the standby copies
    if (RPHelper.isMetroPointVolume(_dbClient, firstSrc)) {
        StringSet associatedVolumes = firstSrc.getAssociatedVolumes();
        if (associatedVolumes != null && !associatedVolumes.isEmpty()) {
            for (String associatedVolumeStr : associatedVolumes) {
                URI associatedVolumeURI = URI.create(associatedVolumeStr);
                Volume associatedVolume = _dbClient.queryObject(Volume.class, associatedVolumeURI);
                sourceInternalSiteNames.add(associatedVolume.getInternalSiteName());
                if (NullColumnValueGetter.isNotNullValue(associatedVolume.getRpCopyName())) {
                    if (associatedVolume.getRpCopyName().equals(copyName)) {
                        isSource = !isMPStandby;
                        internalSiteName = associatedVolume.getInternalSiteName();
                    }
                }
            }
        }
    // determine the internal site name for a source copy
    } else {
        sourceInternalSiteNames.add(firstSrc.getInternalSiteName());
        if (NullColumnValueGetter.isNotNullValue(firstSrc.getRpCopyName())) {
            if (firstSrc.getRpCopyName().equals(copyName)) {
                isSource = true;
                internalSiteName = firstSrc.getInternalSiteName();
            }
        }
    }
    // determine the internal site name for a target copy
    for (String targetURIString : firstSrc.getRpTargets()) {
        Volume tgtVolume = _dbClient.queryObject(Volume.class, URI.create(targetURIString));
        if (NullColumnValueGetter.isNotNullValue(tgtVolume.getRpCopyName()) && tgtVolume.getRpCopyName().equals(copyName)) {
            isTarget = true;
            internalSiteName = tgtVolume.getInternalSiteName();
        }
    }
    if (internalSiteName == null) {
        throw APIException.badRequests.unableToFindTheSpecifiedCopy(copyName);
    }
    // if we're adding volumes to a target, we need to know if it's local or remote
    String targetType = RPHelper.LOCAL;
    int copyType = RecoverPointCGCopyType.PRODUCTION.getCopyNumber();
    if (isTarget) {
        if (sourceInternalSiteNames.contains(internalSiteName)) {
            copyType = RecoverPointCGCopyType.LOCAL.getCopyNumber();
            targetType = RPHelper.LOCAL;
        } else {
            copyType = RecoverPointCGCopyType.REMOTE.getCopyNumber();
            targetType = RPHelper.REMOTE;
        }
    }
    capabilities.put(VirtualPoolCapabilityValuesWrapper.RP_COPY_TYPE, copyType);
    RPProtectionRecommendation rpProtectionRecommendation = new RPProtectionRecommendation();
    rpProtectionRecommendation.setProtectionDevice(protectionSystem.getId());
    RPRecommendation journalRecommendation = getBlockScheduler().buildJournalRecommendation(rpProtectionRecommendation, internalSiteName, new Long(capabilities.getSize()).toString(), journalVarray, journalVpool, protectionSystem, capabilities, capabilities.getResourceCount(), null, false);
    if (journalRecommendation == null) {
        throw APIException.badRequests.unableToFindSuitableJournalRecommendation();
    }
    String copyTypeString = RPHelper.SOURCE;
    if (isSource) {
        rpProtectionRecommendation.setSourceJournalRecommendation(journalRecommendation);
    }
    if (isMPStandby) {
        rpProtectionRecommendation.setStandbyJournalRecommendation(journalRecommendation);
        copyTypeString = "standby " + RPHelper.SOURCE;
    }
    if (isTarget) {
        List<RPRecommendation> journalRecommendations = Lists.newArrayList();
        journalRecommendations.add(journalRecommendation);
        rpProtectionRecommendation.setTargetJournalRecommendations(journalRecommendations);
        copyTypeString = targetType + " " + RPHelper.TARGET;
    }
    List<Recommendation> recommendations = Lists.newArrayList();
    recommendations.add(rpProtectionRecommendation);
    // need to set the journal copy name to something unique
    param.setName(copyName + "_" + task);
    _log.info("Request to add journal capacity to {} copy {}", copyTypeString, copyName);
    _log.info("Copy {} is protected by RP Site {}", copyName, internalSiteName);
    TaskList taskList = new TaskList();
    Map<VpoolUse, List<Recommendation>> recommendationMap = new HashMap<VpoolUse, List<Recommendation>>();
    recommendationMap.put(VpoolUse.ROOT, recommendations);
    return this.createVolumes(param, project, journalVarray, journalVpool, recommendationMap, taskList, task, capabilities);
}
Also used : VpoolUse(com.emc.storageos.api.service.impl.placement.VpoolUse) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) HashMap(java.util.HashMap) TaskList(com.emc.storageos.model.TaskList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) Recommendation(com.emc.storageos.volumecontroller.Recommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) Volume(com.emc.storageos.db.client.model.Volume) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) 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)

Example 27 with RPRecommendation

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

the class RPBlockServiceApiImpl method createRecoverPointVolume.

/**
 * Prepare the volume to be used by the controllers for RP.
 *
 * This includes preparing the volume for any of the leveraged technologies (ex: VPLEX) and
 * lastly for RP.
 *
 * @param rpRec The rec for the RP volume to get most of the info in preparing it
 * @param rpVolumeName Volume name
 * @param project Project for the volume
 * @param capabilities Capabilities for the volume create
 * @param consistencyGroup CG for the volume
 * @param param Volume create param for this volume
 * @param protectionSystemURI URI for the Protection System being used
 * @param personalityType Personality of the volume
 * @param rsetName Replication set name
 * @param preCreatedVolume An optionally pre-created source volume, non-null when calling this method to create a SOURCE volume.
 * @param sourceVolume Source volume. Sent down if we're making a target/metadata that needs to be associated to this volume.
 * @param taskList Tasklist to capture all tasks for the UI
 * @param task Task Id
 * @param copyName RP Copy Name
 * @param descriptors Descriptors to be populated
 * @param changeVpoolVolume Existing volume for change vpool volume if it exist
 * @param isChangeVpool Boolean to indicate if this is a change vpool op
 * @param isSrcAndHaSwapped Boolean to indicate if this is a swapped Src and HA op
 * @param productionCopy whether this is a production copy or not
 * @return Prepared RP Volume
 */
private Volume createRecoverPointVolume(RPRecommendation rpRec, String rpVolumeName, Project project, VirtualPoolCapabilityValuesWrapper capabilities, BlockConsistencyGroup consistencyGroup, VolumeCreate param, URI protectionSystemURI, Volume.PersonalityTypes personalityType, String rsetName, Volume preCreatedVolume, Volume sourceVolume, TaskList taskList, String task, String copyName, List<VolumeDescriptor> descriptors, Volume changeVpoolVolume, boolean isChangeVpool, boolean isSrcAndHaSwapped, boolean productionCopy) {
    boolean isPreCreatedVolume = (preCreatedVolume != null);
    Volume rpVolume = preCreatedVolume;
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, rpRec.getVirtualArray());
    VirtualPool vpool = rpRec.getVirtualPool();
    String rpInternalSiteName = rpRec.getInternalSiteName();
    URI storagePoolUri = rpRec.getSourceStoragePool();
    URI storageSystemUri = rpRec.getSourceStorageSystem();
    String size = String.valueOf(rpRec.getSize());
    // If the copy name was passed in as null, let's get it from the cg or create it
    if (copyName == null) {
        copyName = retrieveRpCopyName(vpool, varray, consistencyGroup, productionCopy);
    }
    // Determine if we're creating a RP+VPLEX or MetroPoint volume
    boolean vplex = VirtualPool.vPoolSpecifiesHighAvailability(vpool);
    _log.info(String.format("Prepare %s Volume %s %s(%s/%s)%s. It will be placed in CG [%s] and " + "will be protected by RecoverPoint (Protection System: %s) with RP Copy Name [%s] on RP Internal Site [%s] " + "as part of RP Replication Set [%s].", personalityType.toString(), (vplex ? "(VPLEX) -" : "-"), rpVolumeName, varray.getLabel(), vpool.getLabel(), (isChangeVpool ? ". This is an existing volume that is involved in a change virtual pool operation." : ""), consistencyGroup.getLabel(), protectionSystemURI.toString(), copyName, rpInternalSiteName, rsetName));
    if (vplex) {
        List<Recommendation> vplexRecs = new ArrayList<Recommendation>();
        // Add VPLEX Source Rec
        vplexRecs.add(0, rpRec.getVirtualVolumeRecommendation());
        // Add VPLEX HA Rec, if it exists
        if (rpRec.getHaRecommendation() != null) {
            vplexRecs.add(1, rpRec.getHaRecommendation().getVirtualVolumeRecommendation());
        }
        // Prepare VPLEX specific volume info
        rpVolume = prepareVPlexVolume(vplexRecs, project, varray, vpool, storagePoolUri, storageSystemUri, capabilities, consistencyGroup, param, rpVolumeName, size, descriptors, taskList, task, personalityType, isChangeVpool, changeVpoolVolume);
    }
    // Prepare RP specific volume info
    rpVolume = prepareVolume(rpVolume, project, varray, vpool, size, rpRec, rpVolumeName, consistencyGroup, protectionSystemURI, personalityType, rsetName, rpInternalSiteName, copyName, sourceVolume, vplex, changeVpoolVolume, isPreCreatedVolume);
    boolean createTask = isTaskRequired(rpVolume, capabilities, vplex, taskList);
    if (createTask) {
        // Create a task for this volume
        createTaskForVolume(rpVolume, capabilities, taskList, task);
    }
    return rpVolume;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Recommendation(com.emc.storageos.volumecontroller.Recommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation)

Example 28 with RPRecommendation

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

the class RecoverPointScheduler method initResources.

/**
 * Initialize common resources
 */
private void initResources() {
    // initialize the storage pool -> storage systems map
    this.storagePoolStorageSystemCache = new HashMap<String, List<String>>();
    // Reset the HA Recommendations
    this.srcHaRecommendation = new RPRecommendation();
    this.tgtHaRecommendation = new HashMap<URI, Recommendation>();
    this.tgtVarrayHasHaVpool = new HashMap<VirtualArray, Boolean>();
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URI(java.net.URI) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation)

Aggregations

RPRecommendation (com.emc.storageos.volumecontroller.RPRecommendation)28 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)22 ArrayList (java.util.ArrayList)21 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)19 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)18 StoragePool (com.emc.storageos.db.client.model.StoragePool)16 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)15 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)14 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)14 List (java.util.List)14 NamedURI (com.emc.storageos.db.client.model.NamedURI)13 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)13 StringMap (com.emc.storageos.db.client.model.StringMap)12 StringSet (com.emc.storageos.db.client.model.StringSet)12 VpoolProtectionVarraySettings (com.emc.storageos.db.client.model.VpoolProtectionVarraySettings)12 Recommendation (com.emc.storageos.volumecontroller.Recommendation)12 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)11 VPlexRecommendation (com.emc.storageos.volumecontroller.VPlexRecommendation)11 Network (com.emc.storageos.db.client.model.Network)10 Project (com.emc.storageos.db.client.model.Project)10