Search in sources :

Example 66 with NetworkLite

use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.

the class VplexXtremIOMaskingOrchestrator method getUsablePortsSet.

/**
 * Returns a Set of Storage Ports selected equally across networks. Minimum of 2 and maximum of 4 storage ports.
 * It returns null when all storage ports have been processed and the minimum requirement is not met.
 *
 * @param allocatablePorts
 *            the allocatable ports
 * @param orderedNetworks
 *            the ordered networks
 * @param usedPorts
 *            the used ports
 * @param networkToSelectedXbricks
 * @param xBricksToSelectedSCs
 * @param networkMap
 * @param allocator
 *            Storage Ports Allocator
 * @param sanZoningEnabled
 *            on vArray
 * @return the usable ports set
 */
private Map<URI, List<StoragePort>> getUsablePortsSet(Map<URI, List<StoragePort>> allocatablePorts, List<URI> orderedNetworks, Set<String> usedPorts, Map<String, List<String>> xBricksToSelectedSCs, Map<URI, List<String>> networkToSelectedXbricks, Map<URI, NetworkLite> networkMap, StoragePortsAllocator allocator, boolean sanZoningEnabled, Map<URI, Map<String, Integer>> switchToPortNumber, Map<URI, PortAllocationContext> contextMap) {
    Map<URI, List<StoragePort>> useablePorts = new HashMap<URI, List<StoragePort>>();
    Set<String> usedPortsSet = new HashSet<String>();
    Set<String> portsSelected = new HashSet<String>(usedPorts);
    do {
        int previousSize = usedPortsSet.size();
        Iterator<URI> networkItr = orderedNetworks.iterator();
        while (networkItr.hasNext() && usedPortsSet.size() < MAXIMUM_NUMBER_OF_STORAGE_PORTS_PER_SET) {
            URI networkURI = networkItr.next();
            _log.debug(String.format("network: %s, xBricksToSelectedSCs: %s, networkToSelectedXbricks: %s", networkURI, xBricksToSelectedSCs.entrySet(), networkToSelectedXbricks.get(networkURI)));
            NetworkLite net = networkMap.get(networkURI);
            // Determine if we should check connectivity from the Network's varray.auto_san_zoning
            boolean checkConnectivity = sanZoningEnabled && !StorageProtocol.Transport.IP.name().equals(net.getTransportType());
            Map<String, Integer> switchNumberMap = null;
            PortAllocationContext context = null;
            if (switchToPortNumber != null) {
                switchNumberMap = switchToPortNumber.get(networkURI);
            }
            if (contextMap != null) {
                context = contextMap.get(networkURI);
            }
            StoragePort port = getNetworkPortUniqueXbrick(networkURI, allocatablePorts.get(networkURI), portsSelected, networkToSelectedXbricks, xBricksToSelectedSCs, allocator, checkConnectivity, switchNumberMap, context);
            _log.debug("Port selected {} for network {}", port != null ? port.getPortName() : null, networkURI);
            if (port != null) {
                usedPortsSet.add(port.getPortName());
                portsSelected.add(port.getPortName());
                if (!useablePorts.containsKey(networkURI)) {
                    useablePorts.put(networkURI, new ArrayList<StoragePort>());
                }
                useablePorts.get(networkURI).add(port);
            }
        }
        // If No ports have been selected in this round, then clear the X-bricks map
        if (previousSize == usedPortsSet.size()) {
            xBricksToSelectedSCs.clear();
            networkToSelectedXbricks.clear();
        }
        _log.debug("Ports selected so far : {}", usedPortsSet);
    } while (usedPortsSet.size() < MAXIMUM_NUMBER_OF_STORAGE_PORTS_PER_SET && !isAllPortsLooped(orderedNetworks, allocatablePorts, portsSelected));
    _log.info("Set Done: Ports selected in this set: {}", usedPortsSet);
    if (usedPortsSet.size() < REQUIRED_MINIMUM_NUMBER_OF_STORAGE_PORTS_PER_SET) {
        // requirement not met
        return null;
    }
    // if usedPortsSet.size() >= 2, satisfies minimum requirement, min 2 paths
    // add to all usedPorts list
    usedPorts.addAll(usedPortsSet);
    return useablePorts;
}
Also used : HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) PortAllocationContext(com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)

Example 67 with NetworkLite

use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.

the class NetworkAssociationHelper method setNetworkConnectedVirtualArrays.

