Search in sources :

Example 6 with VolumeIngestionContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext in project coprhd-controller by CoprHD.

the class BaseIngestionRequestContext method findAllUnManagedVolumesToBeDeleted.

/*
     * (non-Javadoc)
     *
     * @see
     * com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext#findAllProcessedUnManagedVolumes
     * ()
     */
@Override
public List<UnManagedVolume> findAllUnManagedVolumesToBeDeleted() {
    _logger.info("assembling a List of all unmanaged volumes to be deleted");
    List<UnManagedVolume> allUnManagedVolumesToBeDeleted = new ArrayList<UnManagedVolume>();
    _logger.info("\tadding local unmanaged volumes to be deleted: " + this.getUnManagedVolumesToBeDeleted());
    allUnManagedVolumesToBeDeleted.addAll(this.getUnManagedVolumesToBeDeleted());
    VolumeIngestionContext currentVolumeContext = getVolumeContext();
    if (currentVolumeContext != null && currentVolumeContext instanceof IngestionRequestContext) {
        for (UnManagedVolume unmanagedSubVolume : ((IngestionRequestContext) currentVolumeContext).getUnManagedVolumesToBeDeleted()) {
            _logger.info("\t\tadding current volume context UnManagedVolume {}", unmanagedSubVolume.forDisplay());
            allUnManagedVolumesToBeDeleted.add(unmanagedSubVolume);
        }
    }
    for (VolumeIngestionContext volumeContext : this.getProcessedUnManagedVolumeMap().values()) {
        if (volumeContext instanceof IngestionRequestContext) {
            for (UnManagedVolume unmanagedSubVolume : ((IngestionRequestContext) volumeContext).getUnManagedVolumesToBeDeleted()) {
                _logger.info("\t\tadding sub context UnManagedVolume {}", unmanagedSubVolume.forDisplay());
                allUnManagedVolumesToBeDeleted.add(unmanagedSubVolume);
            }
        }
    }
    return allUnManagedVolumesToBeDeleted;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) IngestionRequestContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext) ArrayList(java.util.ArrayList) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)

Example 7 with VolumeIngestionContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext in project coprhd-controller by CoprHD.

the class RecoverPointVolumeIngestionContext method findExistingBlockConsistencyGroup.

/**
 * Finds an existing BlockConsistencyGroup in any RecoverPoint volume ingestion context within the scope of this ingestion request.
 *
 * @param psetLabel the label of the associated ProtectionSet
 * @param projectNamedUri the NamedUri of the Project for the BlockConsistencyGroup
 * @param tenantOrg the Tenant for the BlockConsistencyGroup
 * @return an existing BlockConsistencyGroup matching the arguments
 */
public BlockConsistencyGroup findExistingBlockConsistencyGroup(String psetLabel, NamedURI projectNamedUri, NamedURI tenantOrg) {
    for (VolumeIngestionContext volumeContext : getRootIngestionRequestContext().getProcessedUnManagedVolumeMap().values()) {
        if (volumeContext instanceof RecoverPointVolumeIngestionContext) {
            RecoverPointVolumeIngestionContext rpContext = (RecoverPointVolumeIngestionContext) volumeContext;
            BlockConsistencyGroup bcg = rpContext.getManagedBlockConsistencyGroup();
            if (bcg != null) {
                if ((bcg.getLabel().equals(psetLabel)) && (bcg.getProject().equals(projectNamedUri)) && (bcg.getTenant().equals(tenantOrg))) {
                    _logger.info("found already-instantiated BlockConsistencyGroup {} (hash {})", bcg.getLabel(), bcg.hashCode());
                    return bcg;
                }
            }
        }
    }
    _logger.info("did not find an already-instantiated BlockConsistencyGroup for ", psetLabel);
    return null;
}
Also used : VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 8 with VolumeIngestionContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext 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 9 with VolumeIngestionContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext 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 10 with VolumeIngestionContext

use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext in project coprhd-controller by CoprHD.

the class UnManagedVolumeService method commitIngestedCG.

/**
 * Commit ingested consistency group
 *
 * @param requestContext request context
 * @param unManagedVolume unmanaged volume to ingest against this CG
 * @throws Exception
 */
public void commitIngestedCG(IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) throws Exception {
    VolumeIngestionContext volumeContext = requestContext.getVolumeContext();
    // Iterate through each CG & decorate its objects.
    if (!volumeContext.getCGObjectsToCreateMap().isEmpty()) {
        for (Entry<String, BlockConsistencyGroup> cgEntry : volumeContext.getCGObjectsToCreateMap().entrySet()) {
            BlockConsistencyGroup cg = cgEntry.getValue();
            Collection<BlockObject> allCGBlockObjects = VolumeIngestionUtil.getAllBlockObjectsInCg(cg, requestContext);
            Collection<String> nativeGuids = transform(allCGBlockObjects, fctnBlockObjectToNativeGuid());
            _logger.info("Decorating CG {} with blockObjects {}", cgEntry.getKey(), nativeGuids);
            rpCGDecorator.setDbClient(_dbClient);
            rpCGDecorator.decorate(cg, unManagedVolume, allCGBlockObjects, requestContext);
        }
    }
    persistConsistencyGroups(volumeContext.getCGObjectsToCreateMap().values());
    // Update UnManagedConsistencyGroups.
    if (!volumeContext.getUmCGObjectsToUpdate().isEmpty()) {
        _logger.info("updating {} unmanagedConsistencyGroups in db.");
        _dbClient.updateObject(volumeContext.getUmCGObjectsToUpdate());
    }
}
Also used : VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext) BlockObject(com.emc.storageos.db.client.model.BlockObject) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Aggregations

VolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)16 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)9 IngestionRequestContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext)6 BlockObject (com.emc.storageos.db.client.model.BlockObject)6 DataObject (com.emc.storageos.db.client.model.DataObject)6 Volume (com.emc.storageos.db.client.model.Volume)6 RpVplexVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext)5 VplexVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext)5 ArrayList (java.util.ArrayList)5 RecoverPointVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext)4 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)4 URI (java.net.URI)4 BlockVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext)3 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)3 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)3 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)3 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)2 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)2