Search in sources :

Example 31 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class MaskPerHostIngestOrchestrator method getExportMaskAlreadyCreated.

/*
     * (non-Javadoc)
     *
     * @see
     * com.emc.storageos.api.service.impl.resource.blockingestorchestration.BlockIngestExportOrchestrator#getExportMaskAlreadyCreated(com.
     * emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask,
     * com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext)
     */
@Override
protected ExportMask getExportMaskAlreadyCreated(UnManagedExportMask mask, IngestionRequestContext requestContext, DbClient dbClient) {
    List<URI> initiatorUris = new ArrayList<URI>(Collections2.transform(mask.getKnownInitiatorUris(), CommonTransformerFunctions.FCTN_STRING_TO_URI));
    List<ExportMask> exportMasks = requestContext.findAllNewExportMasks();
    for (URI ini : initiatorUris) {
        for (ExportMask createdMask : exportMasks) {
            if (null != createdMask && createdMask.getInitiators() != null && createdMask.getInitiators().contains(ini.toString())) {
                if (null != createdMask.getStorageDevice() && createdMask.getStorageDevice().equals(mask.getStorageSystemUri())) {
                    _logger.info("Found already-created ExportMask {} matching UnManagedExportMask initiator {} and storage system {}", createdMask.getMaskName(), ini, mask.getStorageSystemUri());
                    return createdMask;
                }
            }
        }
    }
    _logger.info("No existing created mask found for UnManagedExportMask {}", mask.getMaskName());
    return null;
}
Also used : UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 32 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class MultipleMaskPerHostIngestOrchestrator method getExportMaskAlreadyCreated.

/* (non-Javadoc)
     * @see com.emc.storageos.api.service.impl.resource.blockingestorchestration.BlockIngestExportOrchestrator#getExportMaskAlreadyCreated(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask, com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext)
     */
@Override
protected ExportMask getExportMaskAlreadyCreated(UnManagedExportMask mask, IngestionRequestContext requestContext, DbClient dbClient) {
    List<ExportMask> exportMasks = requestContext.findAllNewExportMasks();
    for (ExportMask createdMask : exportMasks) {
        // COP-18184 : Check if the initiators are also matching
        if (null != createdMask && createdMask.getInitiators() != null && createdMask.getInitiators().containsAll(mask.getKnownInitiatorUris())) {
            if (VolumeIngestionUtil.hasIncorrectMaskPathForVplex(mask, createdMask, dbClient)) {
                continue;
            }
            _logger.info("Found already-created ExportMask {} matching all initiators of UnManagedExportMask {}", createdMask.getMaskName(), mask.getMaskName());
            return createdMask;
        }
    }
    _logger.info("No existing created mask found for UnManagedExportMask {}", mask.getMaskName());
    return null;
}
Also used : UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) ExportMask(com.emc.storageos.db.client.model.ExportMask)

Example 33 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class ExportUtils method getItlsForInitiator.

/**
 * Gets the list of exports (ITL) for one initiator. The list contains all the volumes and snapshots
 * that are exported to the initiator together with the target ports and the zones when zoning
 * was performed.
 *
 * @param initiator the initiator
 * @param dbClient an instance of {@link DbClient}
 * @param permissionsHelper an instance of {@link PermissionsHelper}
 * @param user a pointer to the logged in user
 * @return the list of ITLs for one initiator
 */
public static ITLRestRepList getItlsForInitiator(Initiator initiator, DbClient dbClient, PermissionsHelper permissionsHelper, StorageOSUser user) throws DatabaseException {
    ITLRestRepList list = new ITLRestRepList();
    Map<ExportMask, List<ExportGroup>> exportMasks = null;
    exportMasks = getInitiatorExportMasks(initiator, dbClient, permissionsHelper, user);
    BlockObject blockObject = null;
    List<StoragePort> ports = null;
    List<StoragePort> initiatorPorts = null;
    Map<StoragePort, List<FCZoneReference>> zoneRefs = null;
    String hlu = "";
    Map<String, BlockObject> blockObjects = getBlockObjectsForMasks(exportMasks.keySet(), dbClient);
    for (ExportMask exportMask : exportMasks.keySet()) {
        _log.info("Finding ITLs for initiator {} in export mask {}", initiator.getInitiatorPort(), exportMask.getMaskName());
        ports = getStoragePorts(exportMask, dbClient);
        initiatorPorts = getInitiatorPorts(exportMask, initiator, ports, dbClient);
        zoneRefs = getInitiatorsZoneReferences(initiator, initiatorPorts, dbClient);
        for (String doUri : exportMask.getVolumes().keySet()) {
            hlu = exportMask.getVolumes().get(doUri);
            blockObject = blockObjects.get(doUri);
            if (blockObject != null) {
                list.getExportList().addAll(getItlsForMaskInitiator(dbClient, exportMasks.get(exportMask), exportMask, initiator, hlu, blockObject, initiatorPorts, zoneRefs));
            }
        }
    }
    _log.info("{} ITLs were found for initiator {}.", list.getExportList().size(), initiator.getInitiatorPort());
    return list;
}
Also used : ExportMask(com.emc.storageos.db.client.model.ExportMask) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 34 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class ExportUtils method getBlockObjectInitiatorTargets.