public static void setNetworkConnectedVirtualArrays(Network network, boolean cascade, DbClient dbClient) {
    // compute the new virtual arrays
    StringSet newSet = getNetworkConnectedVirtualArrays(network.getId(), network.getRoutedNetworks(), network.getAssignedVirtualArrays(), dbClient);
    // check the new list of virtual arrays is different from the old
    boolean changed = StringSetUtil.isChanged(network.getConnectedVirtualArrays(), newSet);
    if (changed) {
        _log.info("Updating connected virtual arrays for network {}. New virtual arrays {}", network.getId(), newSet);
        network.replaceConnectedVirtualArrays(newSet);
        dbClient.updateObject(network);
        if (cascade) {
            // now update the routed networks
            List<Network> routednetworks = getNetworkRoutedNetworksForUpdate(network, dbClient);
            for (Network routedNetwork : routednetworks) {
                NetworkLite lite = NetworkUtil.getNetworkLite(routedNetwork.getId(), dbClient);
                newSet = getNetworkConnectedVirtualArrays(routedNetwork.getId(), lite.getRoutedNetworks(), lite.getAssignedVirtualArrays(), dbClient);
                _log.info("Updating connected virtual arrays for routed network {}. New virtual arrays {}", network.getId(), newSet);
                routedNetwork.replaceConnectedVirtualArrays(newSet);
                dbClient.updateObject(routedNetwork);
            }
        }
    } else {
        _log.info("The new virtual arrays {} are the same as the existing ones. " + "No update is needed for network {}", newSet, network.getId());
    }
}
Also used : NetworkLite(com.emc.storageos.util.NetworkLite) Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 68 with NetworkLite

use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.

the class NetworkDeviceController method updateAltDeviceid.

/**
 * Ensures every fabricInfo has its altNetworkDevice that is not null when
 * the calling code did not already supply a value for this field.
 *
 * @param fabricInfo the fabric info to be updated
 * @param fabricId the fabric id of the network where zoning will be performed
 * @param fabricWWN the WWN of the network where zoning will be performed
 * @param key the key used to save already retrieved networks in the map
 *            this key is the fabric WWN unless it is null, then it is the fabric id
 * @param fabricId2Network a map where retrieved networks are saved between calls
 *            into this function. This is done to avoid repeated db retrieves of same objects
 */
private void updateAltDeviceid(NetworkFCZoneInfo fabricInfo, String fabricId, String fabricWWN, String key, Map<String, NetworkLite> fabricId2Network) {
    if (fabricInfo != null && fabricInfo.getAltNetworkDeviceId() == null) {
        if (fabricId2Network.get(key) == null) {
            NetworkLite network = NetworkUtil.getNetworkLiteByFabricId(fabricId, fabricWWN, _dbClient);
            if (network != null) {
                fabricId2Network.put(key, network);
                URI id = fabricInfo.getNetworkDeviceId();
                for (String strUri : network.getNetworkSystems()) {
                    if (!strUri.equals(id.toString())) {
                        id = URI.create(strUri);
                        break;
                    }
                }
                fabricInfo.setAltNetworkDeviceId(id);
            }
        }
    }
}
Also used : NetworkLite(com.emc.storageos.util.NetworkLite) URI(java.net.URI)

Example 69 with NetworkLite

use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.

the class NetworkDeviceController method getInitiatorsZoneInfoMap.

/**
 * Given a list of initiators, and a list of ports, for each initiator, find the
 * zones on the network system where the initiator port WWN and the storage port
 * WWN is a member. Returns the results as {@link ZoneInfoMap} which is map
 * of initiator port WWN and storage port WWN keyed by zone-key, where zone-key
 * is the concatenation of the initiator port WWN and the storage port WWN.
 * <p>
 * Note that a zone in the network system can have more than one initiator and one storage port. For such zone, there can be multiple
 * entries in the map, one for each initiator/port pairs.
 * <p>
 * If the initiator is not in a network or no zones could be found for the initiator, there will be no entries for this initiator in the
 * map. An empty map will be returned if no zones could be found for any initiator.
 *
 * @param initiators the list of initiators.
 * @param storagePorts
 * @return an instance of {@link ZoneInfoMap} which is which is map
 *         of initiator port WWN and storage port WWN keyed by zone-key, where zone-key
 *         is the concatenation of the initiator port WWN and the storage port WWN.
 */
