Search in sources :

Example 1 with RecoverPointVolumeIngestionContext

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

the class BlockRecoverPointIngestOrchestrator method decorateVolumeInformationFinalIngest.

/**
 * This method will perform all of the final decorations (attribute setting) on the Volume
 * object after creating the required BlockConsistencyGroup and ProtectionSet objects.
 *
 * Fields such as rpCopyName and rSetName were already filled in when we did the ingest of
 * the volume itself. In this method, we worry about stitching together all of the object
 * references within the Volume object so it will act like a native CoprHD-created RP volume.
 *
 * @param volumeContext the RecoverPointVolumeIngestionContext for the volume currently being ingested
 * @param unManagedVolume the currently ingesting UnManagedVolume
 */
private void decorateVolumeInformationFinalIngest(IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) {
    RecoverPointVolumeIngestionContext volumeContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext();
    ProtectionSet pset = volumeContext.getManagedProtectionSet();
    BlockConsistencyGroup cg = volumeContext.getManagedBlockConsistencyGroup();
    if (pset.getVolumes() == null) {
        _logger.error("No volumes found in protection set: " + pset.getLabel() + ", cannot process ingestion");
        throw IngestionException.exceptions.noVolumesFoundInProtectionSet(pset.getLabel());
    }
    List<Volume> volumes = new ArrayList<Volume>();
    for (String volId : pset.getVolumes()) {
        BlockObject volume = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(URI.create(volId));
        if (volume != null && volume instanceof Volume) {
            volumes.add((Volume) volume);
        }
    }
    // Make sure all of the changed managed block objects get updated
    volumes.add((Volume) volumeContext.getManagedBlockObject());
    Set<DataObject> updatedObjects = new HashSet<DataObject>();
    VolumeIngestionUtil.decorateRPVolumesCGInfo(volumes, pset, cg, updatedObjects, _dbClient, requestContext);
    VolumeIngestionUtil.clearPersistedReplicaFlags(requestContext, volumes, updatedObjects, _dbClient);
    clearReplicaFlagsInIngestionContext(volumeContext, volumes);
    for (DataObject volume : updatedObjects) {
        if (volumeContext.getManagedBlockObject().getId().equals(volume.getId()) && (null == _dbClient.queryObject(Volume.class, volume.getId()))) {
            // this is the managed block object and it hasn't been saved to the db yet
            continue;
        } else {
            // add all volumes except the newly ingested one to the update list
            volumeContext.addDataObjectToUpdate(volume, unManagedVolume);
        }
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) 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) ArrayList(java.util.ArrayList) BlockObject(com.emc.storageos.db.client.model.BlockObject) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) HashSet(java.util.HashSet)

Example 2 with RecoverPointVolumeIngestionContext

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

the class BlockRPCGIngestDecorator method getAssociatedObjects.

@Override
protected List<BlockObject> getAssociatedObjects(BlockConsistencyGroup cg, Collection<BlockObject> allCGBlockObjects, IngestionRequestContext requestContext) throws Exception {
    // Get all of the block objects that are in the protection set
    RecoverPointVolumeIngestionContext rpContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext();
    ProtectionSet pset = rpContext.getManagedProtectionSet();
    if (pset == null) {
        return null;
    }
    // All of the volumes in the CG are in the "objects to be updated" map in the RP context.
    List<BlockObject> boList = new ArrayList<BlockObject>();
    for (String volumeIdStr : pset.getVolumes()) {
        for (DataObject dataObj : allCGBlockObjects) {
            if (URIUtil.identical(dataObj.getId(), URI.create(volumeIdStr))) {
                boList.add((BlockObject) dataObj);
            }
        }
    }
    return boList;
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) ArrayList(java.util.ArrayList) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 3 with RecoverPointVolumeIngestionContext

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

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

the class VolumeIngestionUtil method findOrCreateRPBlockConsistencyGroup.

/**
 * Creates a block consistency group for the given protection set, or finds one first
 * if it has already been created in another volume context within the scope of this
 * ingestion request.
 *
 * @param requestContext the current IngestionRequestContext
 * @param unManagedVolume the currently ingesting UnManagedVolume
 * @param pset the ProtectionSet
 * @param dbClient a reference to the database client
 * @return a BlockConsistencyGroup for the volume context and ProtectionSet
 */
