Search in sources :

Example 96 with StringSet

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

the class VMAX3BlockSnapshotSessionApiImpl method verifyNewTargetCount.

/**
 * {@inheritDoc}
 */
@Override
protected void verifyNewTargetCount(BlockObject sourceObj, int newTargetsCount, boolean zeroIsValid) {
    // Call super first.
    super.verifyNewTargetCount(sourceObj, newTargetsCount, zeroIsValid);
    // Now make sure max is not exceeded.
    if (newTargetsCount > 0) {
        // The total number of linked targets for all sessions for a given
        // source can't exceed 1024. So, get all sessions for the source
        // and add all linked targets for these sessions. That value plus
        // the number of new targets cannot exceed the max.
        int totalLinkedTargets = newTargetsCount;
        List<BlockSnapshotSession> snapSessions = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(sourceObj.getId()));
        for (BlockSnapshotSession snapSession : snapSessions) {
            StringSet linkedTargetIds = snapSession.getLinkedTargets();
            if (linkedTargetIds != null) {
                totalLinkedTargets += linkedTargetIds.size();
            }
        }
        if (totalLinkedTargets > MAX_LINKED_TARGETS_PER_SOURCE) {
            throw APIException.badRequests.invalidNewLinkedTargetsCount(newTargetsCount, sourceObj.getLabel(), MAX_LINKED_TARGETS_PER_SOURCE - totalLinkedTargets);
        }
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) StringSet(com.emc.storageos.db.client.model.StringSet) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 97 with StringSet

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

the class VMAX3BlockFullCopyApiImpl method validateSnapshotCreateRequest.

/**
 * {@inheritDoc}
 */
@Override
public void validateSnapshotCreateRequest(Volume requestedVolume, List<Volume> volumesToSnap) {
    // so verify there are no active full copies for the volume.
    for (Volume volumeToSnap : volumesToSnap) {
        // Check if the volume to snap is an active full copy.
        if ((BlockFullCopyUtils.isVolumeFullCopy(volumeToSnap, _dbClient)) && (!BlockFullCopyUtils.isFullCopyDetached(volumeToSnap, _dbClient)) && (!BlockFullCopyUtils.isFullCopyInactive(volumeToSnap, _dbClient))) {
            throw APIException.badRequests.noSnapshotsForVMAX3VolumeWithActiveFullCopy();
        }
        // Now check if the volume to be snapped is a full copy source
        // that has active full copies.
        StringSet fullCopyIds = volumeToSnap.getFullCopies();
        if ((fullCopyIds != null) && (!fullCopyIds.isEmpty())) {
            Iterator<String> fullCopyIdsIter = fullCopyIds.iterator();
            while (fullCopyIdsIter.hasNext()) {
                URI fullCopyURI = URI.create(fullCopyIdsIter.next());
                Volume fullCopyVolume = _dbClient.queryObject(Volume.class, fullCopyURI);
                if ((fullCopyVolume != null) && (!fullCopyVolume.getInactive()) && (!BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) && (!BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient))) {
                    throw APIException.badRequests.noSnapshotsForVMAX3VolumeWithActiveFullCopy();
                }
            }
        }
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) URI(java.net.URI)

Example 98 with StringSet

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

the class VolumeIngestionUtil method validateUnManagedExportMasks.

/**
 * Validates that all the selected UnManagedExportMasks are compatible for ingestion.
 *
 * Currently only VPLEX volumes are checked for presence of a
 * single storage view per VPLEX cluster per host initiator.
 *
 * @param unManagedVolume the UnManagedVolume being ingested
 * @param unManagedMasks the UnManagedExportMasks being ingested
 * @param dbClient a reference to the database client
 */