public ZoneInfoMap getInitiatorsZoneInfoMap(List<Initiator> initiators, List<StoragePort> storagePorts) {
    ZoneInfoMap zoningMap = new ZoneInfoMap();
    Map<NetworkLite, List<Initiator>> initiatorsByNetworkMap = NetworkUtil.getInitiatorsByNetwork(initiators, _dbClient);
    for (Map.Entry<NetworkLite, List<Initiator>> entry : initiatorsByNetworkMap.entrySet()) {
        if (!Transport.FC.toString().equals(entry.getKey().getTransportType())) {
            continue;
        }
        Map<String, StoragePort> initiatorPortsMap = NetworkUtil.getPortsInNetworkMap(entry.getKey(), storagePorts);
        if (initiatorPortsMap.size() > 0) {
            zoningMap.putAll(getInitiatorsInNetworkZoneInfoMap(entry.getKey(), entry.getValue(), initiatorPortsMap));
        }
    }
    return zoningMap;
}
Also used : NetworkLite(com.emc.storageos.util.NetworkLite) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 70 with NetworkLite

use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.

the class NetworkDeviceController method updateZoningMapForInitiators.

/**
 * Update the zoning map for a newly "accepted" export mask. This applies to
 * brown field scenarios where a export mask was found on the storage array.
 * This function finds the zones of the export mask initiators and
 * existing ports and creates the zoning map between the two sets.
 *
 * @param exportGroup the masking view export group
 * @param exportMask the export mask being updated.
 * @param doPersist a boolean that indicates if the changes should be persisted in the db
 */
public void updateZoningMapForInitiators(ExportGroup exportGroup, ExportMask exportMask, boolean doPersist) {
    if (exportMask.getZoningMap() == null || exportMask.getZoningMap().isEmpty()) {
        Long start = System.currentTimeMillis();
        // possibly the first time this export mask is processed, populate from existing zones
        List<StoragePort> storagePorts = ExportUtils.getStoragePorts(exportMask, _dbClient);
        Set<Initiator> initiators = ExportMaskUtils.getInitiatorsForExportMask(_dbClient, exportMask, Transport.FC);
        Map<NetworkLite, List<Initiator>> initiatorsByNetworkMap = NetworkUtil.getInitiatorsByNetwork(initiators, _dbClient);
        StringSetMap zoningMap = new StringSetMap();
        for (NetworkLite network : initiatorsByNetworkMap.keySet()) {
            if (!Transport.FC.toString().equals(network.getTransportType())) {
                continue;
            }
            Map<String, StoragePort> initiatorPortsMap = NetworkUtil.getPortsInNetworkMap(network, storagePorts);
            if (!initiatorPortsMap.isEmpty()) {
                Map<String, List<Zone>> initiatorWwnToZonesMap = new HashMap<String, List<Zone>>();
                URI[] networkSystemURIUsed = new URI[1];
                zoningMap.putAll(getZoningMap(network, initiatorsByNetworkMap.get(network), initiatorPortsMap, initiatorWwnToZonesMap, networkSystemURIUsed));
                createZoneReferences(network, networkSystemURIUsed[0], exportGroup, exportMask, initiatorWwnToZonesMap);
            }
        }
        _log.info(String.format("Elapsed time to updateZoningMap %d seconds", ((System.currentTimeMillis() - start) / 1000L)));
        exportMask.setZoningMap(zoningMap);
        if (doPersist) {
            _dbClient.updateAndReindexObject(exportMask);
        }
    } else {
        _log.info((String.format("Export mask %s (%s, args) already has a zoning map, not importing zones", exportMask.getMaskName(), exportMask.getId())));
    }
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) Initiator(com.emc.storageos.db.client.model.Initiator) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

NetworkLite (com.emc.storageos.util.NetworkLite)130 StoragePort (com.emc.storageos.db.client.model.StoragePort)110 URI (java.net.URI)86 ArrayList (java.util.ArrayList)85 PortAllocationContext (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)82 HashMap (java.util.HashMap)48 List (java.util.List)44 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)25 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)22 Map (java.util.Map)22 HashSet (java.util.HashSet)20 Initiator (com.emc.storageos.db.client.model.Initiator)19 StringSet (com.emc.storageos.db.client.model.StringSet)19 TreeMap (java.util.TreeMap)10 Set (java.util.Set)9 SortedMap (java.util.SortedMap)9 StringMap (com.emc.storageos.db.client.model.StringMap)7 StoragePortsAllocator (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator)6 DummyDbClient (com.emc.storageos.util.DummyDbClient)4 PortAllocatorTestContext (com.emc.storageos.volumecontroller.placement.PortAllocatorTestContext)4