Search in sources :

Example 31 with UnManagedVolume

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

the class VolumeIngestionUtil method isRPProtectingVplexVolumes.

/**
 * Checks whether RP is protecting any VPLEX volumes or not.
 *
 * 1. Get the ProtectionSet from the context for the given unmanagedvolume.
 * 2. Check every volume in the protectionset.
 * 3. If the volume belongs to a VPLEX or not.
 * 4. If it belongs to VPLEX break the loop and return true.
 *
 * @param umv - unmanaged volume to ingest
 * @param requestContext - current unmanaged volume context.
 * @param dbClient - dbclient reference.
 */
public static boolean isRPProtectingVplexVolumes(UnManagedVolume umv, IngestionRequestContext requestContext, DbClient dbClient) {
    VolumeIngestionContext context = requestContext.getVolumeContext(umv.getNativeGuid());
    boolean isRPProtectingVplexVolumes = false;
    // We expect RP Context to validate Vplex volumes protected by RP or not.
    if (context instanceof RecoverPointVolumeIngestionContext) {
        RecoverPointVolumeIngestionContext rpContext = (RecoverPointVolumeIngestionContext) context;
        ProtectionSet pset = rpContext.getManagedProtectionSet();
        if (pset == null) {
            return isRPProtectingVplexVolumes;
        }
        // Iterate thru protection set volumes.
        for (String volumeIdStr : pset.getVolumes()) {
            for (Set<DataObject> dataObjList : rpContext.getDataObjectsToBeUpdatedMap().values()) {
                for (DataObject dataObj : dataObjList) {
                    if (URIUtil.identical(dataObj.getId(), URI.create(volumeIdStr))) {
                        Volume volume = (Volume) dataObj;
                        if (volume.isVPlexVolume(dbClient)) {
                            isRPProtectingVplexVolumes = true;
                            break;
                        }
                    }
                }
            }
        }
    } else if (context instanceof BlockVolumeIngestionContext) {
        // In this case, the last volume ingested was a replica, so we need to fish out RP information slightly differently.
        Set<DataObject> updatedObjects = requestContext.getDataObjectsToBeUpdatedMap().get(umv.getNativeGuid());
        if (updatedObjects != null && !updatedObjects.isEmpty()) {
            for (DataObject dataObj : updatedObjects) {
                if (dataObj instanceof Volume) {
                    Volume volume = (Volume) dataObj;
                    if (volume.isVPlexVolume(dbClient)) {
                        isRPProtectingVplexVolumes = true;
                        break;
                    }
                }
            }
        }
    } else {
        _logger.error("Context found of type: {} invalid", context.getClass().toString());
    }
    return isRPProtectingVplexVolumes;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) 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) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) BlockVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) BlockVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)

Example 32 with UnManagedVolume

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

the class VolumeIngestionUtil method clearFullCopiesFlags.

/**
 * Clear the flags of the full copies of the RP volume
 *
 * @param requestContext current unManagedVolume Ingestion context.
 * @param volumes the Volume Objects to clear flags on
 * @param updatedObjects a Set of DataObjects to be updated in the database at the end of ingestion
 * @param dbClient - dbClient reference.
 */
