Search in sources :

Example 6 with ProtectionSourcePolicy

use of com.emc.storageos.model.vpool.ProtectionSourcePolicy in project coprhd-controller by CoprHD.

the class BlockVirtualPoolBuilder method setRecoverPointRpo.

public BlockVirtualPoolBuilder setRecoverPointRpo(Long value, String type) {
    if (value != null) {
        if (getProtectionSourcePolicy() == null) {
            getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
        }
        getProtectionSourcePolicy().setRpoValue(value);
        getProtectionSourcePolicy().setRpoType(type);
    }
    return this;
}
Also used : ProtectionSourcePolicy(com.emc.storageos.model.vpool.ProtectionSourcePolicy)

Example 7 with ProtectionSourcePolicy

use of com.emc.storageos.model.vpool.ProtectionSourcePolicy in project coprhd-controller by CoprHD.

the class BlockVirtualPoolUpdateBuilder method setStandByJournalVArrayVpool.

public BlockVirtualPoolUpdateBuilder setStandByJournalVArrayVpool(URI standbyJournalVarray, URI standbyJournalVpool) {
    if (getProtectionSourcePolicy() == null) {
        getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
    }
    getProtectionSourcePolicy().setStandbyJournalVarray(standbyJournalVarray);
    getProtectionSourcePolicy().setStandbyJournalVpool(standbyJournalVpool);
    return this;
}
Also used : ProtectionSourcePolicy(com.emc.storageos.model.vpool.ProtectionSourcePolicy)

Example 8 with ProtectionSourcePolicy

use of com.emc.storageos.model.vpool.ProtectionSourcePolicy in project coprhd-controller by CoprHD.

the class BlockVirtualPoolUpdateBuilder method setJournalVarrayAndVpool.

public BlockVirtualPoolUpdateBuilder setJournalVarrayAndVpool(URI journalVarray, URI journalVpool) {
    if (getProtectionSourcePolicy() == null) {
        getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
    }
    getProtectionSourcePolicy().setJournalVarray(journalVarray);
    getProtectionSourcePolicy().setJournalVpool(journalVpool);
    return this;
}
Also used : ProtectionSourcePolicy(com.emc.storageos.model.vpool.ProtectionSourcePolicy)

Example 9 with ProtectionSourcePolicy

use of com.emc.storageos.model.vpool.ProtectionSourcePolicy 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 10 with ProtectionSourcePolicy

use of com.emc.storageos.model.vpool.ProtectionSourcePolicy 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)

Aggregations

ProtectionSourcePolicy (com.emc.storageos.model.vpool.ProtectionSourcePolicy)11 VirtualPoolProtectionVirtualArraySettingsParam (com.emc.storageos.model.vpool.VirtualPoolProtectionVirtualArraySettingsParam)4 StringMap (com.emc.storageos.db.client.model.StringMap)3 VpoolProtectionVarraySettings (com.emc.storageos.db.client.model.VpoolProtectionVarraySettings)3 VirtualPoolProtectionRPParam (com.emc.storageos.model.vpool.VirtualPoolProtectionRPParam)3 VirtualPoolRemoteMirrorProtectionParam (com.emc.storageos.model.vpool.VirtualPoolRemoteMirrorProtectionParam)3 VirtualPoolRemoteProtectionVirtualArraySettingsParam (com.emc.storageos.model.vpool.VirtualPoolRemoteProtectionVirtualArraySettingsParam)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)2 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)2 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 VpoolRemoteCopyProtectionSettings (com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings)2 BlockVirtualPoolProtectionParam (com.emc.storageos.model.vpool.BlockVirtualPoolProtectionParam)2 VirtualPoolHighAvailabilityParam (com.emc.storageos.model.vpool.VirtualPoolHighAvailabilityParam)2 URI (java.net.URI)2 VirtualPoolMapper.toBlockVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toBlockVirtualPool)1 BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)1 ProtectionCopyPolicy (com.emc.storageos.model.vpool.ProtectionCopyPolicy)1 VirtualArrayVirtualPoolMapEntry (com.emc.storageos.model.vpool.VirtualPoolHighAvailabilityParam.VirtualArrayVirtualPoolMapEntry)1