use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext in project coprhd-controller by CoprHD.
the class VolumeIngestionUtil method validateExportMaskMatchesVplexCluster.
/**
* Validates that the given UnManagedExportMask exists on the same VPLEX Cluster
* as the VirtualArray in the ingestion request. The cluster name is actually
* set by the BlockVplexIngestOrchestrator in order to re-use the cluster-id-to-name
* cache, avoiding a expensive call to get cluster name info from the VPLEX API.
*
* @param requestContext the current IngestionRequestContext
* @param unManagedVolume the current UnManagedVolume being processed for exports
* @param unManagedExportMask the current UnManagdExportMask being processed
*
* @return true if the mask exists on the same VPLEX cluster as the ingestion request VirtualArray
*/
public static boolean validateExportMaskMatchesVplexCluster(IngestionRequestContext requestContext, UnManagedVolume unManagedVolume, UnManagedExportMask unManagedExportMask) {
VolumeIngestionContext volumeContext = requestContext.getRootIngestionRequestContext().getProcessedVolumeContext(unManagedVolume.getNativeGuid());
if (volumeContext == null) {
// just get the current one
volumeContext = requestContext.getVolumeContext();
}
if (volumeContext != null && volumeContext instanceof RpVplexVolumeIngestionContext) {
volumeContext = ((RpVplexVolumeIngestionContext) volumeContext).getVplexVolumeIngestionContext();
}
if (volumeContext != null && volumeContext instanceof VplexVolumeIngestionContext) {
String clusterName = ((VplexVolumeIngestionContext) volumeContext).getVirtualVolumeVplexClusterName();
String maskingViewPath = unManagedExportMask.getMaskingViewPath();
_logger.info("cluster name is {} and masking view path is {}", clusterName, maskingViewPath);
if (clusterName != null && maskingViewPath != null) {
String startOfPath = VPlexApiConstants.URI_CLUSTERS_RELATIVE + clusterName;
// for this ingestion request) overlaps the masking view path, then we are on the right vplex cluster
if (maskingViewPath.startsWith(startOfPath)) {
_logger.info("\tUnManagedExportMask {} is on VPLEX cluster {} and will be processed now", unManagedExportMask.getMaskName(), clusterName);
return true;
}
}
}
_logger.warn("\tUnManagedExportMask {} is not on the right VPLEX cluster for this ingestion request", unManagedExportMask.getMaskName());
return false;
}
use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext in project coprhd-controller by CoprHD.
the class BlockRecoverPointIngestOrchestrator method clearReplicaFlagsInIngestionContext.
/**
* Clear the flags of replicas which have been updated during the ingestion process
*
* @param volumeContext
* @param volumes RP volumes
*/
private void clearReplicaFlagsInIngestionContext(RecoverPointVolumeIngestionContext volumeContext, List<Volume> volumes) {
for (Set<DataObject> updatedObjects : volumeContext.getDataObjectsToBeUpdatedMap().values()) {
for (DataObject updatedObject : updatedObjects) {
if (updatedObject instanceof BlockMirror || updatedObject instanceof BlockSnapshot || updatedObject instanceof BlockSnapshotSession || (updatedObject instanceof Volume && !NullColumnValueGetter.isNullURI(((Volume) updatedObject).getAssociatedSourceVolume()))) {
_logger.info("Clearing internal volume flag of replica {} of RP volume ", updatedObject.getLabel());
updatedObject.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
}
}
}
// 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.
List<String> rpVolumes = new ArrayList<String>();
for (Volume volume : volumes) {
rpVolumes.add(volume.getId().toString());
if (RPHelper.isVPlexVolume(volume, _dbClient) && volumeContext instanceof RpVplexVolumeIngestionContext) {
VplexVolumeIngestionContext vplexVolumeContext = ((RpVplexVolumeIngestionContext) volumeContext.getVolumeContext()).getVplexVolumeIngestionContext();
StringSet associatedVolumes = vplexVolumeContext.getAssociatedVolumeIds(volume);
rpVolumes.addAll(associatedVolumes);
}
}
for (VolumeIngestionContext volumeIngestionContext : volumeContext.getRootIngestionRequestContext().getProcessedUnManagedVolumeMap().values()) {
if (volumeIngestionContext instanceof IngestionRequestContext) {
for (Set<DataObject> objectsToBeUpdated : ((IngestionRequestContext) volumeIngestionContext).getDataObjectsToBeUpdatedMap().values()) {
for (DataObject o : objectsToBeUpdated) {
if (o instanceof BlockSnapshot && rpVolumes.contains(((BlockSnapshot) o).getParent().getURI().toString())) {
_logger.info("Clearing internal volume flag of BlockSnapshot {} of RP volume ", o.getLabel());
o.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
} else if (o instanceof BlockSnapshotSession && rpVolumes.contains(((BlockSnapshotSession) o).getParent().getURI().toString())) {
_logger.info("Clearing internal volume flag of BlockSnapshotSession {} of RP volume ", o.getLabel());
o.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
}
}
}
}
}
}
use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext in project coprhd-controller by CoprHD.
the class BlockVplexVolumeIngestOrchestrator method ingestBackendExportMasks.
/**
* Ingests the export masks between the backend storage arrays and the
* VPLEX for the backend storage volumes.
*
* Calls ingestExportMasks by getting a nested IngestStrategy
* for each backend volume or replica from the IngestStrategyFactory.
*
* @param system the VPLEX storage system
* @param vPool the virtual pool for ingestion
* @param virtualArray the virtual array for ingestion
* @param tenant the tenant for ingestion
* @param unManagedVolumesToBeDeleted unmanaged volumes that will be marked for deletion
* @param taskStatusMap a map of task statuses
* @param context the VplexBackendIngestionContext for the parent virtual volume
*
* @throws IngestionException
*/
private void ingestBackendExportMasks(IngestionRequestContext requestContext, VplexVolumeIngestionContext backendRequestContext) throws IngestionException {
// process masking for any successfully processed UnManagedVolumes
for (Entry<String, VolumeIngestionContext> entry : backendRequestContext.getProcessedUnManagedVolumeMap().entrySet()) {
String unManagedVolumeGUID = entry.getKey();
VolumeIngestionContext volumeContext = entry.getValue();
UnManagedVolume processedUnManagedVolume = volumeContext.getUnmanagedVolume();
VirtualArray virtualArray = backendRequestContext.getVarray(processedUnManagedVolume);
VirtualPool vPool = backendRequestContext.getVpool(processedUnManagedVolume);
if (processedUnManagedVolume.getUnmanagedExportMasks().isEmpty()) {
String reason = "the backend volume has no unmanaged export masks " + processedUnManagedVolume.getLabel();
_logger.warn(reason);
continue;
}
_logger.info("ingesting VPLEX backend export mask(s) for unmanaged volume " + processedUnManagedVolume);
String createdObjectGuid = unManagedVolumeGUID.replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
BlockObject processedBlockObject = backendRequestContext.getBlockObjectsToBeCreatedMap().get(createdObjectGuid);
if (processedBlockObject == null) {
String reason = "The ingested block object is null. Skipping ingestion of export masks.";
throw IngestionException.exceptions.generalVolumeException(processedUnManagedVolume.getLabel(), reason);
}
// and it will have the correct virtual array and virtual pool already set on it
if (backendRequestContext.isDistributed()) {
// a backend volume can only be a Volume BlockObject type, so this is safe
Volume backendVolume = ((Volume) processedBlockObject);
virtualArray = _dbClient.queryObject(VirtualArray.class, backendVolume.getVirtualArray());
vPool = _dbClient.queryObject(VirtualPool.class, backendVolume.getVirtualPool());
if (virtualArray == null) {
throw IngestionException.exceptions.failedToIngestVplexBackend("Could not find virtual array for backend volume " + backendVolume.getLabel());
}
if (vPool == null) {
throw IngestionException.exceptions.failedToIngestVplexBackend("Could not find virtual pool for backend volume " + backendVolume.getLabel());
}
}
try {
// assuming only one export mask for this volume between the backend array and VPLEX
int uemCount = 0;
for (String uri : processedUnManagedVolume.getUnmanagedExportMasks()) {
if (uemCount++ > 1) {
_logger.warn("more than one unmanaged export mask found on this backend volume");
}
UnManagedExportMask uem = _dbClient.queryObject(UnManagedExportMask.class, URI.create(uri));
_logger.info("preparing to ingest backend unmanaged export mask {}", uem.getMaskName());
// find the associated storage system
URI storageSystemUri = processedUnManagedVolume.getStorageSystemUri();
StorageSystem associatedSystem = _dbClient.queryObject(StorageSystem.class, storageSystemUri);
// collect the initiators in this backend mask
List<URI> initUris = new ArrayList<URI>();
for (String initUri : uem.getKnownInitiatorUris()) {
initUris.add(URI.create(initUri));
}
List<Initiator> initiators = _dbClient.queryObject(Initiator.class, initUris);
backendRequestContext.setDeviceInitiators(initiators);
// find or create the backend export group
ExportGroup exportGroup = this.findOrCreateExportGroup(backendRequestContext.getRootIngestionRequestContext(), associatedSystem, initiators, virtualArray.getId(), backendRequestContext.getBackendProject().getId(), backendRequestContext.getTenant().getId(), DEFAULT_BACKEND_NUMPATHS, uem);
if (null == exportGroup.getId()) {
backendRequestContext.setExportGroupCreated(true);
exportGroup.setId(URIUtil.createId(ExportGroup.class));
}
backendRequestContext.setExportGroup(exportGroup);
// find the ingest export strategy and call into for this unmanaged export mask
IngestExportStrategy ingestStrategy = ingestStrategyFactory.buildIngestExportStrategy(processedUnManagedVolume);
BlockObject blockObject = ingestStrategy.ingestExportMasks(processedUnManagedVolume, processedBlockObject, backendRequestContext);
if (null == blockObject) {
// ingestion did not succeed, but in case it wasn't, throw one
throw IngestionException.exceptions.generalVolumeException(processedUnManagedVolume.getLabel(), "check the logs for more details");
} else {
backendRequestContext.getObjectsIngestedByExportProcessing().add(blockObject);
}
backendRequestContext.getVplexBackendExportGroupMap().put(blockObject, exportGroup);
}
} catch (Exception ex) {
_logger.error(ex.getLocalizedMessage());
throw ex;
}
}
}
use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext in project coprhd-controller by CoprHD.
the class BaseIngestionRequestContext method findExportGroup.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext#findExportGroup(java.lang.
* String)
*/
@Override
public ExportGroup findExportGroup(String exportGroupLabel, URI project, URI varray, URI computeResource, String resourceType) {
if (exportGroupLabel != null) {
ExportGroup localExportGroup = getExportGroup();
if (null != localExportGroup && exportGroupLabel.equals(localExportGroup.getLabel())) {
if (VolumeIngestionUtil.verifyExportGroupMatches(localExportGroup, exportGroupLabel, project, varray, computeResource, resourceType)) {
_logger.info("Found existing local ExportGroup {} in base ingestion request context", localExportGroup.forDisplay());
return localExportGroup;
}
}
ExportGroup nestedExportGroup = null;
for (VolumeIngestionContext volumeContext : getProcessedUnManagedVolumeMap().values()) {
if (volumeContext instanceof IngestionRequestContext) {
nestedExportGroup = ((IngestionRequestContext) volumeContext).findExportGroup(exportGroupLabel, project, varray, computeResource, resourceType);
}
if (null != nestedExportGroup) {
if (VolumeIngestionUtil.verifyExportGroupMatches(nestedExportGroup, exportGroupLabel, project, varray, computeResource, resourceType)) {
_logger.info("Found existing nested ExportGroup {} in volume context {}", nestedExportGroup.forDisplay(), volumeContext.getUnmanagedVolume().forDisplay());
return nestedExportGroup;
}
}
}
}
_logger.info("Could not find existing export group for label " + exportGroupLabel);
return null;
}
use of com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext in project coprhd-controller by CoprHD.
the class RecoverPointVolumeIngestionContext method findExportGroup.
/*
* (non-Javadoc)
*
* @see com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext#findExportGroup(java.lang.
* String)
*/
@Override
public ExportGroup findExportGroup(String exportGroupLabel, URI project, URI varray, URI computeResource, String resourceType) {
if (exportGroupLabel != null) {
for (ExportGroup localExportGroup : getRpExportGroupMap().keySet()) {
if (null != localExportGroup && exportGroupLabel.equals(localExportGroup.getLabel())) {
if (VolumeIngestionUtil.verifyExportGroupMatches(localExportGroup, exportGroupLabel, project, varray, computeResource, resourceType)) {
_logger.info("Found existing local ExportGroup {} in RP ingestion request context", localExportGroup.forDisplay());
return localExportGroup;
}
}
}
}
ExportGroup nestedExportGroup = null;
for (VolumeIngestionContext volumeContext : getProcessedUnManagedVolumeMap().values()) {
if (volumeContext instanceof IngestionRequestContext) {
nestedExportGroup = ((IngestionRequestContext) volumeContext).findExportGroup(exportGroupLabel, project, varray, computeResource, resourceType);
}
if (null != nestedExportGroup) {
if (VolumeIngestionUtil.verifyExportGroupMatches(nestedExportGroup, exportGroupLabel, project, varray, computeResource, resourceType)) {
_logger.info("Found existing nested ExportGroup {} in volume context {}", nestedExportGroup.forDisplay(), volumeContext.getUnmanagedVolume().forDisplay());
return nestedExportGroup;
}
}
}
_logger.info("Could not find existing export group for label " + exportGroupLabel);
return null;
}
Aggregations