public static BlockConsistencyGroup findOrCreateRPBlockConsistencyGroup(IngestionRequestContext requestContext, UnManagedVolume unManagedVolume, ProtectionSet pset, DbClient dbClient) {
    BlockConsistencyGroup cg = null;
    Project project = dbClient.queryObject(Project.class, pset.getProject());
    NamedURI projectNamedUri = new NamedURI(pset.getProject(), project.getLabel());
    // if this is a recover point ingestion context, check for an existing CG in memory
    RecoverPointVolumeIngestionContext rpContext = null;
    if (requestContext instanceof RecoverPointVolumeIngestionContext) {
        rpContext = (RecoverPointVolumeIngestionContext) requestContext;
    } else if (requestContext.getVolumeContext(unManagedVolume.getNativeGuid()) instanceof RecoverPointVolumeIngestionContext) {
        rpContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext(unManagedVolume.getNativeGuid());
    }
    if (rpContext != null) {
        cg = rpContext.findExistingBlockConsistencyGroup(pset.getLabel(), projectNamedUri, project.getTenantOrg());
    }
    // Find the source volume in the protection set so we can set the virtual array in the consistency group
    URI varrayId = null;
    URI storageSystemId = null;
    if (pset.getVolumes() != null) {
        for (String volumeIdStr : pset.getVolumes()) {
            Volume volume = requestContext.findDataObjectByType(Volume.class, URI.create(volumeIdStr), true);
            if (volume != null) {
                if (PersonalityTypes.SOURCE.name().equalsIgnoreCase(volume.getPersonality())) {
                    varrayId = volume.getVirtualArray();
                    if (volume.isVPlexVolume(dbClient)) {
                        storageSystemId = volume.getStorageController();
                    }
                }
            }
        }
    }
    if (cg == null) {
        cg = new BlockConsistencyGroup();
        cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
        cg.setLabel(pset.getLabel());
        cg.setProject(projectNamedUri);
        cg.addConsistencyGroupTypes(Types.RP.name());
        // By default, the array consistency is false. However later when we iterate over volumes in the BCG and we
        // see any replicationGroupInstance information, we'll flip this bit to true. (See decorateRPVolumesCGInfo())
        cg.setArrayConsistency(false);
        cg.setTenant(project.getTenantOrg());
        cg.setVirtualArray(varrayId);
        cg.setStorageController(storageSystemId);
        _logger.info("Created new block consistency group: " + cg.getId().toString());
    }
    cg.addSystemConsistencyGroup(pset.getProtectionSystem().toString(), pset.getLabel());
    return cg;
}
Also used : Project(com.emc.storageos.db.client.model.Project) 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) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 5 with RecoverPointVolumeIngestionContext

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

the class BlockRPCGIngestDecorator method decorateCG.

@Override
public void decorateCG(BlockConsistencyGroup cg, Collection<BlockObject> associatedObjects, IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) throws Exception {
    // This information is already set in the RP ingestion orchestrator, however in case anyone ever writes a decorator
    // above us, this will ensure we put the right information in their CG to represent our RP CG.
    RecoverPointVolumeIngestionContext rpContext = (RecoverPointVolumeIngestionContext) requestContext.getVolumeContext();
    ProtectionSet pset = rpContext.getManagedProtectionSet();
    cg.getTypes().add(BlockConsistencyGroup.Types.RP.toString());
    cg.addSystemConsistencyGroup(pset.getProtectionSystem().toString(), pset.getLabel());
}
Also used : RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet)

Aggregations

RecoverPointVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext)9 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)7 Volume (com.emc.storageos.db.client.model.Volume)7 ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)6 BlockObject (com.emc.storageos.db.client.model.BlockObject)5 DataObject (com.emc.storageos.db.client.model.DataObject)5 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)5 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 ArrayList (java.util.ArrayList)4 VolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext)2 BlockVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.BlockVolumeIngestionContext)2 RpVplexVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext)2 VplexVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext)2 HashSet (java.util.HashSet)2 IngestionRequestContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext)1 AbstractChangeTrackingSet (com.emc.storageos.db.client.model.AbstractChangeTrackingSet)1 BlockMirror (com.emc.storageos.db.client.model.BlockMirror)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)1