use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask 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;
}
}
}
Aggregations