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