Search in sources :

Example 26 with VpoolProtectionVarraySettings

use of com.emc.storageos.db.client.model.VpoolProtectionVarraySettings in project coprhd-controller by CoprHD.

the class VirtualPoolChangeAnalyzer method determineRPTargetMigration.

/**
 * Determines if there are any Target migrations and adds them to the
 * potentialMigrations container.
 *
 * @param volume The change vpool volume
 * @param currentVpool The change vpool volume's current vpool
 * @param newVpool The target vpool to move to
 * @param potentialMigrations Container for migrations
 * @param notSuppReasonBuff Buffer for not supported reasons
 * @param dbClient DbClient instance
 * @return true if invalid migration, false otherwise
 */
private static boolean determineRPTargetMigration(Volume volume, VirtualPool currentVpool, VirtualPool newVpool, List<RPVPlexMigration> potentialMigrations, StringBuffer notSuppReasonBuff, DbClient dbClient) {
    boolean invalidMigration = false;
    if (currentVpool.getProtectionVarraySettings() == null || newVpool.getProtectionVarraySettings() == null || (currentVpool.getProtectionVarraySettings().size() != newVpool.getProtectionVarraySettings().size())) {
        notSuppReasonBuff.append("RP Targets are mismatched.");
        return true;
    }
    // Check the Targets for potential candidates for migration
    for (Map.Entry<String, String> entry : currentVpool.getProtectionVarraySettings().entrySet()) {
        String targetVarrayId = entry.getKey();
        // exclude the migration operation.
        if (newVpool.getProtectionVarraySettings().containsKey(targetVarrayId)) {
            String currentProtectionVarraySettingsId = entry.getValue();
            String newProtectionVarraySettingsId = newVpool.getProtectionVarraySettings().get(targetVarrayId);
            // Get the current protection varray settings
            VpoolProtectionVarraySettings currentProtectionVarraySetting = dbClient.queryObject(VpoolProtectionVarraySettings.class, URI.create(currentProtectionVarraySettingsId));
            // Get the new protection varray settings
            VpoolProtectionVarraySettings newProtectionVarraySetting = dbClient.queryObject(VpoolProtectionVarraySettings.class, URI.create(newProtectionVarraySettingsId));
            // Current Target vpool
            String currentTargetVpoolId = NullColumnValueGetter.getStringValue(currentProtectionVarraySetting.getVirtualPool());
            if (currentTargetVpoolId.equals(NullColumnValueGetter.getNullStr())) {
                currentTargetVpoolId = currentVpool.getId().toString();
            }
            VirtualPool currentTargetVpool = dbClient.queryObject(VirtualPool.class, URI.create(currentTargetVpoolId));
            // New Target vpool
            String newTargetVpoolId = NullColumnValueGetter.getStringValue(newProtectionVarraySetting.getVirtualPool());
            if (newTargetVpoolId.equals(NullColumnValueGetter.getNullStr())) {
                newTargetVpoolId = newVpool.getId().toString();
            }
            VirtualPool newTargetVpool = dbClient.queryObject(VirtualPool.class, URI.create(newTargetVpoolId));
            // Only allow migrations when both vpools specify HA.
            if (!currentTargetVpoolId.equals(newTargetVpoolId)) {
                if (VirtualPool.vPoolSpecifiesHighAvailability(currentTargetVpool) && VirtualPool.vPoolSpecifiesHighAvailability(newTargetVpool)) {
                    // Add Target for potential migration
                    potentialMigrations.add(new RPVPlexMigration(Volume.PersonalityTypes.TARGET, URI.create(targetVarrayId), currentTargetVpool, newTargetVpool));
                } else {
                    // This Target is not a candidate for migration and the vpools are not the exact
                    // same so we can not allow the migration. The Targets could potentially get misaligned
                    // in the new vpool and we can not allow that.
                    notSuppReasonBuff.append("No RP Target migration detected, so RP Target virtual pools must match.");
                    invalidMigration = true;
                    break;
                }
            }
            // Target Journal
            invalidMigration = determineRPTargetJournalMigration(volume, currentTargetVpool, newTargetVpool, potentialMigrations, notSuppReasonBuff, dbClient, currentProtectionVarraySetting, newProtectionVarraySetting, targetVarrayId);
            if (invalidMigration) {
                break;
            }
        } else {
            notSuppReasonBuff.append("Target virtual arrays do not match.");
            invalidMigration = true;
            break;
        }
    }
    return invalidMigration;
}
Also used : VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Map(java.util.Map) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 27 with VpoolProtectionVarraySettings

use of com.emc.storageos.db.client.model.VpoolProtectionVarraySettings in project coprhd-controller by CoprHD.

the class RecoverPointScheduler method buildCgRecommendations.

/**
 * Builds a recommendation from existing CG.
 *
 * This method is called when adding more volumes into an existing CG or change vpool scenario.
 *
 * When adding to an existing CG we can accommodate the request with the recommendations from
 * resources that have already been placed in the existing CG.
 *
 * @param capabilities - Virtual Pool capabilities
 * @param vpool - Virtual Pool
 * @param protectionVarrays - List of target copy virtual arrays
 * @param vpoolChangeVolume - change virtual pool volume
 * @return - List of recommendations
 */