public static void clearFullCopiesFlags(IngestionRequestContext requestContext, Volume volume, Set<DataObject> updatedObjects, DbClient dbClient) {
    if (volume.getFullCopies() != null) {
        for (String volumeId : volume.getFullCopies()) {
            BlockObject bo = requestContext.findDataObjectByType(Volume.class, URI.create(volumeId), true);
            if (null != bo && bo instanceof Volume) {
                _logger.info("Clearing internal volume flag of full copy {} of RP volume {}", bo.getLabel(), volume.getLabel());
                bo.clearInternalFlags(BlockIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
                updatedObjects.add(bo);
            }
        }
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 33 with UnManagedVolume

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

the class VolumeIngestionUtil method findVplexParentVolume.

/**
 * Recursively find a VPLEX parent volume for the given UnManagedVolume. Will first check
 * VPLEX_PARENT_VOLUME and if not found, will check LOCAL_REPLICA_SOURCE_VOLUME recursively
 * for its VPLEX_PARENT_VOLUME.
 *
 * @param unManagedVolume the UnManagedVolume to check
 * @param dbClient a reference to the database client
 * @param cache an optional cache of loaded VPLEX parent volume guids to UnManagedVolume object for that GUID
 * @return the root parent VPLEX virtual volume UnManagedVolume, or null if none found
 */
public static UnManagedVolume findVplexParentVolume(UnManagedVolume unManagedVolume, DbClient dbClient, Map<String, UnManagedVolume> cache) {
    if (unManagedVolume == null || isVplexVolume(unManagedVolume)) {
        return unManagedVolume;
    }
    String vplexParentVolumeGuid = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.VPLEX_PARENT_VOLUME.toString(), unManagedVolume.getVolumeInformation());
    if (vplexParentVolumeGuid != null) {
        if (cache != null && cache.containsKey(vplexParentVolumeGuid)) {
            return cache.get(vplexParentVolumeGuid);
        }
        URIQueryResultList unManagedVolumeList = new URIQueryResultList();
        dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(vplexParentVolumeGuid), unManagedVolumeList);
        if (unManagedVolumeList.iterator().hasNext()) {
            UnManagedVolume vplexParentVolume = dbClient.queryObject(UnManagedVolume.class, unManagedVolumeList.iterator().next());
            if (cache != null) {
                cache.put(vplexParentVolumeGuid, vplexParentVolume);
            }
            return vplexParentVolume;
        }
    } else {
        String localReplicaSourceVolumeGuid = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.LOCAL_REPLICA_SOURCE_VOLUME.toString(), unManagedVolume.getVolumeInformation());
        if (localReplicaSourceVolumeGuid != null) {
            URIQueryResultList unManagedVolumeList = new URIQueryResultList();
            dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(localReplicaSourceVolumeGuid), unManagedVolumeList);
            if (unManagedVolumeList.iterator().hasNext()) {
                UnManagedVolume localReplicaSourceVolume = dbClient.queryObject(UnManagedVolume.class, unManagedVolumeList.iterator().next());
                return findVplexParentVolume(localReplicaSourceVolume, dbClient, cache);
            }
        }
    }
    return null;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 34 with UnManagedVolume

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

the class VolumeIngestionUtil method clearReplicaFlagsInIngestionContext.

/**
 * Clear the flags of replicas which have been updated during the ingestion process
 *
 * @param requestContext current unManagedVolume Ingestion context.
 * @param volumes RP volumes
 * @param dbClient database client
 */
public static void clearReplicaFlagsInIngestionContext(IngestionRequestContext requestContext, List<Volume> volumes, DbClient dbClient) {
    // We need to look for all snapshots and snapshot session in the contexts related to the rp volumes and its backend volumes and
    // clear their flags.
    _logger.info("Clearing flags of replicas in the context");
    List<String> rpVolumes = new ArrayList<String>();
    for (Volume volume : volumes) {
        rpVolumes.add(volume.getId().toString());
        if (RPHelper.isVPlexVolume(volume, dbClient) && volume.getAssociatedVolumes() != null && !volume.getAssociatedVolumes().isEmpty()) {
            StringSet associatedVolumes = volume.getAssociatedVolumes();
            rpVolumes.addAll(associatedVolumes);
        }
    }
    for (VolumeIngestionContext volumeIngestionContext : requestContext.getRootIngestionRequestContext().getProcessedUnManagedVolumeMap().values()) {
        if (volumeIngestionContext instanceof IngestionRequestContext) {
            for (Set<DataObject> objectsToBeUpdated : ((IngestionRequestContext) volumeIngestionContext).getDataObjectsToBeUpdatedMap().values()) {
                for (DataObject o : objectsToBeUpdated) {
                    boolean rpBlockSnapshot = (o instanceof BlockSnapshot && rpVolumes.contains(((BlockSnapshot) o).getParent().getURI().toString()));
                    boolean rpBlockSnapshotSession = (o instanceof BlockSnapshotSession && rpVolumes.contains(((BlockSnapshotSession) o).getParent().getURI().toString()));
                    if (rpBlockSnapshot || rpBlockSnapshotSession) {
                        _logger.info(String.format("Clearing internal volume flag of %s %s of RP volume ", (rpBlockSnapshot ? "BlockSnapshot" : "BlockSnapshotSession"), o.getLabel()));
                        o.clearInternalFlags(BlockIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
                    }
                }
            }
        }
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) IngestionRequestContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) BlockVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)