/**
 * Returns initiators-to-target-storage-ports pairing for all initiators to which
 * the block object (volume or snapshot) was exported.
 *
 * @param id the URN of a ViPR block object
 * @param dbClient dbClient an instance of {@link DbClient}
 * @param idEmbeddedInURL
 * @return initiators-to-target-storage-ports pairing for all initiators to which
 *         the block object (volume or snapshot) was exported.
 */
public static ITLRestRepList getBlockObjectInitiatorTargets(URI id, DbClient dbClient, boolean idEmbeddedInURL) {
    BlockObject blockObject = getBlockObject(id, dbClient);
    ArgValidator.checkEntityNotNull(blockObject, id, idEmbeddedInURL);
    ITLRestRepList list = new ITLRestRepList();
    Map<ExportMask, List<ExportGroup>> exportMasks = getBlockObjectExportMasks(blockObject, dbClient);
    Collection<Initiator> initiators = null;
    List<StoragePort> ports = null;
    List<StoragePort> initiatorPorts = null;
    BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, blockObject.getId());
    if (bo != null) {
        Map<StoragePort, List<FCZoneReference>> zoneRefs = null;
        for (ExportMask exportMask : exportMasks.keySet()) {
            // now process the initiators - Every initiator must see the volume
            initiators = getInitiators(exportMask, dbClient);
            _log.debug("Found {} initiators in export mask {}", initiators.size(), exportMask.getMaskName());
            ports = getStoragePorts(exportMask, dbClient);
            _log.debug("Found {} storage ports in export mask {}", ports.size(), exportMask.getMaskName());
            String hlu = exportMask.getVolumes().get(bo.getId().toString());
            _log.debug("Start pairing initiators and targets in export mask {}.", exportMask.getMaskName());
            for (Initiator initiator : initiators) {
                initiatorPorts = getInitiatorPorts(exportMask, initiator, ports, dbClient);
                zoneRefs = getInitiatorsZoneReferencesForBlockObject(initiator, initiatorPorts, bo, dbClient);
                list.getExportList().addAll(getItlsForMaskInitiator(dbClient, exportMasks.get(exportMask), exportMask, initiator, hlu, blockObject, initiatorPorts, zoneRefs));
            }
        }
    }
    _log.info("{} ITLs were found for block object {}.", list.getExportList().size(), blockObject.getLabel());
    return list;
}
Also used : Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) StoragePort(com.emc.storageos.db.client.model.StoragePort) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 35 with ExportMask

use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.

the class ExportUtils method getBlockObjectExportMasks.

/**
 * Fetches all the export masks in which a block object is member
 *
 * @param blockObject the block object
 * @param dbClient an instance of {@link DbClient}
 * @return a map of export masks in which a block object is member
 */
private static Map<ExportMask, List<ExportGroup>> getBlockObjectExportMasks(BlockObject blockObject, DbClient dbClient) {
    Map<ExportMask, List<ExportGroup>> exportMasks = new HashMap<ExportMask, List<ExportGroup>>();
    ContainmentConstraint constraint = ContainmentConstraint.Factory.getBlockObjectExportGroupConstraint(blockObject.getId());
    // permission are checked by the API service - no need to check again
    List<ExportGroup> exportGroups = getExportGroupsByConstraint(constraint, dbClient, null, null);
    List<ExportMask> masks = getMasksForExportGroups(exportGroups, dbClient);
    // Get the actual export block object associated with the snapshot (if applicable)
    BlockObject bo = Volume.fetchExportMaskBlockObject(dbClient, blockObject.getId());
    if (bo != null) {
        for (ExportMask exportMask : masks) {
            if (exportMask != null && !exportMask.getInactive() && exportMask.hasVolume(bo.getId()) && (exportMask.getInitiators() != null || exportMask.getExistingInitiators() != null)) {
                List<ExportGroup> maskGroups = new ArrayList<ExportGroup>();
                exportMasks.put(exportMask, maskGroups);
                for (ExportGroup group : exportGroups) {
                    if (group.getExportMasks() != null && group.getExportMasks().contains(exportMask.getId().toString())) {
                        maskGroups.add(group);
                    }
                }
            }
        }
        _log.debug("Found {} export masks for block object {}", exportMasks.size(), bo.getLabel());
    }
    return exportMasks;
}
Also used : ExportGroup(com.emc.storageos.db.client.model.ExportGroup) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) HashMap(java.util.HashMap) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Aggregations

ExportMask (com.emc.storageos.db.client.model.ExportMask)368 URI (java.net.URI)274 ArrayList (java.util.ArrayList)224 Initiator (com.emc.storageos.db.client.model.Initiator)155 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)140 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)134 HashMap (java.util.HashMap)128 HashSet (java.util.HashSet)121 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)107 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)102 List (java.util.List)79 StringSet (com.emc.storageos.db.client.model.StringSet)68 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)65 Map (java.util.Map)65 StringMap (com.emc.storageos.db.client.model.StringMap)60 BlockObject (com.emc.storageos.db.client.model.BlockObject)56 NamedURI (com.emc.storageos.db.client.model.NamedURI)56 Workflow (com.emc.storageos.workflow.Workflow)54 Set (java.util.Set)51 Volume (com.emc.storageos.db.client.model.Volume)44