protected List<Recommendation> buildCgRecommendations(VirtualPoolCapabilityValuesWrapper capabilities, VirtualPool vpool, List<VirtualArray> protectionVarrays, Volume vpoolChangeVolume) {
    BlockConsistencyGroup cg = dbClient.queryObject(BlockConsistencyGroup.class, capabilities.getBlockConsistencyGroup());
    _log.info(String.format("Attempting to align placement (protection system, storage pools, internal site names) with " + "existing volumes in RecoverPoint consistency group %s.", cg.getLabel()));
    List<Recommendation> recommendations = new ArrayList<Recommendation>();
    // Find the first existing source volume
    List<Volume> sourceVolumes = RPHelper.getCgSourceVolumes(cg.getId(), dbClient);
    if (sourceVolumes.isEmpty()) {
        _log.info(String.format("Unable to fully align placement with existing volumes in RecoverPoint consistency group %s.  " + "The consistency group currently contains no volumes.", cg.getLabel()));
        return recommendations;
    }
    // Verify that all the underlying protection storage pools used by the existing source volume are available to this request
    if (!verifyExistingSourceProtectionPools(sourceVolumes.get(0), vpool, cg.getLabel())) {
        return recommendations;
    }
    Volume sourceVolume = null;
    boolean createRecommendations = false;
    for (Volume currentSourceVolume : sourceVolumes) {
        // enough capacity, use it to produce the recommendation.
        if (cgPoolsHaveAvailableCapacity(currentSourceVolume, capabilities, vpool, protectionVarrays)) {
            createRecommendations = true;
            sourceVolume = currentSourceVolume;
            break;
        }
    }
    if (!createRecommendations) {
        return recommendations;
    }
    RPProtectionRecommendation recommendation = new RPProtectionRecommendation();
    if (sourceVolume.getProtectionController() != null) {
        ProtectionSystem ps = dbClient.queryObject(ProtectionSystem.class, sourceVolume.getProtectionController());
        if (ps.getInactive()) {
            // be protected so we must fail.
            throw APIException.badRequests.cgReferencesInvalidProtectionSystem(cg.getId(), sourceVolume.getProtectionController());
        }
    } else {
        // be protected so we must fail.
        throw APIException.badRequests.cgReferencesInvalidProtectionSystem(cg.getId(), sourceVolume.getProtectionController());
    }
    recommendation.setProtectionDevice(sourceVolume.getProtectionController());
    recommendation.setVpoolChangeVolume(vpoolChangeVolume != null ? vpoolChangeVolume.getId() : null);
    recommendation.setVpoolChangeNewVpool(vpoolChangeVolume != null ? vpool.getId() : null);
    recommendation.setVpoolChangeProtectionAlreadyExists(vpoolChangeVolume != null ? vpoolChangeVolume.checkForRp() : false);
    recommendation.setResourceCount(capabilities.getResourceCount());
    // Check to see if we need an additional journal for Source
    Map<Integer, Long> additionalJournalForSource = RPHelper.additionalJournalRequiredForRPCopy(vpool.getJournalSize(), cg.getId(), capabilities.getSize(), capabilities.getResourceCount(), sourceVolume.getRpCopyName(), dbClient);
    if (!CollectionUtils.isEmpty(additionalJournalForSource)) {
        // ACTIVE SOURCE JOURNAL Recommendation
        List<Volume> sourceJournals = RPHelper.findExistingJournalsForCopy(dbClient, sourceVolume.getConsistencyGroup(), sourceVolume.getRpCopyName());
        Volume sourceJournal = sourceJournals.get(0);
        if (sourceJournal == null) {
            _log.error(String.format("No existing source journal found in CG [%s] for copy [%s], returning false", sourceVolume.getConsistencyGroup(), sourceVolume.getRpCopyName()));
            throw APIException.badRequests.unableToFindSuitableJournalRecommendation();
        }
        VirtualPool sourceJournalVpool = NullColumnValueGetter.isNotNullValue(vpool.getJournalVpool()) ? dbClient.queryObject(VirtualPool.class, URI.create(vpool.getJournalVpool())) : vpool;
        Long sourceJournalSize = getJournalCapabilities(vpool.getJournalSize(), capabilities, 1).getSize();
        RPRecommendation sourceJournalRecommendation = buildRpRecommendationFromExistingVolume(sourceJournal, sourceJournalVpool, capabilities, sourceJournalSize);
        // Parse out the calculated values
        Map.Entry<Integer, Long> entry = additionalJournalForSource.entrySet().iterator().next();
        Integer journalCount = entry.getKey();
        Long journalSize = entry.getValue();
        // Override values in recommendation with calculated journal count and size
        sourceJournalRecommendation.setResourceCount(journalCount);
        sourceJournalRecommendation.setSize(journalSize);
        recommendation.setSourceJournalRecommendation(sourceJournalRecommendation);
        // STANDBY SOURCE JOURNAL Recommendation
        String standbyCopyName = RPHelper.getStandbyProductionCopyName(dbClient, sourceVolume);
        if (standbyCopyName != null) {
            List<Volume> existingStandbyJournals = RPHelper.findExistingJournalsForCopy(dbClient, sourceVolume.getConsistencyGroup(), standbyCopyName);
            Volume standbyJournal = existingStandbyJournals.get(0);
            if (standbyJournal == null) {
                _log.error(String.format("No existing standby journal found in CG [%s] for copy [%s], returning false", sourceVolume.getConsistencyGroup(), standbyCopyName));
                throw APIException.badRequests.unableToFindSuitableJournalRecommendation();
            }
            VirtualPool haVpool = (null != VirtualPool.getHAVPool(vpool, dbClient)) ? VirtualPool.getHAVPool(vpool, dbClient) : vpool;
            VirtualPool standbyJournalVpool = NullColumnValueGetter.isNotNullValue(vpool.getStandbyJournalVpool()) ? dbClient.queryObject(VirtualPool.class, URI.create(vpool.getStandbyJournalVpool())) : haVpool;
            RPRecommendation standbyJournalRecommendation = buildRpRecommendationFromExistingVolume(standbyJournal, standbyJournalVpool, capabilities, sourceJournalSize);
            // Override values in recommendation with calculated journal count and size
            standbyJournalRecommendation.setResourceCount(journalCount);
            standbyJournalRecommendation.setSize(journalSize);
            recommendation.setStandbyJournalRecommendation(standbyJournalRecommendation);
        }
    }
    // SOURCE Recommendation
    RPRecommendation sourceRecommendation = buildRpRecommendationFromExistingVolume(sourceVolume, vpool, capabilities, null);
    recommendation.getSourceRecommendations().add(sourceRecommendation);
    // TARGET Recommendation(s)
    Map<URI, VpoolProtectionVarraySettings> protectionSettings = VirtualPool.getProtectionSettings(vpool, dbClient);
    for (VirtualArray protectionVarray : protectionVarrays) {
        Volume targetVolume = getTargetVolumeForProtectionVirtualArray(sourceVolume, protectionVarray);
        // if the target vpool is not set, it defaults to the source vpool
        VirtualPool targetVpool = vpool;
        if (protectionSettings.get(protectionVarray.getId()) != null && protectionSettings.get(protectionVarray.getId()).getVirtualPool() != null) {
            targetVpool = dbClient.queryObject(VirtualPool.class, protectionSettings.get(protectionVarray.getId()).getVirtualPool());
        }
        RPRecommendation targetRecommendation = buildRpRecommendationFromExistingVolume(targetVolume, targetVpool, capabilities, null);
        if (sourceRecommendation.getTargetRecommendations() == null) {
            sourceRecommendation.setTargetRecommendations(new ArrayList<RPRecommendation>());
        }
        sourceRecommendation.getTargetRecommendations().add(targetRecommendation);
        // Check to see if we need an additional journal for Target
        Map<Integer, Long> additionalJournalForTarget = RPHelper.additionalJournalRequiredForRPCopy(vpool.getJournalSize(), cg.getId(), capabilities.getSize(), capabilities.getResourceCount(), targetVolume.getRpCopyName(), dbClient);
        if (!CollectionUtils.isEmpty(additionalJournalForTarget)) {
            // TARGET JOURNAL Recommendation
            List<Volume> targetJournals = RPHelper.findExistingJournalsForCopy(dbClient, targetVolume.getConsistencyGroup(), targetVolume.getRpCopyName());
            Volume targetJournal = targetJournals.get(0);
            if (targetJournal == null) {
                _log.error(String.format("No existing target journal found in CG [%s] for copy [%s], returning false", targetVolume.getConsistencyGroup(), targetVolume.getRpCopyName()));
                throw APIException.badRequests.unableToFindSuitableJournalRecommendation();
            }
            VirtualPool targetJournalVpool = protectionSettings.get(protectionVarray.getId()).getJournalVpool() != null ? dbClient.queryObject(VirtualPool.class, protectionSettings.get(protectionVarray.getId()).getJournalVpool()) : targetVpool;
            Long targetJournalSize = getJournalCapabilities(protectionSettings.get(protectionVarray.getId()).getJournalSize(), capabilities, 1).getSize();
            RPRecommendation targetJournalRecommendation = buildRpRecommendationFromExistingVolume(targetJournal, targetJournalVpool, capabilities, targetJournalSize);
            // Parse out the calculated values
            Map.Entry<Integer, Long> entry = additionalJournalForSource.entrySet().iterator().next();
            Integer journalCount = entry.getKey();
            Long journalSize = entry.getValue();
            // Override values in recommendation with calculated journal count and size
            targetJournalRecommendation.setResourceCount(journalCount);
            targetJournalRecommendation.setSize(journalSize);
            if (recommendation.getTargetJournalRecommendations() == null) {
                recommendation.setTargetJournalRecommendations(new ArrayList<RPRecommendation>());
            }
            recommendation.getTargetJournalRecommendations().add(targetJournalRecommendation);
        }
    }
    _log.info(String.format("Produced recommendations based on existing source volume [%s](%s) from " + "RecoverPoint consistency group [%s].", sourceVolume.getLabel(), sourceVolume.getId(), cg.getLabel()));
    recommendations.add(recommendation);
    return recommendations;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) ArrayList(java.util.ArrayList) VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Volume(com.emc.storageos.db.client.model.Volume) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 28 with VpoolProtectionVarraySettings