Example 35 with UnManagedVolume

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

the class VolumeIngestionUtil method findUnManagedVolumesForCluster.

/**
 * Returns a List of UnManagedVolumes for the given Cluster URI.
 *
 * @param clusterUri the Cluster URI to check
 * @param dbClient a reference to the database client
 * @return a List of UnManagedVolumes for the given Cluster URI
 */
public static List<UnManagedVolume> findUnManagedVolumesForCluster(URI clusterUri, DbClient dbClient) {
    _logger.info("finding unmanaged volumes for cluster " + clusterUri);
    Set<URI> consistentVolumeUris = new HashSet<URI>();
    List<URI> hostUris = ComputeSystemHelper.getChildrenUris(dbClient, clusterUri, Host.class, "cluster");
    int hostIndex = 0;
    for (URI hostUri : hostUris) {
        _logger.info("   looking at host " + hostUri);
        List<Initiator> initiators = ComputeSystemHelper.queryInitiators(dbClient, hostUri);
        URIQueryResultList results = new URIQueryResultList();
        Set<URI> unManagedVolumeUris = new HashSet<URI>();
        for (Initiator initiator : initiators) {
            _logger.info("      looking at initiator " + initiator.getInitiatorPort());
            dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedVolumeInitiatorNetworkIdConstraint(initiator.getInitiatorPort()), results);
            if (results.iterator() != null) {
                for (URI uri : results) {
                    _logger.info("      found UnManagedVolume " + uri);
                    unManagedVolumeUris.add(uri);
                }
            }
        }
        Set<URI> thisHostsUris = new HashSet<URI>();
        for (URI unmanagedVolumeUri : unManagedVolumeUris) {
            if (hostIndex == 0) {
                // on the first host, just add all UnManagedVolumes that were found
                consistentVolumeUris.add(unmanagedVolumeUri);
            } else {
                // on subsequent hosts, create a collection to use in diffing the sets
                thisHostsUris.add(unmanagedVolumeUri);
            }
        }
        if (hostIndex > 0) {
            // retain only UnManagedVolumes that are found exposed to all hosts in the cluster
            consistentVolumeUris.retainAll(thisHostsUris);
        }
        hostIndex++;
    }
    _logger.info("   found {} UnManagedVolumes to be consistent across all hosts", consistentVolumeUris.size());
    List<UnManagedVolume> unmanagedVolumes = new ArrayList<UnManagedVolume>();
    for (URI unmanagedVolumeUri : consistentVolumeUris) {
        UnManagedVolume unmanagedVolume = dbClient.queryObject(UnManagedVolume.class, unmanagedVolumeUri);
        if (unmanagedVolume == null || unmanagedVolume.getInactive() == true) {
            continue;
        }
        unmanagedVolumes.add(unmanagedVolume);
        _logger.info("      volume: " + unmanagedVolume.getLabel() + " nativeGuid: " + unmanagedVolume.getNativeGuid());
    }
    return unmanagedVolumes;
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet)

Aggregations

UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)146 StringSet (com.emc.storageos.db.client.model.StringSet)66 URI (java.net.URI)53 Volume (com.emc.storageos.db.client.model.Volume)48 ArrayList (java.util.ArrayList)48 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)33 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)31 BlockObject (com.emc.storageos.db.client.model.BlockObject)30 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)24 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)19 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)18 DataObject (com.emc.storageos.db.client.model.DataObject)13 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)13 CIMObjectPath (javax.cim.CIMObjectPath)13 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)12 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)11 Map (java.util.Map)11 StringMap (com.emc.storageos.db.client.model.StringMap)10