Search in sources :

Example 11 with ProtectionSet

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

the class RPBlockServiceApiImpl method cleanupForViPROnlyDelete.

/**
 * {@inheritDoc}
 */
@Override
protected void cleanupForViPROnlyDelete(List<VolumeDescriptor> volumeDescriptors) {
    // Call super first.
    super.cleanupForViPROnlyDelete(volumeDescriptors);
    // Get the RP source volumes.
    List<VolumeDescriptor> sourceVolumeDescriptors = VolumeDescriptor.filterByType(volumeDescriptors, new VolumeDescriptor.Type[] { VolumeDescriptor.Type.RP_SOURCE, VolumeDescriptor.Type.RP_VPLEX_VIRT_SOURCE }, new VolumeDescriptor.Type[] {});
    List<URI> sourceVolumeURIs = new ArrayList<URI>();
    for (URI sourceVolumeURI : VolumeDescriptor.getVolumeURIs(sourceVolumeDescriptors)) {
        Volume sourceVolume = _dbClient.queryObject(Volume.class, sourceVolumeURI);
        if (sourceVolume != null && !sourceVolume.getInactive() && !sourceVolume.isIngestedVolumeWithoutBackend(_dbClient)) {
            // Keeping this in here for when we do RP ingest.
            sourceVolumeURIs.add(sourceVolumeURI);
        }
    }
    // If we're deleting the last volume, we can delete the ProtectionSet object.
    // This list of volumes may contain volumes from many protection sets
    Set<URI> volumesToDelete = RPHelper.getVolumesToDelete(sourceVolumeURIs, _dbClient);
    Map<URI, Set<URI>> psetToVolumesToDelete = new HashMap<URI, Set<URI>>();
    // Group volumes to delete by their protectionsets
    for (URI volumeURI : volumesToDelete) {
        Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
        if (volume.getProtectionSet() != null) {
            if (psetToVolumesToDelete.get(volume.getProtectionSet().getURI()) == null) {
                psetToVolumesToDelete.put(volume.getProtectionSet().getURI(), new HashSet<URI>());
            }
            psetToVolumesToDelete.get(volume.getProtectionSet().getURI()).add(volumeURI);
        }
    }
    // Go through all protection sets and verify we have all of the volumes accounted for
    // and delete the protection set if necessary. Log otherwise.
    Set<URI> psetsDeleted = new HashSet<URI>();
    for (Entry<URI, Set<URI>> psetVolumeEntry : psetToVolumesToDelete.entrySet()) {
        ProtectionSet pset = _dbClient.queryObject(ProtectionSet.class, psetVolumeEntry.getKey());
        if (pset != null && !psetsDeleted.contains(pset.getId()) && psetVolumeEntry.getValue().size() == pset.getVolumes().size()) {
            _dbClient.markForDeletion(pset);
            psetsDeleted.add(pset.getId());
        } else if (pset.getVolumes() == null) {
            _dbClient.markForDeletion(pset);
            psetsDeleted.add(pset.getId());
            _log.info(String.format("Deleting protection %s because there are no volumes in it any longer", pset.getLabel()));
        } else if (volumesToDelete.size() != pset.getVolumes().size()) {
            // For debugging: log conditions that caused us to not delete the protection set
            _log.info(String.format("Not deleting protection %s because there are %d volumes to delete in the request, however there are %d volumes in the pset", pset.getLabel(), RPHelper.getVolumesToDelete(sourceVolumeURIs, _dbClient).size(), pset.getVolumes().size()));
        }
    }
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Volume(com.emc.storageos.db.client.model.Volume) HashSet(java.util.HashSet)

Example 12 with ProtectionSet

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

the class BlockService method getProtectionSet.

/**
 * Get info for protectionSet including owner, parent protectionSet, and child protectionSets
 *
 * @prereq none
 *
 * @param id
 *            Volume identifier
 * @param pid
 *            the URN of a ViPR ProtectionSet
 *
 * @brief Show protection set
 * @return ProtectionSet details
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/protection-sets/{pid}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public ProtectionSetRestRep getProtectionSet(@PathParam("id") URI id, @PathParam("pid") URI pid) {
    validateProtectionSetUri(id, pid);
    _log.info("Getting protection set for ID: " + pid);
    ProtectionSet protectionSet = queryProtectionSetResource(pid);
    _log.info("Protection set status: " + protectionSet.getProtectionStatus());
    return map(protectionSet);
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) SOURCE_TO_TARGET(com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 13 with ProtectionSet

use of com.emc.storageos.db.client.model.ProtectionSet 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 14 with ProtectionSet

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

the class BlockRecoverPointIngestOrchestrator method createProtectionSet.

/**
 * Create the managed protection set associated with the ingested RP volumes.
 * Also, as a side-effect, insert the protection set ID into each of the impacted volumes.
 *
 * @param volumeContext the RecoverPointVolumeIngestionContext for the volume currently being ingested
 * @return a new protection set object
 */
private ProtectionSet createProtectionSet(RecoverPointVolumeIngestionContext volumeContext) {
    UnManagedProtectionSet umpset = volumeContext.getUnManagedProtectionSet();
    ProtectionSet pset = VolumeIngestionUtil.findOrCreateProtectionSet(volumeContext, volumeContext.getUnmanagedVolume(), umpset, _dbClient);
    volumeContext.setManagedProtectionSet(pset);
    return pset;
}
Also used : ProtectionSet(com.emc.storageos.db.client.model.ProtectionSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)

Example 15 with ProtectionSet

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

Aggregations

ProtectionSet (com.emc.storageos.db.client.model.ProtectionSet)57 Volume (com.emc.storageos.db.client.model.Volume)39 URI (java.net.URI)30 NamedURI (com.emc.storageos.db.client.model.NamedURI)26 ArrayList (java.util.ArrayList)25 StringSet (com.emc.storageos.db.client.model.StringSet)18 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)14 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)13 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)11 URISyntaxException (java.net.URISyntaxException)10 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)9 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)9 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)9 RecoverPointClient (com.emc.storageos.recoverpoint.impl.RecoverPointClient)9 HashSet (java.util.HashSet)8 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 RecoverPointException (com.emc.storageos.recoverpoint.exceptions.RecoverPointException)7 FunctionalAPIActionFailedException_Exception (com.emc.fapiclient.ws.FunctionalAPIActionFailedException_Exception)6 FunctionalAPIInternalError_Exception (com.emc.fapiclient.ws.FunctionalAPIInternalError_Exception)6 RecoverPointVolumeIngestionContext (com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext)6