use of com.emc.storageos.db.client.model.VpoolProtectionVarraySettings in project coprhd-controller by CoprHD.

the class BlockVirtualPoolService method prepareVirtualPool.

// This method must not persist anything to the DB
private VirtualPool prepareVirtualPool(BlockVirtualPoolParam param, Map<URI, VpoolRemoteCopyProtectionSettings> remoteSettingsMap, Map<URI, VpoolProtectionVarraySettings> protectionSettingsMap, List<VpoolProtectionVarraySettings> protectionSettingsList) {
    if (remoteSettingsMap == null) {
        remoteSettingsMap = new HashMap<URI, VpoolRemoteCopyProtectionSettings>();
    }
    if (protectionSettingsMap == null) {
        protectionSettingsMap = new HashMap<URI, VpoolProtectionVarraySettings>();
    }
    if (protectionSettingsList == null) {
        protectionSettingsList = new ArrayList<VpoolProtectionVarraySettings>();
    }
    VirtualPool vpool = new VirtualPool();
    vpool.setType(VirtualPool.Type.block.name());
    // set common VirtualPool parameters.
    populateCommonVirtualPoolCreateParams(vpool, param);
    // By default, mirrors and snaps are disabled
    vpool.setMaxNativeContinuousCopies(VirtualPool.MAX_DISABLED);
    vpool.setMaxNativeSnapshots(VirtualPool.MAX_DISABLED);
    if (param.getThinVolumePreAllocationPercentage() != null) {
        vpool.setThinVolumePreAllocationPercentage(param.getThinVolumePreAllocationPercentage());
    }
    if (param.getMultiVolumeConsistency() != null) {
        vpool.setMultivolumeConsistency(param.getMultiVolumeConsistency());
    }
    StringSetMap arrayInfo = new StringSetMap();
    if (null != param.getRaidLevels()) {
        for (String raidLevel : param.getRaidLevels()) {
            arrayInfo.put(VirtualPoolCapabilityValuesWrapper.RAID_LEVEL, raidLevel);
        }
    }
    if (null != param.getSystemType()) {
        arrayInfo.put(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE, param.getSystemType());
    }
    if (arrayInfo.isEmpty()) {
        arrayInfo.put(VirtualPoolCapabilityValuesWrapper.SYSTEM_TYPE, NONE);
    }
    vpool.addArrayInfoDetails(arrayInfo);
    if (param.getProtection() != null) {
        if (param.getProtection().getContinuousCopies() != null) {
            URI ccVpoolURI = param.getProtection().getContinuousCopies().getVpool();
            if (!NullColumnValueGetter.isNullURI(ccVpoolURI)) {
                URI vpoolUri = param.getProtection().getContinuousCopies().getVpool();
                ArgValidator.checkUri(vpoolUri);
                VirtualPool protectionMirrorVpool = _permissionsHelper.getObjectById(vpoolUri, VirtualPool.class);
                ArgValidator.checkEntity(protectionMirrorVpool, vpoolUri, false);
                if (param.getHighAvailability() != null) {
                    validateMirrorVpool(param.getHighAvailability().getType(), protectionMirrorVpool);
                } else {
                    validateMirrorVpool(null, protectionMirrorVpool);
                }
                vpool.setMirrorVirtualPool(vpoolUri.toString());
            }
        }
        if ((param.getProtection().getSnapshots() != null) && (param.getProtection().getSnapshots().getMaxSnapshots() != null)) {
            vpool.setMaxNativeSnapshots(param.getProtection().getSnapshots().getMaxSnapshots());
        }
        if ((param.getProtection().getContinuousCopies() != null) && (param.getProtection().getContinuousCopies().getMaxMirrors() != null)) {
            if (param.getHighAvailability() != null) {
                validateMaxNativeContinuousCopies(param.getProtection().getContinuousCopies().getMaxMirrors(), param.getHighAvailability().getType());
                if (param.getProtection().getContinuousCopies().getVpool() == null && VirtualPool.HighAvailabilityType.vplex_distributed.name().equals(param.getHighAvailability().getType()) && (param.getProtection().getContinuousCopies().getMaxMirrors() > 0)) {
                    throw APIException.badRequests.invalidMirrorVpoolForVplexDistributedVpool();
                }
            }
            vpool.setMaxNativeContinuousCopies(param.getProtection().getContinuousCopies().getMaxMirrors());
        }
        // employ...
        if ((param.getProtection().getRecoverPoint() != null) && (param.getProtection().getRecoverPoint().getCopies() != null)) {
            ProtectionSourcePolicy sourcePolicy = param.getProtection().getRecoverPoint().getSourcePolicy();
            if (sourcePolicy != null) {
                vpool.setJournalSize(sourcePolicy.getJournalSize());
                vpool.setRpRpoValue(sourcePolicy.getRpoValue());
                vpool.setRpRpoType(sourcePolicy.getRpoType());
                vpool.setRpCopyMode(sourcePolicy.getRemoteCopyMode());
                if (!NullColumnValueGetter.isNullURI(sourcePolicy.getJournalVarray())) {
                    vpool.setJournalVarray(sourcePolicy.getJournalVarray().toString());
                    if (!NullColumnValueGetter.isNullURI(sourcePolicy.getJournalVpool())) {
                        vpool.setJournalVpool(sourcePolicy.getJournalVpool().toString());
                    } else {
                        String journalVpoolId = NullColumnValueGetter.getNullStr();
                        if (param.getHighAvailability() == null || Boolean.TRUE.equals(param.getHighAvailability().getMetroPoint())) {
                            // In cases of MetroPoint or when high availability is not specified, default the journal virtual pool
                            // to the parent virtual pool
                            journalVpoolId = vpool.getId().toString();
                        } else if (Boolean.FALSE.equals(param.getHighAvailability().getMetroPoint()) && param.getHighAvailability().getHaVirtualArrayVirtualPool() != null && Boolean.TRUE.equals(param.getHighAvailability().getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite())) {
                            // HA virtual pool.
                            if (param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualPool() != null) {
                                journalVpoolId = param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualPool().toString();
                            }
                        } else {
                            // In cases of MetroPoint or when high availability is not specified, default the journal virtual pool
                            // to the parent virtual pool
                            journalVpoolId = vpool.getId().toString();
                        }
                        vpool.setJournalVpool(journalVpoolId);
                    }
                }
                if (param.getHighAvailability() != null && param.getHighAvailability().getMetroPoint() != null && param.getHighAvailability().getMetroPoint()) {
                    if (!NullColumnValueGetter.isNullURI(sourcePolicy.getStandbyJournalVarray())) {
                        vpool.setStandbyJournalVarray(sourcePolicy.getStandbyJournalVarray().toString());
                        if (!NullColumnValueGetter.isNullURI(sourcePolicy.getStandbyJournalVpool())) {
                            vpool.setStandbyJournalVpool(sourcePolicy.getStandbyJournalVpool().toString());
                        }
                    }
                }
            }
            StringMap settingsMap = new StringMap();
            for (VirtualPoolProtectionVirtualArraySettingsParam settingsParam : param.getProtection().getRecoverPoint().getCopies()) {
                VpoolProtectionVarraySettings setting = new VpoolProtectionVarraySettings();
                setting.setId(URIUtil.createId(VpoolProtectionVarraySettings.class));
                setting.setParent(new NamedURI(vpool.getId(), vpool.getLabel()));
                if (settingsParam.getVpool() != null && !String.valueOf(settingsParam.getVpool()).isEmpty()) {
                    setting.setVirtualPool(settingsParam.getVpool());
                }
                if (settingsParam.getCopyPolicy() != null) {
                    setting.setJournalSize(settingsParam.getCopyPolicy().getJournalSize() != null ? settingsParam.getCopyPolicy().getJournalSize() : null);
                    setting.setJournalVarray(settingsParam.getCopyPolicy().getJournalVarray() != null ? settingsParam.getCopyPolicy().getJournalVarray() : settingsParam.getVarray());
                    setting.setJournalVpool(settingsParam.getCopyPolicy().getJournalVpool() != null ? settingsParam.getCopyPolicy().getJournalVpool() : settingsParam.getVpool());
                }
                if (settingsParam.getVarray() != null) {
                    settingsMap.put(settingsParam.getVarray().toString(), setting.getId().toString());
                    protectionSettingsMap.put(settingsParam.getVarray(), setting);
                }
                protectionSettingsList.add(setting);
            }
            vpool.setProtectionVarraySettings(settingsMap);
        }
        // SRDF remote protection Settings
        if (null != param.getProtection().getRemoteCopies() && null != param.getProtection().getRemoteCopies().getRemoteCopySettings()) {
            StringMap remoteCopysettingsMap = new StringMap();
            for (VirtualPoolRemoteProtectionVirtualArraySettingsParam remoteSettings : param.getProtection().getRemoteCopies().getRemoteCopySettings()) {
                VirtualArray remoteVArray = _dbClient.queryObject(VirtualArray.class, remoteSettings.getVarray());
                if (null == remoteVArray || remoteVArray.getInactive()) {
                    throw APIException.badRequests.inactiveRemoteVArrayDetected(remoteSettings.getVarray());
                }
                VpoolRemoteCopyProtectionSettings remoteCopySettingsParam = new VpoolRemoteCopyProtectionSettings();
                remoteCopySettingsParam.setId(URIUtil.createId(VpoolRemoteCopyProtectionSettings.class));
                remoteCopySettingsParam.setVirtualArray(remoteSettings.getVarray());
                if (remoteCopysettingsMap.containsKey(remoteSettings.getVarray().toString())) {
                    throw APIException.badRequests.duplicateRemoteSettingsDetected(remoteSettings.getVarray());
                }
                remoteCopysettingsMap.put(remoteSettings.getVarray().toString(), remoteCopySettingsParam.getId().toString());
                // The remote virtual pool is an optional field. If it is not set, this value will be null and the source
                // virtual pool will be used to provision the target storage for that remote copy.
                remoteCopySettingsParam.setVirtualPool(remoteSettings.getVpool());
                if (null != remoteSettings.getRemoteCopyMode()) {
                    if (!CopyModes.lookup(remoteSettings.getRemoteCopyMode())) {
                        throw APIException.badRequests.invalidCopyMode(remoteSettings.getRemoteCopyMode());
                    }
                    remoteCopySettingsParam.setCopyMode(remoteSettings.getRemoteCopyMode());
                }
                remoteSettingsMap.put(remoteSettings.getVarray(), remoteCopySettingsParam);
            }
            vpool.setProtectionRemoteCopySettings(remoteCopysettingsMap);
        }
    }
    // Validate and set high availability.
    if (param.getHighAvailability() != null) {
        _log.debug("Vpool specifies high availability {}", param.getHighAvailability());
        // High availability type must be specified and valid.
        vpool.setHighAvailability(param.getHighAvailability().getType());
        if (!VirtualPool.vPoolSpecifiesHighAvailability(vpool)) {
            throw APIException.badRequests.requiredParameterMissingOrEmpty("highAvailability.type");
        }
        // Set the MetroPoint value.
        vpool.setMetroPoint(param.getHighAvailability().getMetroPoint());
        // Default if no parameter is supplied is enabled
        if (param.getHighAvailability().getAutoCrossConnectExport() != null) {
            vpool.setAutoCrossConnectExport(param.getHighAvailability().getAutoCrossConnectExport());
        }
        // user may also specify the high availability VirtualPool.
        if (VirtualPool.HighAvailabilityType.vplex_distributed.name().equals(param.getHighAvailability().getType())) {
            if (param.getHighAvailability().getHaVirtualArrayVirtualPool() == null || param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualArray() == null) {
                throw APIException.badRequests.invalidParameterVirtualPoolHighAvailabilityMismatch(param.getHighAvailability().getType());
            }
            // High availability varray must be specified and valid.
            _log.debug("HA varray VirtualPool map specifies the HA varray {}", param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualArray());
            VirtualArray haVarray = _dbClient.queryObject(VirtualArray.class, param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualArray());
            ArgValidator.checkEntity(haVarray, param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualArray(), false);
            String haVarrayId = param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualArray().toString();
            // Check the HA varray VirtualPool, which is not required.
            String haVarrayVpoolId = null;
            if ((param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualPool() != null) && (!param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualPool().toString().isEmpty())) {
                _log.debug("HA varray VirtualPool map specifies the HA vpool {}", param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualPool());
                VirtualPool haVpool = _dbClient.queryObject(VirtualPool.class, param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualPool());
                ArgValidator.checkEntity(haVpool, param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualPool(), false);
                haVarrayVpoolId = param.getHighAvailability().getHaVirtualArrayVirtualPool().getVirtualPool().toString();
                // Further validate that this VirtualPool is valid for the
                // specified high availability varray.
                StringSet haVpoolVarrays = haVpool.getVirtualArrays();
                if ((haVpoolVarrays != null) && (!haVpoolVarrays.isEmpty()) && !haVpoolVarrays.contains(haVarrayId)) {
                    throw APIException.badRequests.invalidParameterVirtualPoolNotValidForArray(haVarrayVpoolId, haVarrayId);
                }
            } else {
                _log.debug("HA varray VirtualPool map does not specify HA vpool");
                haVarrayVpoolId = NullColumnValueGetter.getNullURI().toString();
            }
            // should be used as the RP source array for volume create.
            if (param.getHighAvailability().getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite() != null && param.getHighAvailability().getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite()) {
                vpool.setHaVarrayConnectedToRp(haVarrayId);
            }
            StringMap haVarrayVirtualPoolMap = new StringMap();
            haVarrayVirtualPoolMap.put(haVarrayId, haVarrayVpoolId);
            vpool.setHaVarrayVpoolMap(haVarrayVirtualPoolMap);
        } else {
            final VirtualArrayVirtualPoolMapEntry haVirtualArrayVirtualPool = param.getHighAvailability().getHaVirtualArrayVirtualPool();
            if ((haVirtualArrayVirtualPool != null) && ((haVirtualArrayVirtualPool.getVirtualArray() != null) || (haVirtualArrayVirtualPool.getVirtualPool() != null))) {
                throw APIException.badRequests.invalidParameterVirtualPoolAndVirtualArrayNotApplicableForHighAvailabilityType(param.getHighAvailability().getType());
            }
        }
    }
    // Set expandable
    if (param.getExpandable() != null) {
        vpool.setExpandable(param.getExpandable());
    }
    if (param.getFastExpansion() != null) {
        vpool.setFastExpansion(param.getFastExpansion());
    }
    if (null != param.getAutoTieringPolicyName() && !param.getAutoTieringPolicyName().isEmpty()) {
        vpool.setAutoTierPolicyName(param.getAutoTieringPolicyName());
    }
    if (param.getCompressionEnabled() != null) {
        vpool.setCompressionEnabled(param.getCompressionEnabled());
    }
    if (null != param.getDriveType()) {
        vpool.setDriveType(param.getDriveType());
    } else {
        vpool.setDriveType(NONE);
    }
    // Set the min/max paths an paths per initiator
    validateAndSetPathParams(vpool, param.getMaxPaths(), param.getMinPaths(), param.getPathsPerInitiator());
    if (null != param.getUniquePolicyNames()) {
        vpool.setUniquePolicyNames(param.getUniquePolicyNames());
    }
    // set limit for host bandwidth
    if (param.getHostIOLimitBandwidth() != null) {
        vpool.setHostIOLimitBandwidth(param.getHostIOLimitBandwidth());
    }
    // set limit for host i/o
    if (param.getHostIOLimitIOPs() != null) {
        vpool.setHostIOLimitIOPs(param.getHostIOLimitIOPs());
    }
    // set placement policy
    if (param.getPlacementPolicy() != null) {
        vpool.setPlacementPolicy(param.getPlacementPolicy());
    }
    // set dedup capable or not
    if (null != param.getDedupCapable()) {
        vpool.setDedupCapable(param.getDedupCapable());
    }
    return vpool;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) StringMap(com.emc.storageos.db.client.model.StringMap) VirtualPoolRemoteProtectionVirtualArraySettingsParam(com.emc.storageos.model.vpool.VirtualPoolRemoteProtectionVirtualArraySettingsParam) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) NamedURI(com.emc.storageos.db.client.model.NamedURI) VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) VirtualPoolMapper.toBlockVirtualPool(com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) VirtualPoolProtectionVirtualArraySettingsParam(com.emc.storageos.model.vpool.VirtualPoolProtectionVirtualArraySettingsParam) StringSet(com.emc.storageos.db.client.model.StringSet) ProtectionSourcePolicy(com.emc.storageos.model.vpool.ProtectionSourcePolicy) VirtualArrayVirtualPoolMapEntry(com.emc.storageos.model.vpool.VirtualPoolHighAvailabilityParam.VirtualArrayVirtualPoolMapEntry)

