Search in sources :

Example 26 with VpoolRemoteCopyProtectionSettings

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

the class RemoteMirrorProtectionValidator method validateVirtualPoolUpdateAttributeValue.

@Override
protected void validateVirtualPoolUpdateAttributeValue(final VirtualPool vpool, final BlockVirtualPoolUpdateParam updateParam, final DbClient dbClient) {
    if (!VirtualPool.vPoolSpecifiesSRDF(vpool)) {
        // this code is not added under updateAttributeOn, as SRDF CopyModes
        // can be updated without altering Add or remove
        _logger.info("Not SRDF Specified");
        return;
    }
    validateVPlexProtection(updateParam, dbClient);
    checkSystemIsVMAX(vpool, updateParam);
    Map<URI, VpoolRemoteCopyProtectionSettings> remoteSettingsMap = VirtualPool.getRemoteProtectionSettings(vpool, dbClient);
    if (remoteSettingsMap != null && !remoteSettingsMap.isEmpty()) {
        for (VpoolRemoteCopyProtectionSettings remoteSettings : remoteSettingsMap.values()) {
            validateSRDFTargetAsVMAX(remoteSettings.getVirtualPool(), dbClient);
        }
    }
    Map<String, List<String>> mapping = VirtualPool.groupRemoteCopyModesByVPool(vpool, dbClient);
    List<String> availableCopyModes = new ArrayList<String>();
    _logger.info("Multi Volume Consistency {} :", vpool.getMultivolumeConsistency());
    if (mapping != null) {
        for (Collection<String> copyModes : mapping.values()) {
            availableCopyModes.addAll(copyModes);
        }
    }
    int frequency = Collections.frequency(availableCopyModes, Mode.ASYNCHRONOUS.toString());
    if (frequency > 1) {
        throw APIException.badRequests.unsupportedConfigurationWithMultipleAsyncModes();
    }
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) URI(java.net.URI)

Example 27 with VpoolRemoteCopyProtectionSettings

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

the class BlockRemoteReplicationIngestOrchestrator method validateTargetVolumeVpoolWithSourceVolume.

/**
 * Validate the Target Volume VirtualArray with the Source Volume VPool
 * VirtualArray.
 *
 * @param type
 * @param unManagedVolume
 * @param virtualArray
 */
private void validateTargetVolumeVpoolWithSourceVolume(UnManagedVolume unManagedVolume, VirtualArray virtualArray) {
    String sourceUnManagedVolumeId = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_MIRROR_SOURCE_VOLUME.toString(), unManagedVolume.getVolumeInformation());
    String sourceVolumeId = sourceUnManagedVolumeId.replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
    List<URI> sourceUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeNativeGuidConstraint(sourceVolumeId));
    if (sourceUris.isEmpty()) {
        _logger.info("Source {} Not found for target {}", sourceVolumeId, unManagedVolume.getNativeGuid());
    } else {
        // if source volume is ingested, then
        Volume sourceVolume = _dbClient.queryObject(Volume.class, sourceUris.get(0));
        // check whether the source Volume's VPool is actually having this
        // target Volume's varray
        // specified as remote
        VirtualPool sourceVPool = _dbClient.queryObject(VirtualPool.class, sourceVolume.getVirtualPool());
        Map<URI, VpoolRemoteCopyProtectionSettings> settings = sourceVPool.getRemoteProtectionSettings(sourceVPool, _dbClient);
        if (null == settings || settings.isEmpty() || !settings.containsKey(virtualArray.getId())) {
            _logger.info("Target Volume's VArray {} is not matching already ingested source volume virtual pool's remote VArray ", virtualArray.getId());
            throw IngestionException.exceptions.unmanagedSRDFTargetVolumeVArrayMismatch(unManagedVolume.getLabel(), sourceVolume.getVirtualArray().toString());
        }
    }
}
Also used : VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI)

Example 28 with VpoolRemoteCopyProtectionSettings

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

the class RemoteReplicationIngestor method runRemoteReplicationStepsOnSource.

/**
 * If unmanaged volume is of type Source, then check if all its target volumes are already
 * ingested. if yes, establish links.
 *
 * @param unManagedVolume
 * @param srcVolume
 * @param unManagedVolumes
 * @param type
 * @return
 */
