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()));
}
}
}
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);
}
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);
}
}
}
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;
}
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;
}
Aggregations