Example 29 with VpoolProtectionVarraySettings

use of com.emc.storageos.db.client.model.VpoolProtectionVarraySettings in project coprhd-controller by CoprHD.

the class BlockVirtualPoolService method updateProtectionParamsForVirtualPool.

/**
 * Performs the protection updates on <code>VirtualPool</code>.
 *
 * @param virtualPool Reference to the virtual pool to update.
 * @param param The updates that need to be applied to the virtual pool.
 */
private void updateProtectionParamsForVirtualPool(VirtualPool virtualPool, BlockVirtualPoolProtectionUpdateParam param, VirtualPoolHighAvailabilityParam haParam) {
    // If the update specifies protection, we need to process the update.
    if (param != null) {
        // If the update specifies protection mirroring, process the mirroring update.
        if (param.getContinuousCopies() != null) {
            if ((param.getContinuousCopies().getVpool() == null || String.valueOf(param.getContinuousCopies().getVpool()).isEmpty()) && (param.getContinuousCopies().getMaxMirrors() == null || param.getContinuousCopies().getMaxMirrors() == VirtualPoolProtectionMirrorParam.MAX_DISABLED || String.valueOf(param.getContinuousCopies().getMaxMirrors()).isEmpty())) {
                // so remove protection mirror vpool and set max native continuous copies to disabled value.
                if (virtualPool.getMirrorVirtualPool() != null) {
                    virtualPool.setMirrorVirtualPool(String.valueOf(NullColumnValueGetter.getNullURI()));
                }
                virtualPool.setMaxNativeContinuousCopies(VirtualPool.MAX_DISABLED);
            } else if ((param.getContinuousCopies().getVpool() == null || String.valueOf(param.getContinuousCopies().getVpool()).isEmpty())) {
                // Setting Mirror Virtual Pool is optional so user can choose to remove mirror virtual pool
                if (virtualPool.getMirrorVirtualPool() != null) {
                    virtualPool.setMirrorVirtualPool(String.valueOf(NullColumnValueGetter.getNullURI()));
                }
                if (param.getContinuousCopies().getMaxMirrors() != null) {
                    // Updating max mirrors
                    virtualPool.setMaxNativeContinuousCopies(param.getContinuousCopies().getMaxMirrors());
                }
            } else if ((param.getContinuousCopies().getVpool() != null && !String.valueOf(param.getContinuousCopies().getVpool()).isEmpty()) && (param.getContinuousCopies().getMaxMirrors() == null)) {
                // Update protection mirror vpool
                updateProtectionMirrorVPool(param.getContinuousCopies().getVpool(), virtualPool);
            } else {
                // the protection vpool and max mirrors
                if (param.getContinuousCopies().getVpool() != null && !String.valueOf(param.getContinuousCopies().getVpool()).isEmpty()) {
                    updateProtectionMirrorVPool(param.getContinuousCopies().getVpool(), virtualPool);
                }
                if (param.getContinuousCopies().getMaxMirrors() != null) {
                    virtualPool.setMaxNativeContinuousCopies(param.getContinuousCopies().getMaxMirrors());
                }
            }
        }
        // Handle the protection snapshot updates
        if (param.getSnapshots() != null) {
            // but good to have just in case...
            if (param.getSnapshots().getMaxSnapshots() != null) {
                // Keep in mind that if an empty or 0 value is specified snapshots
                // will be removed from the virtual pool.
                virtualPool.setMaxNativeSnapshots(param.getSnapshots().getMaxSnapshots());
            } else {
                // Remove snapshots by setting the disabled value
                virtualPool.setMaxNativeSnapshots(VirtualPool.MAX_DISABLED);
            }
        }
        // Handle SRDF update
        updateRemoteCopyVPool(virtualPool, param);
        // Handle the RP protection updates
        if (param.getRecoverPoint() != null) {
            if (param.getRecoverPoint().getAdd() == null && param.getRecoverPoint().getRemove() == null && param.getRecoverPoint().getSourcePolicy() == null) {
                // Empty RP protection specified. This indicates removal of
                // RP protection so remove it.
                deleteVPoolProtectionVArraySettings(virtualPool);
            } else {
                // If the source policy is omitted, do nothing.
                ProtectionSourcePolicy sourcePolicy = param.getRecoverPoint().getSourcePolicy();
                if (sourcePolicy != null) {
                    String nullValue = NullColumnValueGetter.getNullStr();
                    virtualPool.setJournalSize(StringUtils.defaultString(sourcePolicy.getJournalSize(), nullValue));
                    virtualPool.setJournalVarray(!NullColumnValueGetter.isNullURI(sourcePolicy.getJournalVarray()) ? sourcePolicy.getJournalVarray().toString() : nullValue);
                    if (NullColumnValueGetter.isNullValue(virtualPool.getJournalVarray())) {
                        // If the journal varray is null, the journal vpool has to be null too.
                        virtualPool.setJournalVpool(nullValue);
                    } else {
                        // Set the journal virtual pool. If none is specified, we must determine the default, which
                        // will be the parent vpool or the ha vpool.
                        String defaultVpoolId = nullValue;
                        if (haParam == null || Boolean.TRUE.equals(haParam.getMetroPoint())) {
                            // Default the virtual pool to the parent virtual pool in cases where no high availability
                            // is specified or when HA is specified but not MetroPoint.
                            defaultVpoolId = virtualPool.getId().toString();
                        } else if (Boolean.FALSE.equals(haParam.getMetroPoint()) && haParam.getHaVirtualArrayVirtualPool() != null && Boolean.TRUE.equals(haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite())) {
                            // virtual pool.
                            if (haParam.getHaVirtualArrayVirtualPool().getVirtualPool() != null) {
                                defaultVpoolId = haParam.getHaVirtualArrayVirtualPool().getVirtualPool().toString();
                            }
                        }
                        virtualPool.setJournalVpool(!NullColumnValueGetter.isNullURI(sourcePolicy.getJournalVpool()) ? sourcePolicy.getJournalVpool().toString() : defaultVpoolId);
                    }
                    if (NullColumnValueGetter.isNotNullValue(virtualPool.getHighAvailability())) {
                        virtualPool.setStandbyJournalVarray(!NullColumnValueGetter.isNullURI(sourcePolicy.getStandbyJournalVarray()) ? sourcePolicy.getStandbyJournalVarray().toString() : nullValue);
                        if (NullColumnValueGetter.isNullValue(virtualPool.getStandbyJournalVarray())) {
                            // If the ha journal varray is null, the ha journal vpool has to be null too.
                            virtualPool.setStandbyJournalVpool(nullValue);
                        } else {
                            String defaultHaVpool = nullValue;
                            // Obtain the default HA virtual pool
                            Map<String, String> haVarrayVpoolMap = virtualPool.getHaVarrayVpoolMap();
                            if (haVarrayVpoolMap != null && !haVarrayVpoolMap.isEmpty()) {
                                if (NullColumnValueGetter.isNotNullValue(haVarrayVpoolMap.get(virtualPool.getStandbyJournalVarray()))) {
                                    defaultHaVpool = haVarrayVpoolMap.get(virtualPool.getStandbyJournalVarray());
                                }
                            }
                            // By default, if no standby vpool is set, set the HA journal vpool to the HA vpool.
                            virtualPool.setStandbyJournalVpool(!NullColumnValueGetter.isNullURI(sourcePolicy.getStandbyJournalVpool()) ? sourcePolicy.getStandbyJournalVpool().toString() : defaultHaVpool);
                        }
                    }
                    virtualPool.setRpCopyMode(StringUtils.defaultString(sourcePolicy.getRemoteCopyMode(), nullValue));
                    // If the RPO value is null, set the value to 0 to unset this field.
                    long rpoValue = (sourcePolicy.getRpoValue() == null) ? 0L : sourcePolicy.getRpoValue();
                    virtualPool.setRpRpoValue(rpoValue);
                    virtualPool.setRpRpoType(StringUtils.defaultString(sourcePolicy.getRpoType(), nullValue));
                }
                if (param.getRecoverPoint().getRemove() != null && !param.getRecoverPoint().getRemove().isEmpty()) {
                    // Only remove protection copies if there are copies to remove
                    if (virtualPool.getProtectionVarraySettings() != null && !virtualPool.getProtectionVarraySettings().isEmpty()) {
                        StringMap settingsMap = virtualPool.getProtectionVarraySettings();
                        for (VirtualPoolProtectionVirtualArraySettingsParam settingsParam : param.getRecoverPoint().getRemove()) {
                            if (settingsParam.getVarray() != null && !settingsParam.getVarray().toString().isEmpty()) {
                                String vpoolProtectionVarraySettingsUri = virtualPool.getProtectionVarraySettings().get(settingsParam.getVarray().toString());
                                if (vpoolProtectionVarraySettingsUri == null) {
                                    throw APIException.badRequests.protectionNoCopyCorrespondingToVirtualArray(settingsParam.getVarray());
                                }
                                deleteVPoolProtectionVArraySettings(virtualPool.getProtectionVarraySettings().get(settingsParam.getVarray().toString()));
                                settingsMap.remove(settingsParam.getVarray().toString());
                            }
                        }
                        virtualPool.setProtectionVarraySettings(settingsMap);
                    }
                }
                if (param.getRecoverPoint().getAdd() != null && !param.getRecoverPoint().getAdd().isEmpty()) {
                    Set<VpoolProtectionVarraySettings> protectionSettingsToAdd = null;
                    StringMap settingsMap = virtualPool.getProtectionVarraySettings();
                    if (settingsMap == null) {
                        settingsMap = new StringMap();
                    }
                    for (VirtualPoolProtectionVirtualArraySettingsParam settingsParam : param.getRecoverPoint().getAdd()) {
                        VirtualArray virtualArray = _permissionsHelper.getObjectById(settingsParam.getVarray(), VirtualArray.class);
                        ArgValidator.checkEntity(virtualArray, settingsParam.getVarray(), false);
                        VpoolProtectionVarraySettings setting = new VpoolProtectionVarraySettings();
                        setting.setId(URIUtil.createId(VpoolProtectionVarraySettings.class));
                        setting.setParent(new NamedURI(virtualPool.getId(), virtualPool.getLabel()));
                        if (settingsParam.getVpool() != null && !String.valueOf(settingsParam.getVpool()).isEmpty()) {
                            setting.setVirtualPool(settingsParam.getVpool());
                        }
                        setting.setJournalSize(settingsParam.getCopyPolicy() != null ? settingsParam.getCopyPolicy().getJournalSize() : null);
                        setting.setJournalVarray(settingsParam.getCopyPolicy() != null ? settingsParam.getCopyPolicy().getJournalVarray() : settingsParam.getVarray());
                        setting.setJournalVpool(settingsParam.getCopyPolicy() != null ? settingsParam.getCopyPolicy().getJournalVpool() : settingsParam.getVpool());
                        settingsMap.put(settingsParam.getVarray().toString(), setting.getId().toString());
                        if (protectionSettingsToAdd == null) {
                            protectionSettingsToAdd = new HashSet<VpoolProtectionVarraySettings>();
                        }
                        protectionSettingsToAdd.add(setting);
                    }
                    // Set the underlying protection setting objects
                    if (protectionSettingsToAdd != null) {
                        for (VpoolProtectionVarraySettings setting : protectionSettingsToAdd) {
                            _dbClient.createObject(setting);
                        }
                    }
                    virtualPool.setProtectionVarraySettings(settingsMap);
                }
                StringMap settingsMap = virtualPool.getProtectionVarraySettings();
                if (settingsMap != null && settingsMap.size() == 0) {
                    // If there are no copies after the add/remove, remove the source policy
                    virtualPool.setJournalSize(NullColumnValueGetter.getNullStr());
                    virtualPool.setJournalVarray(NullColumnValueGetter.getNullStr());
                    virtualPool.setJournalVpool(NullColumnValueGetter.getNullStr());
                }
            }
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) NamedURI(com.emc.storageos.db.client.model.NamedURI) VirtualPoolProtectionVirtualArraySettingsParam(com.emc.storageos.model.vpool.VirtualPoolProtectionVirtualArraySettingsParam) VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) ProtectionSourcePolicy(com.emc.storageos.model.vpool.ProtectionSourcePolicy)

Example 30 with VpoolProtectionVarraySettings

use of com.emc.storageos.db.client.model.VpoolProtectionVarraySettings in project coprhd-controller by CoprHD.

the class VirtualPoolMapper method toBlockVirtualPool.

public static BlockVirtualPoolRestRep toBlockVirtualPool(DbClient dbclient, VirtualPool from, Map<URI, VpoolProtectionVarraySettings> protectionSettings, Map<URI, VpoolRemoteCopyProtectionSettings> remoteProtectionSettings) {
    if (from == null) {
        return null;
    }
    BlockVirtualPoolRestRep to = new BlockVirtualPoolRestRep();
    to.setDriveType(from.getDriveType());
    to.setAutoTieringPolicyName(from.getAutoTierPolicyName());
    to.setCompressionEnabled(from.getCompressionEnabled());
    to.setThinVolumePreAllocationPercentage(from.getThinVolumePreAllocationPercentage());
    to.setExpandable(from.getExpandable());
    to.setFastExpansion(from.getFastExpansion());
    to.setMultiVolumeConsistent(from.getMultivolumeConsistency());
    to.setUniquePolicyNames(from.getUniquePolicyNames());
    to.setMaxPaths(from.getNumPaths());
    to.setMinPaths(from.getMinPaths());
    to.setPathsPerInitiator(from.getPathsPerInitiator());
    to.setHostIOLimitBandwidth(from.getHostIOLimitBandwidth());
    to.setHostIOLimitIOPs(from.getHostIOLimitIOPs());
    to.setPlacementPolicy(from.getPlacementPolicy());
    if (from.getArrayInfo() != null) {
        StringSetMap arrayInfo = from.getArrayInfo();
        // Raid Levels
        StringSet raidLevels = arrayInfo.get(VirtualPoolCapabilityValuesWrapper.RAID_LEVEL);
        if (raidLevels != null) {
            to.setRaidLevels(raidLevels);
        }
    }
    BlockVirtualPoolProtectionParam protection = new BlockVirtualPoolProtectionParam();
    // mirror logic
    protection.setContinuousCopies(new VirtualPoolProtectionMirrorParam());
    if (NullColumnValueGetter.isNotNullValue(from.getMirrorVirtualPool())) {
        protection.getContinuousCopies().setVpool(URI.create(from.getMirrorVirtualPool()));
    }
    protection.getContinuousCopies().setMaxMirrors(from.getMaxNativeContinuousCopies());
    // SRDF logic
    if (null != remoteProtectionSettings && !remoteProtectionSettings.isEmpty()) {
        protection.setRemoteCopies(new VirtualPoolRemoteMirrorProtectionParam());
        protection.getRemoteCopies().setRemoteCopySettings(new ArrayList<VirtualPoolRemoteProtectionVirtualArraySettingsParam>());
        for (Map.Entry<URI, VpoolRemoteCopyProtectionSettings> remoteSetting : remoteProtectionSettings.entrySet()) {
            VirtualPoolRemoteProtectionVirtualArraySettingsParam remoteCopy = new VirtualPoolRemoteProtectionVirtualArraySettingsParam();
            remoteCopy.setRemoteCopyMode(remoteSetting.getValue().getCopyMode());
            remoteCopy.setVarray(remoteSetting.getValue().getVirtualArray());
            remoteCopy.setVpool(remoteSetting.getValue().getVirtualPool());
            protection.getRemoteCopies().getRemoteCopySettings().add(remoteCopy);
        }
    }
    // RP logic
    if (protectionSettings != null && !protectionSettings.isEmpty()) {
        protection.setRecoverPoint(new VirtualPoolProtectionRPParam());
        if (isNotNullValue(from.getJournalSize())) {
            if (protection.getRecoverPoint().getSourcePolicy() == null) {
                protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
            }
            protection.getRecoverPoint().getSourcePolicy().setJournalSize(from.getJournalSize());
        }
        if (isNotNullValue(from.getJournalVarray())) {
            if (protection.getRecoverPoint().getSourcePolicy() == null) {
                protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
            }
            protection.getRecoverPoint().getSourcePolicy().setJournalVarray(URI.create(from.getJournalVarray()));
        }
        if (isNotNullValue(from.getJournalVpool())) {
            if (protection.getRecoverPoint().getSourcePolicy() == null) {
                protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
            }
            protection.getRecoverPoint().getSourcePolicy().setJournalVpool(URI.create(from.getJournalVpool()));
        }
        if (isNotNullValue(from.getStandbyJournalVarray())) {
            if (protection.getRecoverPoint().getSourcePolicy() == null) {
                protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
            }
            protection.getRecoverPoint().getSourcePolicy().setStandbyJournalVarray(URI.create(from.getStandbyJournalVarray()));
        }
        if (isNotNullValue(from.getStandbyJournalVpool())) {
            if (protection.getRecoverPoint().getSourcePolicy() == null) {
                protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
            }
            protection.getRecoverPoint().getSourcePolicy().setStandbyJournalVpool(URI.create(from.getStandbyJournalVpool()));
        }
        if (isNotNullValue(from.getRpCopyMode())) {
            if (protection.getRecoverPoint().getSourcePolicy() == null) {
                protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
            }
            protection.getRecoverPoint().getSourcePolicy().setRemoteCopyMode(from.getRpCopyMode());
        }
        if (isNotNullValue(from.getRpRpoType())) {
            if (protection.getRecoverPoint().getSourcePolicy() == null) {
                protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
            }
            protection.getRecoverPoint().getSourcePolicy().setRpoType(from.getRpRpoType());
        }
        if (from.checkRpRpoValueSet()) {
            if (protection.getRecoverPoint().getSourcePolicy() == null) {
                protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
            }
            protection.getRecoverPoint().getSourcePolicy().setRpoValue(from.getRpRpoValue());
        }
        protection.getRecoverPoint().setCopies(new HashSet<VirtualPoolProtectionVirtualArraySettingsParam>());
        for (Map.Entry<URI, VpoolProtectionVarraySettings> setting : protectionSettings.entrySet()) {
            VirtualPoolProtectionVirtualArraySettingsParam copy = new VirtualPoolProtectionVirtualArraySettingsParam();
            VpoolProtectionVarraySettings value = setting.getValue();
            if (value != null) {
                copy.setVpool(setting.getValue().getVirtualPool());
                copy.setVarray(setting.getKey());
                copy.setCopyPolicy(new ProtectionCopyPolicy());
                copy.getCopyPolicy().setJournalSize(setting.getValue().getJournalSize());
                copy.getCopyPolicy().setJournalVarray(setting.getValue().getJournalVarray());
                copy.getCopyPolicy().setJournalVpool(setting.getValue().getJournalVpool());
                protection.getRecoverPoint().getCopies().add(copy);
            }
        }
    }
    // Show the feature even if it's disabled
    protection.setSnapshots(new VirtualPoolProtectionSnapshotsParam());
    protection.getSnapshots().setMaxSnapshots(from.getMaxNativeSnapshots());
    if (protection.hasAnyProtection()) {
        to.setProtection(protection);
    }
    // VPLEX logic
    if (isNotNullValue(from.getHighAvailability())) {
        VirtualPoolHighAvailabilityParam haParam = new VirtualPoolHighAvailabilityParam(from.getHighAvailability());
        // Set the MetroPoint field.
        haParam.setMetroPoint(from.getMetroPoint());
        haParam.setAutoCrossConnectExport(from.getAutoCrossConnectExport());
        StringMap haVarrayVpoolMap = from.getHaVarrayVpoolMap();
        if ((haVarrayVpoolMap != null) && (haVarrayVpoolMap.size() != 0)) {
            VirtualPoolHighAvailabilityParam.VirtualArrayVirtualPoolMapEntry varrayVpoolMapEntry = null;
            for (Map.Entry<String, String> entry : haVarrayVpoolMap.entrySet()) {
                URI vpoolUri = null;
                // Logic to ensure "null" doesn't get displayed as the HA vpool.
                if (isNotNullValue(entry.getValue())) {
                    vpoolUri = URI.create(entry.getValue());
                }
                if (entry.getKey() != null && !entry.getKey().isEmpty()) {
                    varrayVpoolMapEntry = new VirtualPoolHighAvailabilityParam.VirtualArrayVirtualPoolMapEntry(URI.create(entry.getKey()), vpoolUri);
                }
                if (isNotNullValue(from.getHaVarrayConnectedToRp()) && !from.getHaVarrayConnectedToRp().isEmpty()) {
                    varrayVpoolMapEntry.setActiveProtectionAtHASite(true);
                } else {
                    varrayVpoolMapEntry.setActiveProtectionAtHASite(false);
                }
                haParam.setHaVirtualArrayVirtualPool(varrayVpoolMapEntry);
                if (vpoolUri != null) {
                    VirtualPool haVpool = dbclient.queryObject(VirtualPool.class, vpoolUri);
                    if (haVpool != null) {
                        if (haVpool.getMirrorVirtualPool() != null) {
                            protection.getContinuousCopies().setHaVpool(URI.create(haVpool.getMirrorVirtualPool()));
                        }
                        protection.getContinuousCopies().setHaMaxMirrors(haVpool.getMaxNativeContinuousCopies());
                    }
                }
            }
        }
        to.setHighAvailability(haParam);
    }
    // dedup capability
    if (from.getDedupCapable() != null) {
        to.setDedupCapable(from.getDedupCapable());
    }
    return mapVirtualPoolFields(from, to, protectionSettings);
}
Also used : VirtualPoolRemoteProtectionVirtualArraySettingsParam(com.emc.storageos.model.vpool.VirtualPoolRemoteProtectionVirtualArraySettingsParam) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) StringMap(com.emc.storageos.db.client.model.StringMap) BlockVirtualPoolProtectionParam(com.emc.storageos.model.vpool.BlockVirtualPoolProtectionParam) VirtualPoolProtectionRPParam(com.emc.storageos.model.vpool.VirtualPoolProtectionRPParam) ProtectionCopyPolicy(com.emc.storageos.model.vpool.ProtectionCopyPolicy) URI(java.net.URI) StringSet(com.emc.storageos.db.client.model.StringSet) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) ProtectionSourcePolicy(com.emc.storageos.model.vpool.ProtectionSourcePolicy) VirtualPoolProtectionMirrorParam(com.emc.storageos.model.vpool.VirtualPoolProtectionMirrorParam) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) VpoolProtectionVarraySettings(com.emc.storageos.db.client.model.VpoolProtectionVarraySettings) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) VirtualPoolRemoteMirrorProtectionParam(com.emc.storageos.model.vpool.VirtualPoolRemoteMirrorProtectionParam) VirtualPoolProtectionSnapshotsParam(com.emc.storageos.model.vpool.VirtualPoolProtectionSnapshotsParam) VirtualPoolProtectionVirtualArraySettingsParam(com.emc.storageos.model.vpool.VirtualPoolProtectionVirtualArraySettingsParam) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) VirtualPoolHighAvailabilityParam(com.emc.storageos.model.vpool.VirtualPoolHighAvailabilityParam)

Aggregations

VpoolProtectionVarraySettings (com.emc.storageos.db.client.model.VpoolProtectionVarraySettings)31 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)26 StringMap (com.emc.storageos.db.client.model.StringMap)22 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)18 NamedURI (com.emc.storageos.db.client.model.NamedURI)17 URI (java.net.URI)16 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)15 ArrayList (java.util.ArrayList)15 StoragePool (com.emc.storageos.db.client.model.StoragePool)14 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)13 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)13 StringSet (com.emc.storageos.db.client.model.StringSet)13 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)12 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)12 RPRecommendation (com.emc.storageos.volumecontroller.RPRecommendation)12 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)12 Network (com.emc.storageos.db.client.model.Network)11 Project (com.emc.storageos.db.client.model.Project)11 RPSiteArray (com.emc.storageos.db.client.model.RPSiteArray)11 StoragePort (com.emc.storageos.db.client.model.StoragePort)11