private static boolean runRemoteReplicationStepsOnSource(UnManagedVolume unManagedVolume, Volume srcVolume, List<UnManagedVolume> unManagedVolumes, String type, DbClient dbClient) {
    boolean removeUnManagedVolume = false;
    StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
    // find whether all targets are ingested
    StringSet targetUnManagedVolumeGuids = unManagedVolumeInformation.get(SupportedVolumeInformation.REMOTE_MIRRORS.toString());
    _logger.info("Type : {} --> Source Volume {}", type, srcVolume.getNativeGuid());
    if (null != targetUnManagedVolumeGuids && !targetUnManagedVolumeGuids.isEmpty()) {
        StringSet targetVolumeNativeGuids = VolumeIngestionUtil.getListofVolumeIds(targetUnManagedVolumeGuids);
        // check whether target exists
        List<URI> targetUris = VolumeIngestionUtil.getVolumeUris(targetVolumeNativeGuids, dbClient);
        _logger.info("Expected targets : {} -->Found Target URIs : {}", targetUnManagedVolumeGuids.size(), targetUris.size());
        _logger.debug("Expected Targets {} : Found {}", Joiner.on("\t").join(targetVolumeNativeGuids), Joiner.on("\t").join(targetUris));
        if (targetUris.size() != targetUnManagedVolumeGuids.size()) {
            _logger.info("Found Target Volumes still not ingested.Skipping Remote Replication Link establishment.");
        } else {
            List<Volume> targetVolumes = dbClient.queryObject(Volume.class, targetUris);
            for (Volume targetVolume : targetVolumes) {
                // Get the Source Volume's remote VArray and compare the same with target's Virtual Array.
                VirtualPool sourceVPool = dbClient.queryObject(VirtualPool.class, srcVolume.getVirtualPool());
                Map<URI, VpoolRemoteCopyProtectionSettings> settings = sourceVPool.getRemoteProtectionSettings(sourceVPool, dbClient);
                if (null == settings || settings.size() == 0 || !settings.containsKey(targetVolume.getVirtualArray())) {
                    _logger.info("Target Volume's VArray {} is not matching already ingested source volume virtual pool's remote VArray {}", targetVolume.getVirtualArray(), Joiner.on(",").join(settings.keySet()));
                    // remove the target from processing .so that links will never get established
                    targetUris.remove(targetVolume.getId());
                } else {
                    // for each target set its srdf parent ; copyMode and
                    // raGroup should be updated as part of target ingestion.
                    _logger.info("Set parent for volume {}", targetVolume.getId());
                    targetVolume.setSrdfParent(new NamedURI(srcVolume.getId(), srcVolume.getLabel()));
                    targetVolume.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
                }
            }
            if (!targetUris.isEmpty()) {
                // set targets from source
                srcVolume.setSrdfTargets(VolumeIngestionUtil.convertUrisToStrings(targetUris));
                dbClient.persistObject(targetVolumes);
                // can remove unmanaged volume
                removeUnManagedVolume = true;
                // setting target unmanaged volumes inactive
                List<UnManagedVolume> targetUnManagedVolumes = dbClient.queryObject(UnManagedVolume.class, VolumeIngestionUtil.getUnManagedVolumeUris(targetUnManagedVolumeGuids, dbClient));
                for (UnManagedVolume targetUnManagedVol : targetUnManagedVolumes) {
                    if (!targetUris.contains(targetUnManagedVol.getId())) {
                        _logger.info("Setting unmanaged target inactive {}", targetUnManagedVol.getId());
                        targetUnManagedVol.setInactive(true);
                        unManagedVolumes.add(targetUnManagedVol);
                    } else {
                        _logger.info("Skipping deletion of unmanaged volume {} as remote  links are not established", targetUnManagedVol.getId());
                    }
                }
                _logger.info("Source Volume successfully ingested with remote replication links", srcVolume.getNativeGuid());
            } else {
                _logger.info("Source Volume failed to ingest with remote replication links", srcVolume.getNativeGuid());
            }
        }
    }
    return removeUnManagedVolume;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) NamedURI(com.emc.storageos.db.client.model.NamedURI) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 29 with VpoolRemoteCopyProtectionSettings

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

