Search in sources :

Example 66 with StoragePort

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

the class VplexExportGroupServiceApiImpl method validateVarrayStoragePorts.

/**
 * Validate varray ports during Export Group Create. If varray
 * contains ports from both Vplex Cluster 1 and Cluster 2 thats an invalid
 * network configuration. It could be one or more network within a varray.
 * If initiators of a host are in two networks then vplex storage ports from
 * both networks are taken into account to check if ports belong to both
 * Vplex Cluster 1 and Cluster 2.
 *
 * @param storageSystemURIs vplex storageSystem URIs
 * @param varray source VirtualArray
 * @param allHosts
 * @throws InternalException
 */
@Override
public void validateVarrayStoragePorts(Set<URI> storageSystemURIs, VirtualArray varray, List<URI> allHosts) throws InternalException {
    try {
        // Get VirtualArray Storage ports by Network.
        Map<Network, Set<StoragePort>> networkToPortsMap = getVirtualArrayTaggedPortsByNework(varray.getId());
        Map<URI, Set<URI>> vplexCluster1ports = new HashMap<URI, Set<URI>>();
        Map<URI, Set<URI>> vplexCluster2ports = new HashMap<URI, Set<URI>>();
        Map<URI, StorageSystem> storageSystems = new HashMap<URI, StorageSystem>();
        // Separate cluster1 and cluster 2 ports of the provided vplex storageSystemURIs
        for (URI uri : storageSystemURIs) {
            StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, uri);
            URIQueryResultList storagePortURIs = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(storageSystem.getId()), storagePortURIs);
            final String cluster1 = "1";
            final String cluster2 = "2";
            Set<URI> cluster1StoragePorts = new HashSet<URI>();
            Set<URI> cluster2StoragePorts = new HashSet<URI>();
            Iterator<URI> storagePortsIter = storagePortURIs.iterator();
            while (storagePortsIter.hasNext()) {
                URI storagePortURI = storagePortsIter.next();
                StoragePort storagePort = _dbClient.queryObject(StoragePort.class, storagePortURI);
                if (storagePort != null && !storagePort.getInactive() && storagePort.getRegistrationStatus().equals(DiscoveredDataObject.RegistrationStatus.REGISTERED.name()) && !storagePort.getDiscoveryStatus().equalsIgnoreCase(DiscoveryStatus.NOTVISIBLE.name())) {
                    // after director- in this string determines vplex cluster
                    if (storagePort.getPortGroup() != null) {
                        String[] tokens = storagePort.getPortGroup().split("-");
                        if (cluster1.equals(tokens[1])) {
                            cluster1StoragePorts.add(storagePort.getId());
                        } else if (cluster2.equals(tokens[1])) {
                            cluster2StoragePorts.add(storagePort.getId());
                        } else {
                            _log.warn("Could not determine cluster for storageport:" + storagePort.getPortNetworkId() + " " + storagePort.getId() + " Port group is:" + storagePort.getPortGroup());
                        }
                    } else {
                        _log.warn("Could not determine cluster for storageport:" + storagePort.getPortNetworkId() + " " + storagePort.getId());
                    }
                }
            }
            vplexCluster1ports.put(uri, cluster1StoragePorts);
            vplexCluster2ports.put(uri, cluster2StoragePorts);
            storageSystems.put(uri, storageSystem);
        }
        for (URI hostUri : allHosts) {
            Map<URI, StoragePort> networkStoragePortsForHost = getNetworkTaggedPortsForHost(hostUri, networkToPortsMap);
            // clusters of the vplex.
            for (URI uri : storageSystemURIs) {
                Set<URI> intersection1 = new HashSet<URI>(networkStoragePortsForHost.keySet());
                Set<URI> intersection2 = new HashSet<URI>(networkStoragePortsForHost.keySet());
                intersection1.retainAll(vplexCluster1ports.get(uri));
                intersection2.retainAll(vplexCluster2ports.get(uri));
                // if we have ports in both then its a mix ports from cluster 1 and cluster 2
                if (!intersection1.isEmpty() && !intersection2.isEmpty()) {
                    Map<URI, String> cluster1Ports = new HashMap<URI, String>();
                    Map<URI, String> cluster2Ports = new HashMap<URI, String>();
                    // which belong in the same varray
                    for (URI uriIntersection1 : intersection1) {
                        if (networkStoragePortsForHost.get(uriIntersection1) != null) {
                            cluster1Ports.put(uriIntersection1, networkStoragePortsForHost.get(uriIntersection1).getPortNetworkId());
                        }
                    }
                    for (URI uriIntersection2 : intersection2) {
                        if (networkStoragePortsForHost.get(uriIntersection2) != null) {
                            cluster2Ports.put(uriIntersection2, networkStoragePortsForHost.get(uriIntersection2).getPortNetworkId());
                        }
                    }
                    Host host = _dbClient.queryObject(Host.class, hostUri);
                    _log.error("Varray " + varray.getLabel() + " has storageports from Cluster 1 and Cluster 2 of the Vplex " + storageSystems.get(uri).getLabel() + " " + storageSystems.get(uri).getId().toString() + ". This is detected for the host " + host.getHostName() + "\n Cluster 1 storageports in varray are" + cluster1Ports + "\n Cluster 2 storageports in varray are" + cluster2Ports);
                    throw APIException.badRequests.invalidVarrayNetworkConfiguration(varray.getLabel(), storageSystems.get(uri).getLabel());
                }
            }
        }
        _log.info("Done validating vplex cluster 1 and 2 ports for the Varray:" + varray.getLabel());
    } catch (InternalException ex) {
        _log.error(ex.getLocalizedMessage());
        throw (ex);
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Network(com.emc.storageos.db.client.model.Network) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 67 with StoragePort

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

the class BlockRecoverPointIngestOrchestrator method performRPExportIngestion.

/**
 * RecoverPoint volumes are expected to have export masks where the volume is exported to
 * a RecoverPoint site. Therefore every RP volume (sources, targets, journals) will need to
 * go through this code and have their export mask ingested. Even if the mask has already been
 * ingested by a previous volume ingestion, this method still needs to update the ExportGroup and
 * ExportMask objects to reflect the newly ingested volume as part of its management.
 *
 * @param volumeContext the RecoverPointVolumeIngestionContext for the volume currently being ingested
 * @param unManagedVolume unmanaged volume
 * @param volume managed volume
 * @return managed volume with export ingested
 */
private void performRPExportIngestion(IngestionRequestContext parentRequestContext, RecoverPointVolumeIngestionContext volumeContext, UnManagedVolume unManagedVolume, Volume volume) {
    _logger.info("starting RecoverPoint export ingestion for volume {}", volume.forDisplay());
    Project project = volumeContext.getProject();
    ProtectionSystem protectionSystem = _dbClient.queryObject(ProtectionSystem.class, volume.getProtectionController());
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, volume.getStorageController());
    List<UnManagedExportMask> unManagedRPExportMasks = findUnManagedRPExportMask(protectionSystem, unManagedVolume);
    if (unManagedRPExportMasks.isEmpty()) {
        _logger.error("Could not find any unmanaged export masks associated with volume: " + unManagedVolume.getLabel());
        throw IngestionException.exceptions.noUnManagedExportMaskFound(unManagedVolume.getNativeGuid());
    }
    // Keep a map for internal site name name and varray
    Map<String, VirtualArray> internalSiteToVarrayMap = new HashMap<String, VirtualArray>();
    internalSiteToVarrayMap.put(volume.getInternalSiteName(), volumeContext.getVarray(unManagedVolume));
    // If this is a MetroPoint volume we're going to have multiple ExportMasks/ExportGroups to deal with.
    // We'll need to query the backend volumes for extra info to populate internalSiteToVarrayMap so
    // we can properly line up the ExportMasks/ExportGroups.
    boolean metropoint = RPHelper.isMetroPointVolume(_dbClient, volume);
    if (metropoint) {
        // We need the VPLEX ingest context to get the backend volume info
        VplexVolumeIngestionContext vplexVolumeContext = ((RpVplexVolumeIngestionContext) volumeContext.getVolumeContext()).getVplexVolumeIngestionContext();
        for (String associatedVolumeIdStr : vplexVolumeContext.getAssociatedVolumeIds(volume)) {
            // Find the associated volumes using the context maps or the db if they are already there
            Volume associatedVolume = VolumeIngestionUtil.findVolume(_dbClient, vplexVolumeContext.getBlockObjectsToBeCreatedMap(), vplexVolumeContext.getDataObjectsToBeUpdatedMap(), associatedVolumeIdStr);
            String internalSiteName = associatedVolume.getInternalSiteName();
            // If we don't already have an entry for this internal site name, let's add it now.
            if (!internalSiteToVarrayMap.containsKey(internalSiteName)) {
                internalSiteToVarrayMap.put(internalSiteName, _dbClient.queryObject(VirtualArray.class, associatedVolume.getVirtualArray()));
            }
        }
    }
    // this will more than likely only loop once.
    for (Entry<String, VirtualArray> entry : internalSiteToVarrayMap.entrySet()) {
        String internalSiteName = entry.getKey();
        VirtualArray virtualArray = entry.getValue();
        UnManagedExportMask em = null;
        if (metropoint) {
            // Since we're flagged for MetroPoint we need to determine which ExportMask to use.
            // We need the MetroPoint volume to be added to BOTH ExportGroups that represent the
            // two Storage Views on VPLEX for cluster-1 and cluster-2.
            // So let's use the varray to find the cluster we're looking for on this pass and match
            // it to the maskingViewParth of the UnManagedExportMask.
            // This should line things up roughly as:
            // VPLEX Storage View 1 -> VPLEX Cluster1 + RPA1
            // VPLEX Storage View 2 -> VPLEX Cluster2 + RPA2
            String vplexCluster = ConnectivityUtil.getVplexClusterForVarray(virtualArray.getId(), storageSystem.getId(), _dbClient);
            // First try and match based on UnManagedExportMask ports
            for (UnManagedExportMask exportMask : unManagedRPExportMasks) {
                for (String portUri : exportMask.getKnownStoragePortUris()) {
                    StoragePort port = _dbClient.queryObject(StoragePort.class, URI.create(portUri));
                    if (port != null && !port.getInactive()) {
                        String vplexClusterForMask = ConnectivityUtil.getVplexClusterOfPort(port);
                        if (vplexCluster.equals(vplexClusterForMask)) {
                            em = exportMask;
                            break;
                        }
                    }
                }
                if (em != null) {
                    break;
                }
            }
            if (em == null) {
                // It really shouldn't come to this, but leaving this code just in case.
                for (UnManagedExportMask exportMask : unManagedRPExportMasks) {
                    if (exportMask.getMaskingViewPath().contains("cluster-" + vplexCluster)) {
                        em = exportMask;
                        break;
                    }
                }
            }
        } else {
            em = unManagedRPExportMasks.get(0);
        }
        // If the mask for ingested volume is in a mask that contains JOURNAL keyword, make sure the ExportGroup created contains
        // that internal flag.
        boolean isJournalExport = false;
        if (em.getMaskName().toLowerCase().contains(VolumeIngestionUtil.RP_JOURNAL)) {
            isJournalExport = true;
        }
        String exportGroupGeneratedName = RPHelper.generateExportGroupName(protectionSystem, storageSystem, internalSiteName, virtualArray, isJournalExport);
        ExportGroup exportGroup = VolumeIngestionUtil.verifyExportGroupExists(parentRequestContext, exportGroupGeneratedName, project.getId(), em.getKnownInitiatorUris(), virtualArray.getId(), _dbClient);
        boolean exportGroupCreated = false;
        if (null == exportGroup) {
            exportGroupCreated = true;
            Integer numPaths = em.getZoningMap().size();
            _logger.info("Creating Export Group with label {}", em.getMaskName());
            exportGroup = RPHelper.createRPExportGroup(exportGroupGeneratedName, virtualArray, project, numPaths, isJournalExport);
        }
        if (null != exportGroup) {
            // check if the ExportGroup has already been fetched
            ExportGroup loadedExportGroup = parentRequestContext.findExportGroup(exportGroup.getLabel(), project.getId(), virtualArray.getId(), null, null);
            if (null != loadedExportGroup) {
                exportGroup = loadedExportGroup;
            }
        }
        volumeContext.setExportGroup(exportGroup);
        volumeContext.setExportGroupCreated(exportGroupCreated);
        volumeContext.getRpExportGroupMap().put(exportGroup, exportGroupCreated);
        // set RP device initiators to be used as the "host" for export mask ingestion
        List<Initiator> initiators = new ArrayList<Initiator>();
        Iterator<Initiator> initiatorItr = _dbClient.queryIterativeObjects(Initiator.class, URIUtil.toURIList(em.getKnownInitiatorUris()));
        while (initiatorItr.hasNext()) {
            initiators.add(initiatorItr.next());
        }
        volumeContext.setDeviceInitiators(initiators);
        // find the ingest export strategy and call into for this unmanaged export mask
        IngestExportStrategy ingestStrategy = ingestStrategyFactory.buildIngestExportStrategy(unManagedVolume);
        volume = ingestStrategy.ingestExportMasks(unManagedVolume, volume, volumeContext);
        if (null == volume) {
            // ingestion did not succeed, but in case it wasn't, throw one
            throw IngestionException.exceptions.generalVolumeException(unManagedVolume.getLabel(), "check the logs for more details");
        }
    }
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) HashMap(java.util.HashMap) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) Project(com.emc.storageos.db.client.model.Project) 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) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 68 with StoragePort

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