public static void validateUnManagedExportMasks(UnManagedVolume unManagedVolume, List<UnManagedExportMask> unManagedMasks, DbClient dbClient) {
    if (isVplexVolume(unManagedVolume)) {
        Map<String, Set<String>> initToMaskMap = new HashMap<String, Set<String>>();
        // vplex brownfield requires initiators to only be in one storage view.
        // assemble a Set of all initiator ports being masked to the ingesting unmanaged volume
        StringSet allInitiatorPortsBeingIngested = new StringSet();
        for (UnManagedExportMask mask : unManagedMasks) {
            allInitiatorPortsBeingIngested.addAll(mask.getKnownInitiatorNetworkIds());
            allInitiatorPortsBeingIngested.addAll(mask.getUnmanagedInitiatorNetworkIds());
        }
        URIQueryResultList result = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageSystemUnManagedExportMaskConstraint(unManagedVolume.getStorageSystemUri()), result);
        Set<URI> allMasksUrisForVplex = new HashSet<URI>();
        Iterator<URI> it = result.iterator();
        while (it.hasNext()) {
            allMasksUrisForVplex.add(it.next());
        }
        Iterator<UnManagedExportMask> allMasksForVplex = dbClient.queryIterativeObjects(UnManagedExportMask.class, allMasksUrisForVplex, true);
        while (allMasksForVplex.hasNext()) {
            UnManagedExportMask mask = allMasksForVplex.next();
            if (null != mask) {
                mapInitsToVplexStorageViews(initToMaskMap, mask, allInitiatorPortsBeingIngested);
            }
        }
        _logger.info("initiator to UnManagedExportMask map is " + initToMaskMap);
        // filter out any initiator to mask entries that satisfy the requirements of 1 storage view per initiator
        Iterator<Entry<String, Set<String>>> mapEntries = initToMaskMap.entrySet().iterator();
        while (mapEntries.hasNext()) {
            Entry<String, Set<String>> entry = mapEntries.next();
            if (entry.getValue().size() <= 1) {
                mapEntries.remove();
            }
        }
        // if any are left in the map, they violate the single storage view per initiator rule
        if (!initToMaskMap.isEmpty()) {
            StringBuilder errorDetails = new StringBuilder();
            for (Entry<String, Set<String>> mapEntry : initToMaskMap.entrySet()) {
                errorDetails.append("Initiator port ").append(mapEntry.getKey());
                errorDetails.append(" is contained in the following storage views: ");
                errorDetails.append(Joiner.on(", ").join(mapEntry.getValue())).append(". ");
            }
            _logger.error(errorDetails.toString());
            throw IngestionException.exceptions.invalidExportConfiguration(errorDetails.toString());
        }
    }
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) Set(java.util.Set) HashSet(java.util.HashSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Entry(java.util.Map.Entry) StringSet(com.emc.storageos.db.client.model.StringSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) HashSet(java.util.HashSet)

Example 99 with StringSet

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

the class VolumeIngestionUtil method setupMirrorParentRelations.

/**
 * Setup relationships between a mirror and its parent BlockObject.
 *
 * @param mirror the mirror BlockObject
 * @param parentVolume the mirror's parent BlockObject
 * @param dbClient a reference to the database client
 */
public static void setupMirrorParentRelations(BlockObject mirror, BlockObject parent, DbClient dbClient) {
    _logger.info("Setting up relationship between mirror {} ({}) and parent {} ({})", new Object[] { mirror.getLabel(), mirror.getId(), parent.getLabel(), parent.getId() });
    ((BlockMirror) mirror).setSource(new NamedURI(parent.getId(), parent.getLabel()));
    if (parent instanceof Volume) {
        StringSet mirrors = ((Volume) parent).getMirrors();
        if (mirrors == null) {
            mirrors = new StringSet();
        }
        mirrors.add(mirror.getId().toString());
        ((Volume) parent).setMirrors(mirrors);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) NamedURI(com.emc.storageos.db.client.model.NamedURI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 100 with StringSet

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

the class VolumeIngestionUtil method setupSnapParentRelations.

/**
 * Setup relationships between a snapshot and its parent BlockObject.
 *
 * @param snapshot the snapshot BlockObject
 * @param parentVolume the snapshot's parent BlockObject
 * @param dbClient a reference to the database client
 */
public static void setupSnapParentRelations(BlockObject snapshot, BlockObject parentVolume, DbClient dbClient) {
    _logger.info("Setting up relationship between snapshot {} ({}) and parent {} ({})", new Object[] { snapshot.getLabel(), snapshot.getId(), parentVolume.getLabel(), parentVolume.getId() });
    ((BlockSnapshot) snapshot).setSourceNativeId(parentVolume.getNativeId());
    ((BlockSnapshot) snapshot).setParent(new NamedURI(parentVolume.getId(), parentVolume.getLabel()));
    snapshot.setProtocol(new StringSet());
    snapshot.getProtocol().addAll(parentVolume.getProtocol());
    URI cgUri = parentVolume.getConsistencyGroup();
    // Do not associate parent's CG if it is a RP protected parent volume
    boolean isRP = (parentVolume instanceof Volume && ((Volume) parentVolume).checkForRp()) || (parentVolume instanceof BlockSnapshot && ((BlockSnapshot) parentVolume).getProtectionController() != null);
    if (!isRP && cgUri != null) {
        snapshot.setConsistencyGroup(cgUri);
    }
// TODO - check how to populate snapsetlabel if in consistency group
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

StringSet (com.emc.storageos.db.client.model.StringSet)760 URI (java.net.URI)371 ArrayList (java.util.ArrayList)278 Volume (com.emc.storageos.db.client.model.Volume)189 NamedURI (com.emc.storageos.db.client.model.NamedURI)176 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)137 HashMap (java.util.HashMap)132 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)124 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)116 List (java.util.List)108 HashSet (java.util.HashSet)106 StoragePort (com.emc.storageos.db.client.model.StoragePort)90 StoragePool (com.emc.storageos.db.client.model.StoragePool)75 StringMap (com.emc.storageos.db.client.model.StringMap)74 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)71 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)70 Initiator (com.emc.storageos.db.client.model.Initiator)60 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)60 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)50 Map (java.util.Map)48