the class StorageScheduler method getMatchingPools.

/**
 * Select candidate storage pools for placement.
 *
 * @param varray The VirtualArray for matching storage pools.
 * @param vpool The virtualPool that must be satisfied by the storage pool.
 * @param capabilities The VirtualPool params that must be satisfied.
 * @param optionalAttributes Optional addition attributes to consider for placement
 *
 * @return A list of matching storage pools.
 */
protected List<StoragePool> getMatchingPools(VirtualArray varray, VirtualPool vpool, VirtualPoolCapabilityValuesWrapper capabilities, Map<String, Object> optionalAttributes) {
    capabilities.put(VirtualPoolCapabilityValuesWrapper.VARRAYS, varray.getId().toString());
    if (null != vpool.getAutoTierPolicyName()) {
        capabilities.put(VirtualPoolCapabilityValuesWrapper.AUTO_TIER__POLICY_NAME, vpool.getAutoTierPolicyName());
    }
    List<StoragePool> storagePools = new ArrayList<StoragePool>();
    String varrayId = varray.getId().toString();
    StringBuffer errorMessage = new StringBuffer();
    // Verify that if the VirtualPool has been assigned one or more VirtualArrays,
    // there is a match with the passed VirtualArray.
    StringSet vpoolVarrays = vpool.getVirtualArrays();
    if ((vpoolVarrays != null) && (!vpoolVarrays.contains(varrayId))) {
        String message = String.format("Virtual Array %s is not assigned to Virtual Pool %s. ", varray.forDisplay(), vpool.forDisplay());
        errorMessage.append(message);
        _log.error(message);
        if (optionalAttributes != null) {
            optionalAttributes.put(AttributeMatcher.ERROR_MESSAGE, errorMessage);
        }
        return storagePools;
    }
    // Get pools for VirtualPool and VirtualArray
    List<StoragePool> matchedPoolsForCos = VirtualPool.getValidStoragePools(vpool, _dbClient, true);
    if (matchedPoolsForCos.isEmpty()) {
        _log.warn("vPool {} does not have any valid storage pool in vArray {}.", vpool.getId(), varray.getId());
        throw APIException.badRequests.noStoragePoolsForVpoolInVarray(varray.getLabel(), vpool.getLabel());
    }
    AttributeMapBuilder provMapBuilder = new ProvisioningAttributeMapBuilder(capabilities.getSize(), varrayId, capabilities.getThinVolumePreAllocateSize());
    provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.provisioning_type.toString(), vpool.getSupportedProvisioningType());
    // Set CG related attributes for placement
    final BlockConsistencyGroup consistencyGroup = capabilities.getBlockConsistencyGroup() == null ? null : _dbClient.queryObject(BlockConsistencyGroup.class, capabilities.getBlockConsistencyGroup());
    if (consistencyGroup != null) {
        URI cgStorageSystemURI = consistencyGroup.getStorageController();
        if (!NullColumnValueGetter.isNullURI(cgStorageSystemURI)) {
            StorageSystem cgStorageSystem = _dbClient.queryObject(StorageSystem.class, cgStorageSystemURI);
            Set<String> storageSystemSet = new HashSet<String>();
            // this logic is added, as we don't want to add any relationships between source and target CGs explicitly in ViPR.
            if (VirtualPoolCapabilityValuesWrapper.SRDF_TARGET.equalsIgnoreCase(capabilities.getPersonality())) {
                // then update storage system corresponding to target CG
                // source Label is set as alternate name for target Cgs, so that the same name can be used to create targte CGs in
                // Array.
                List<URI> cgUris = _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getBlockConsistencyGroupByAlternateNameConstraint(consistencyGroup.getLabel()));
                if (!cgUris.isEmpty()) {
                    BlockConsistencyGroup targetCgGroup = _dbClient.queryObject(BlockConsistencyGroup.class, cgUris.get(0));
                    if (null != targetCgGroup && !targetCgGroup.getInactive() && null != targetCgGroup.getStorageController() && !NullColumnValueGetter.isNullURI(targetCgGroup.getStorageController())) {
                        storageSystemSet.add(targetCgGroup.getStorageController().toString());
                        provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.storage_system.name(), storageSystemSet);
                        provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.multi_volume_consistency.name(), true);
                    }
                }
            } else if (!DiscoveredDataObject.Type.vplex.name().equals(cgStorageSystem.getSystemType())) {
                // If this is not a VPLEX CG, add the ConsistencyGroup's StorageSystem
                // so that the matching pools are in the same system
                storageSystemSet.add(cgStorageSystemURI.toString());
                provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.storage_system.name(), storageSystemSet);
                provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.multi_volume_consistency.name(), true);
                // IBM XIV requires all volumes of a CG in the same StoragePool
                if (DiscoveredDataObject.Type.ibmxiv.name().equals(cgStorageSystem.getSystemType())) {
                    List<Volume> activeCGVolumes = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, Volume.class, AlternateIdConstraint.Factory.getBlockObjectsByConsistencyGroup(consistencyGroup.getId().toString()));
                    if (!activeCGVolumes.isEmpty()) {
                        URI cgPoolURI = activeCGVolumes.get(0).getPool();
                        if (!NullColumnValueGetter.isNullURI(cgPoolURI)) {
                            Iterator<StoragePool> itr = matchedPoolsForCos.iterator();
                            while (itr.hasNext()) {
                                // remove all pools from matchedPoolsForCos except the one matched
                                URI poolURI = itr.next().getId();
                                if (!cgPoolURI.equals(poolURI)) {
                                    _log.debug("Remove pool {} from list", poolURI);
                                    itr.remove();
                                }
                            }
                        }
                        if (!matchedPoolsForCos.isEmpty()) {
                            _log.debug("Pool {} is used by CG {}", cgPoolURI, consistencyGroup.getId());
                        } else {
                            _log.warn("vPool {} does not have required IBM XIV storage pool in vArray {}.", vpool.getId(), varray.getId());
                            throw APIException.badRequests.noStoragePoolsForVpoolInVarray(varray.getLabel(), vpool.getLabel());
                        }
                    }
                }
            } else {
                provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.multi_volume_consistency.name(), true);
            }
        } else {
            provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.multi_volume_consistency.name(), true);
        }
    }
    // This is used by the VPLEX to control consistency groups.
    if (capabilities.getSourceStorageDevice() != null) {
        StorageSystem sourceStorageSystem = capabilities.getSourceStorageDevice();
        Set<String> storageSystemSet = new HashSet<String>();
        storageSystemSet.add(sourceStorageSystem.getId().toString());
        provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.storage_system.name(), storageSystemSet);
    } else if (capabilities.getExcludedStorageDevice() != null) {
        StorageSystem excludedStorageSystem = capabilities.getExcludedStorageDevice();
        Set<String> storageSystemSet = new HashSet<String>();
        storageSystemSet.add(excludedStorageSystem.getId().toString());
        provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.exclude_storage_system.name(), storageSystemSet);
    }
    // populate DriveType,and Raid level and Policy Name for FAST Initial Placement Selection
    provMapBuilder.putAttributeInMap(Attributes.auto_tiering_policy_name.toString(), vpool.getAutoTierPolicyName());
    provMapBuilder.putAttributeInMap(Attributes.unique_policy_names.toString(), vpool.getUniquePolicyNames());
    provMapBuilder.putAttributeInMap(AttributeMatcher.PLACEMENT_MATCHERS, true);
    provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.drive_type.name(), vpool.getDriveType());
    StringSetMap arrayInfo = vpool.getArrayInfo();
    if (null != arrayInfo) {
        Set<String> raidLevels = arrayInfo.get(VirtualPoolCapabilityValuesWrapper.RAID_LEVEL);
        if (null != raidLevels && !raidLevels.isEmpty()) {
            provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.raid_levels.name(), raidLevels);
        }
        Set<String> systemTypes = arrayInfo.get(AttributeMatcher.Attributes.system_type.name());
        if (null != systemTypes && !systemTypes.isEmpty()) {
            provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.system_type.name(), systemTypes);
            // put quota value for ecs storage
            if (systemTypes.contains("ecs") && capabilities.getQuota() != null) {
                provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.quota.name(), capabilities.getQuota());
            }
        }
    }
    Map<URI, VpoolRemoteCopyProtectionSettings> remoteProtectionSettings = vpool.getRemoteProtectionSettings(vpool, _dbClient);
    if (null != remoteProtectionSettings && !remoteProtectionSettings.isEmpty()) {
        provMapBuilder.putAttributeInMap(Attributes.remote_copy.toString(), VirtualPool.groupRemoteCopyModesByVPool(vpool.getId(), remoteProtectionSettings));
    }
    if (VirtualPoolCapabilityValuesWrapper.FILE_REPLICATION_SOURCE.equalsIgnoreCase(capabilities.getPersonality())) {
        // Run the placement algorithm for file replication!!!
        if (capabilities.getFileReplicationType() != null && !FileReplicationType.NONE.name().equalsIgnoreCase(capabilities.getFileReplicationType())) {
            provMapBuilder.putAttributeInMap(Attributes.file_replication_type.toString(), capabilities.getFileReplicationType());
            if (capabilities.getFileRpCopyMode() != null) {
                provMapBuilder.putAttributeInMap(Attributes.file_replication_copy_mode.toString(), capabilities.getFileRpCopyMode());
            }
            if (capabilities.getFileReplicationTargetVArrays() != null) {
                provMapBuilder.putAttributeInMap(Attributes.file_replication_target_varray.toString(), capabilities.getFileReplicationTargetVArrays());
            }
            if (capabilities.getFileReplicationTargetVPool() != null) {
                provMapBuilder.putAttributeInMap(Attributes.file_replication_target_vpool.toString(), capabilities.getFileReplicationTargetVPool());
            }
        }
    }
    if (capabilities.getSupportsSoftLimit()) {
        provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.support_soft_limit.name(), capabilities.getSupportsSoftLimit());
    }
    if (capabilities.getSupportsNotificationLimit()) {
        provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.support_notification_limit.name(), capabilities.getSupportsNotificationLimit());
    }
    if (!(VirtualPool.vPoolSpecifiesProtection(vpool) || VirtualPool.vPoolSpecifiesSRDF(vpool) || VirtualPool.vPoolSpecifiesHighAvailability(vpool) || VirtualPool.vPoolSpecifiesHighAvailabilityDistributed(vpool))) {
        // only enforce array affinity policy for vpool without RP, SRDF, VPLEX
        boolean arrayAffinity = VirtualPool.ResourcePlacementPolicyType.array_affinity.name().equals(vpool.getPlacementPolicy());
        if (arrayAffinity && capabilities.getCompute() != null) {
            capabilities.put(VirtualPoolCapabilityValuesWrapper.ARRAY_AFFINITY, true);
            provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.array_affinity.name(), true);
        }
    }
    URI portGroupURI = capabilities.getPortGroup();
    boolean usePortGroup = !NullColumnValueGetter.isNullURI(portGroupURI);
    if (usePortGroup) {
        if (!VirtualPool.vPoolSpecifiesHighAvailability(vpool)) {
            StoragePortGroup portGroup = _dbClient.queryObject(StoragePortGroup.class, portGroupURI);
            URI pgSystemURI = portGroup.getStorageDevice();
            boolean setSystemMatcher = true;
            if (consistencyGroup != null) {
                URI cgSystemURI = consistencyGroup.getStorageController();
                if (!NullColumnValueGetter.isNullURI(cgSystemURI)) {
                    if (!cgSystemURI.equals(pgSystemURI)) {
                        // consistency group and port group does not belong to the same storage system
                        throw APIException.badRequests.cgPortGroupNotMatch(portGroupURI.toString(), consistencyGroup.getId().toString());
                    } else {
                        // system matcher has been set
                        setSystemMatcher = false;
                    }
                }
            }
            if (setSystemMatcher) {
                Set<String> storageSystemSet = new HashSet<String>();
                storageSystemSet.add(pgSystemURI.toString());
                provMapBuilder.putAttributeInMap(AttributeMatcher.Attributes.storage_system.name(), storageSystemSet);
            }
        } else {
            // port group could be only specified for native vmax
            throw APIException.badRequests.portGroupValidForVMAXOnly();
        }
    } else {
        // PG was not supplied. This is normally OK unless the VMAX PG feature in enabled and the vpool is not for VPLEX.
        String value = _customConfigHandler.getComputedCustomConfigValue(CustomConfigConstants.VMAX_USE_PORT_GROUP_ENABLED, Type.vmax.name(), null);
        if (Boolean.TRUE.toString().equalsIgnoreCase(value) && !VirtualPool.vPoolSpecifiesHighAvailability(vpool)) {
            // VMAX PG feature is enabled. Limit the valid storage pools to those not requiring PG.
            limitToStoragePoolsNotRequiringPortGroup(capabilities, vpool, provMapBuilder);
        }
    }
    Map<String, Object> attributeMap = provMapBuilder.buildMap();
    if (optionalAttributes != null) {
        attributeMap.putAll(optionalAttributes);
    }
    _log.info("Populated attribute map: {}", attributeMap);
    // Execute basic precondition check to verify that vArray has active storage pools in the vPool.
    // We will return a more accurate error condition if this basic check fails.
    List<StoragePool> matchedPools = _matcherFramework.matchAttributes(matchedPoolsForCos, attributeMap, _dbClient, _coordinator, AttributeMatcher.BASIC_PLACEMENT_MATCHERS, errorMessage);
    if (matchedPools == null || matchedPools.isEmpty()) {
        _log.warn("vPool {} does not have active storage pools in vArray  {} .", vpool.getId(), varray.getId());
        throw APIException.badRequests.noStoragePools(varray.getLabel(), vpool.getLabel(), errorMessage.toString());
    }
    errorMessage.setLength(0);
    // Matches the pools against the VolumeParams.
    // Use a set of matched pools returned from the basic placement matching as the input for this call.
    matchedPools = _matcherFramework.matchAttributes(matchedPools, attributeMap, _dbClient, _coordinator, AttributeMatcher.PLACEMENT_MATCHERS, errorMessage);
    if (matchedPools == null || matchedPools.isEmpty()) {
        if (optionalAttributes != null) {
            optionalAttributes.put(AttributeMatcher.ERROR_MESSAGE, errorMessage);
        }
        _log.warn("Varray {} does not have storage pools which match vpool {} properties and have specified  capabilities.", varray.getId(), vpool.getId());
        return storagePools;
    }
    storagePools.addAll(matchedPools);
    return storagePools;
}
Also used : ProvisioningAttributeMapBuilder(com.emc.storageos.volumecontroller.impl.utils.ProvisioningAttributeMapBuilder) StoragePortGroup(com.emc.storageos.db.client.model.StoragePortGroup) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) StoragePool(com.emc.storageos.db.client.model.StoragePool) Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StringSet(com.emc.storageos.db.client.model.StringSet) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) ProvisioningAttributeMapBuilder(com.emc.storageos.volumecontroller.impl.utils.ProvisioningAttributeMapBuilder) AttributeMapBuilder(com.emc.storageos.volumecontroller.impl.utils.AttributeMapBuilder) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject)

Example 30 with VpoolRemoteCopyProtectionSettings

use of com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings 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)

Aggregations

VpoolRemoteCopyProtectionSettings (com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings)32 URI (java.net.URI)29 ArrayList (java.util.ArrayList)21 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)20 StringSet (com.emc.storageos.db.client.model.StringSet)15 NamedURI (com.emc.storageos.db.client.model.NamedURI)14 List (java.util.List)13 StringMap (com.emc.storageos.db.client.model.StringMap)12 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)11 StoragePool (com.emc.storageos.db.client.model.StoragePool)9 Volume (com.emc.storageos.db.client.model.Volume)8 Recommendation (com.emc.storageos.volumecontroller.Recommendation)8 SRDFRecommendation (com.emc.storageos.volumecontroller.SRDFRecommendation)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)7 SRDFCopyRecommendation (com.emc.storageos.volumecontroller.SRDFCopyRecommendation)6 Network (com.emc.storageos.db.client.model.Network)5