Search in sources :

Example 46 with UnManagedExportMask

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;
        }
    }
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) ExportGroup(com.emc.storageos.db.client.model.ExportGroup) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) Initiator(com.emc.storageos.db.client.model.Initiator) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext) BlockObject(com.emc.storageos.db.client.model.BlockObject) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)46 URI (java.net.URI)33 ArrayList (java.util.ArrayList)26 HashSet (java.util.HashSet)20 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)19 StringSet (com.emc.storageos.db.client.model.StringSet)17 Initiator (com.emc.storageos.db.client.model.Initiator)15 HashMap (java.util.HashMap)14 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)13 ExportMask (com.emc.storageos.db.client.model.ExportMask)8 NamedURI (com.emc.storageos.db.client.model.NamedURI)8 Map (java.util.Map)8 Set (java.util.Set)8 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)7 Volume (com.emc.storageos.db.client.model.Volume)7 StoragePort (com.emc.storageos.db.client.model.StoragePort)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)6 CIMInstance (javax.cim.CIMInstance)5 CIMObjectPath (javax.cim.CIMObjectPath)5