the class UnManagedFilesystemService method returnAllPortsforStgArrayAndVArray.

/**
 * @param system
 * @return List of StoragePorts for a StorageSystems in a Virtual Array.
 */
private List<URI> returnAllPortsforStgArrayAndVArray(StorageSystem system, List<URI> storagePortsForVArray) {
    List<URI> sPorts = new ArrayList<URI>();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(system.getId()), storagePortURIs);
    Iterator<URI> storagePortIter = storagePortURIs.iterator();
    while (storagePortIter.hasNext()) {
        StoragePort port = _dbClient.queryObject(StoragePort.class, storagePortIter.next());
        for (URI spVArray : storagePortsForVArray) {
            if (port.getId().toString().equals(spVArray.toString())) {
                sPorts.add(port.getId());
            }
        }
    }
    return sPorts;
}
Also used : ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 69 with StoragePort

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

the class ExportUtils method getInitiatorPorts.

private static List<StoragePort> getInitiatorPorts(ExportMask exportMask, Initiator initiator, List<StoragePort> ports, DbClient dbClient) {
    List<StoragePort> initiatorPorts = new ArrayList<StoragePort>();
    // Determine if WWN. Don't use the zoning map for iSCSI or other protocols.
    boolean isWWN = WWNUtility.isValidWWN(initiator.getInitiatorPort());
    if (isWWN) {
        if (exportMask.getZoningMap() != null) {
            // ExportMask specifies zoning
            initiatorPorts = getZonedPorts(initiator, ports, exportMask.getZoningMap());
        }
    } else {
        // for iscsi and other ip initiators, get all ports in the network
        NetworkLite network = NetworkUtil.getEndpointNetworkLite(initiator.getInitiatorPort(), dbClient);
        if (network != null && network.getTransportType().equals(TransportType.IP.toString())) {
            for (StoragePort port : ports) {
                if (network.getId().equals(port.getNetwork())) {
                    initiatorPorts.add(port);
                }
            }
        }
    }
    return initiatorPorts;
}
Also used : NetworkLite(com.emc.storageos.util.NetworkLite) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList)

Example 70 with StoragePort

use of com.emc.storageos.db.client.model.StoragePort 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)

Aggregations

StoragePort (com.emc.storageos.db.client.model.StoragePort)477 URI (java.net.URI)285 ArrayList (java.util.ArrayList)261 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)143 HashMap (java.util.HashMap)134 List (java.util.List)130 NetworkLite (com.emc.storageos.util.NetworkLite)110 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)107 StringSet (com.emc.storageos.db.client.model.StringSet)92 PortAllocationContext (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)84 HashSet (java.util.HashSet)81 Initiator (com.emc.storageos.db.client.model.Initiator)78 Map (java.util.Map)64 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)62 StoragePool (com.emc.storageos.db.client.model.StoragePool)51 IOException (java.io.IOException)48 StringMap (com.emc.storageos.db.client.model.StringMap)45 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)42 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)34