Search in sources :

Example 81 with StoragePort

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

the class VplexCinderMaskingOrchestrator method getPortGroups.

@Override
public Set<Map<URI, List<List<StoragePort>>>> getPortGroups(Map<URI, List<StoragePort>> allocatablePorts, Map<URI, NetworkLite> networkMap, URI varrayURI, int nInitiatorGroups, Map<URI, Map<String, Integer>> switchToPortNumber, Map<URI, PortAllocationContext> contextMap, StringBuilder errorMessages) {
    _log.debug("START - getPortGroups");
    Set<Map<URI, List<List<StoragePort>>>> portGroups = new HashSet<Map<URI, List<List<StoragePort>>>>();
    Map<URI, Integer> portsAllocatedPerNetwork = new HashMap<URI, Integer>();
    // Port Group is always 1 for Cinder as of now.
    for (URI netURI : allocatablePorts.keySet()) {
        Integer nports = allocatablePorts.get(netURI).size() / CINDER_NUM_PORT_GROUP;
        portsAllocatedPerNetwork.put(netURI, nports);
    }
    StoragePortsAllocator allocator = new StoragePortsAllocator();
    for (int i = 0; i < CINDER_NUM_PORT_GROUP; i++) {
        Map<URI, List<List<StoragePort>>> portGroup = new HashMap<URI, List<List<StoragePort>>>();
        StringSet portNames = new StringSet();
        for (URI netURI : allocatablePorts.keySet()) {
            NetworkLite net = networkMap.get(netURI);
            Map<String, Integer> switchCountMap = null;
            if (switchToPortNumber != null) {
                switchCountMap = switchToPortNumber.get(netURI);
            }
            PortAllocationContext context = null;
            if (contextMap != null) {
                context = contextMap.get(netURI);
            }
            List<StoragePort> allocatedPorts = allocatePorts(allocator, allocatablePorts.get(netURI), portsAllocatedPerNetwork.get(netURI), net, varrayURI, switchCountMap, context);
            if (portGroup.get(netURI) == null) {
                portGroup.put(netURI, new ArrayList<List<StoragePort>>());
            }
            portGroup.get(netURI).add(allocatedPorts);
            allocatablePorts.get(netURI).removeAll(allocatedPorts);
            for (StoragePort port : allocatedPorts) {
                portNames.add(port.getPortName());
            }
        }
        portGroups.add(portGroup);
        _log.info(String.format("Port Group %d: port names in the port group {%s}", i, portNames.toString()));
    }
    _log.debug("END - getPortGroups");
    return portGroups;
}
Also used : HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) StoragePortsAllocator(com.emc.storageos.volumecontroller.placement.StoragePortsAllocator) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) HashSet(java.util.HashSet) PortAllocationContext(com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)

Example 82 with StoragePort

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

the class VplexXtremIOMaskingOrchestrator method getNetworkPortUniqueXbrick.

/**
 * Gets a storage port for the given network from Unique X-brick/SC.
 *
 * @param networkURI
 *            the network uri
 * @param storagePorts
 *            the storage ports
 * @param usedPorts
 *            the used ports
 * @param networkToSelectedXbricks
 *            the network to selected x-bricks
 * @param xBricksToSelectedSCs
 *            the x-bricks to selected SCs
 * @param allocator
 *            Storage Port Allocator
 * @param checkConnectivity
 * @return the network port unique x brick
 */
private StoragePort getNetworkPortUniqueXbrick(URI networkURI, List<StoragePort> storagePorts, Set<String> usedPorts, Map<URI, List<String>> networkToSelectedXbricks, Map<String, List<String>> xBricksToSelectedSCs, StoragePortsAllocator allocator, boolean checkConnectivity, Map<String, Integer> switchNumberMap, PortAllocationContext context) {
    /**
     * Input:
     * -List of network's storage ports;
     * -X-bricks already chosen for this network;
     * -X-bricks already chosen for all networks with StorageControllers (SC) chosen:
     *
     * Choose a storage port based on below logic:
     * -See if there is a port from X-brick other than allNetworkXbricks (select different SC for the selected
     * X-brick)
     * -If not, see if there is a port from X-brick other than networkXbricks (select different SC for the selected
     * X-brick)
     */
    StoragePort port = null;
    if (networkToSelectedXbricks.get(networkURI) == null) {
        networkToSelectedXbricks.put(networkURI, new ArrayList<String>());
    }
    boolean isSwitchAffinity = false;
    Map<StoragePort, String> portSwitchMap = null;
    if (switchNumberMap != null) {
        // switch affinity is on
        isSwitchAffinity = true;
        if (!simulation) {
            portSwitchMap = getPortSwitchMap(storagePorts);
        } else if (simulation && context != null) {
            portSwitchMap = allocator.getPortSwitchMap(context);
        }
    }
    List<StoragePort> uniqueXBrickPorts = new ArrayList<StoragePort>();
    for (StoragePort sPort : storagePorts) {
        // Do not choose a port that has already been chosen
        if (!usedPorts.contains(sPort.getPortName()) && isPortConnected(allocator, sPort, checkConnectivity)) {
            String[] splitArray = sPort.getPortGroup().split(Constants.HYPHEN);
            String xBrick = splitArray[0];
            String sc = splitArray[1];
            // select port from unique X-brick/SC
            if (!xBricksToSelectedSCs.containsKey(xBrick)) {
                if (isSwitchAffinity) {
                    uniqueXBrickPorts.add(sPort);
                } else {
                    port = sPort;
                    addSCToXbrick(xBricksToSelectedSCs, xBrick, sc);
                    networkToSelectedXbricks.get(networkURI).add(xBrick);
                    break;
                }
            }
        }
    }
    if (!uniqueXBrickPorts.isEmpty()) {
        port = getSwitchAffinityPort(uniqueXBrickPorts, switchNumberMap, portSwitchMap, networkToSelectedXbricks, xBricksToSelectedSCs, networkURI);
    }
    if (port == null) {
        uniqueXBrickPorts.clear();
        for (StoragePort sPort : storagePorts) {
            // Do not choose a port that has already been chosen
            if (!usedPorts.contains(sPort.getPortName()) && isPortConnected(allocator, sPort, checkConnectivity)) {
                String[] splitArray = sPort.getPortGroup().split(Constants.HYPHEN);
                String xBrick = splitArray[0];
                String sc = splitArray[1];
                // select port from unique X-brick/SC for this network
                if (!networkToSelectedXbricks.get(networkURI).contains(xBrick) && (xBricksToSelectedSCs.get(xBrick) == null || !xBricksToSelectedSCs.get(xBrick).contains(sc))) {
                    if (isSwitchAffinity) {
                        uniqueXBrickPorts.add(sPort);
                    } else {
                        port = sPort;
                        addSCToXbrick(xBricksToSelectedSCs, xBrick, sc);
                        networkToSelectedXbricks.get(networkURI).add(xBrick);
                        break;
                    }
                }
            }
        }
        if (!uniqueXBrickPorts.isEmpty()) {
            port = getSwitchAffinityPort(uniqueXBrickPorts, switchNumberMap, portSwitchMap, networkToSelectedXbricks, xBricksToSelectedSCs, networkURI);
        }
    }
    return port;
}
Also used : StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList)

Example 83 with StoragePort

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

the class VplexXtremIOMaskingOrchestrator method getPortGroups.

@Override
public Set<Map<URI, List<List<StoragePort>>>> getPortGroups(Map<URI, List<StoragePort>> allocatablePorts, Map<URI, NetworkLite> networkMap, URI varrayURI, int nInitiatorGroups, Map<URI, Map<String, Integer>> switchToPortNumber, Map<URI, PortAllocationContext> contextMap, StringBuilder errorMessages) {
    /**
     * Number of Port Group for XtremIO is always one.
     * - If multiple port groups, each VPLEX Director's initiators will be mapped to multiple ports
     *
     * Single Port Group contains different set of storage ports for each network,
     * so that each VPLEX director's initiators will map to different port set.
     *
     * why allocatePorts() not required:
     * allocatePorts() would return required number of storage ports from a network from unique X-bricks.
     * But we need to select storage ports uniquely across X-bricks & StorageControllers and we need
     * to make use of all storage ports.
     */
    Set<Map<URI, List<List<StoragePort>>>> portGroups = new HashSet<Map<URI, List<List<StoragePort>>>>();
    StringSet netNames = new StringSet();
    // Order the networks from those with fewest ports to those with the most ports.
    List<URI> orderedNetworks = orderNetworksByNumberOfPorts(allocatablePorts);
    for (URI networkURI : orderedNetworks) {
        netNames.add(networkMap.get(networkURI).getLabel());
    }
    _log.info("Calculating PortGroups for Networks: {}", netNames.toString());
    StoragePortsAllocator allocator = new StoragePortsAllocator();
    // Determine if we should check connectivity from the varray.auto_san_zoning
    boolean sanZoningEnabled = false;
    if (!simulation) {
        VirtualArray varray = _dbClient.queryObject(VirtualArray.class, varrayURI);
        if (varray != null && NetworkScheduler.isZoningRequired(_dbClient, varray)) {
            sanZoningEnabled = true;
        }
    }
    /**
     * Till all storage ports been processed:
     * -- get a set of 4 storage ports selected equally across networks
     * -- add this set into network to port List map (each port set within a network will be mapped for different
     * directors)
     */
    Map<URI, List<List<StoragePort>>> useablePorts = new HashMap<URI, List<List<StoragePort>>>();
    Set<String> usedPorts = new HashSet<String>();
    // map of selected X-brick to Storage Controllers across all networks
    Map<String, List<String>> xBricksToSelectedSCs = new HashMap<String, List<String>>();
    // map of network to selected X-bricks
    Map<URI, List<String>> networkToSelectedXbricks = new HashMap<URI, List<String>>();
    do {
        Map<URI, List<StoragePort>> useablePortsSet = getUsablePortsSet(allocatablePorts, orderedNetworks, usedPorts, xBricksToSelectedSCs, networkToSelectedXbricks, networkMap, allocator, sanZoningEnabled, switchToPortNumber, contextMap);
        if (useablePortsSet == null) {
            // if requirement not satisfied
            break;
        }
        for (URI networkURI : useablePortsSet.keySet()) {
            if (!useablePorts.containsKey(networkURI)) {
                useablePorts.put(networkURI, new ArrayList<List<StoragePort>>());
            }
            useablePorts.get(networkURI).add(useablePortsSet.get(networkURI));
        }
    } while (!isAllPortsLooped(orderedNetworks, allocatablePorts, usedPorts));
    int numPG = XTREMIO_NUM_PORT_GROUP;
    _log.info(String.format("Number of Port Groups: %d", numPG));
    portGroups.add(useablePorts);
    _log.info("Selected network to ports set: {}", useablePorts.entrySet());
    // get number of X-bricks from selected ports
    xtremIOXbricksCount = getXbricksCount(useablePorts);
    return portGroups;
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) StoragePortsAllocator(com.emc.storageos.volumecontroller.placement.StoragePortsAllocator) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) HashSet(java.util.HashSet)

Example 84 with StoragePort

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

the class VplexXtremIOMaskingOrchestrator method configureZoning.

@Override
public StringSetMap configureZoning(Map<URI, List<List<StoragePort>>> portGroup, Map<String, Map<URI, Set<Initiator>>> initiatorGroup, Map<URI, NetworkLite> networkMap, StoragePortsAssigner assigner, Map<URI, String> initiatorSwitchMap, Map<URI, Map<String, List<StoragePort>>> switchStoragePortsMap, Map<URI, String> portSwitchMap) {
    StringSetMap zoningMap = new StringSetMap();
    // Set up a map to track port usage so that we can use all ports more or less equally.
    Map<StoragePort, Integer> portUsage = new HashMap<StoragePort, Integer>();
    // Iterate through each of the directors, matching each of its initiators
    // with one port. This will ensure not to violate four paths per director.
    // select number of paths per VPLEX director
    // if X-bricks count is less than director count, choose only 2 initiators from each director
    // leaving other initiators for future scale of X-bricks
    // default 4 initiators in director
    int pathsPerDirector = DEFAULT_NUMBER_OF_PATHS_PER_VPLEX_DIRECTOR;
    if (xtremIOXbricksCount < vplexDirectorCount) {
        pathsPerDirector = MINIMUM_NUMBER_OF_PATHS_PER_VPLEX_DIRECTOR;
    }
    _log.info(String.format("VPLEX Directors: %s, X-bricks: %s, Number of paths per VPLEX Director: %s", vplexDirectorCount, xtremIOXbricksCount, pathsPerDirector));
    boolean isSwitchAffinity = false;
    if (initiatorSwitchMap != null && !initiatorSwitchMap.isEmpty() && switchStoragePortsMap != null && !switchStoragePortsMap.isEmpty()) {
        isSwitchAffinity = true;
    }
    int directorNumber = 1;
    for (String director : initiatorGroup.keySet()) {
        // split initiators across networks depending on number of paths per director
        int numberOfNetworksForDirector = initiatorGroup.get(director).keySet().size();
        int initiatorsPerNetworkForDirector = pathsPerDirector / numberOfNetworksForDirector;
        _log.info("Number of Initiators that must be chosen per network for a director: {}", initiatorsPerNetworkForDirector);
        for (URI networkURI : initiatorGroup.get(director).keySet()) {
            int numberOfInitiatorsPerNetwork = 0;
            NetworkLite net = networkMap.get(networkURI);
            for (Initiator initiator : initiatorGroup.get(director).get(networkURI)) {
                // If there are no ports on the initiators network, too bad...
                if (portGroup.get(networkURI) == null) {
                    _log.info(String.format("%s -> no ports in network", initiator.getInitiatorPort()));
                    continue;
                }
                // if desired number of initiator paths chosen for network
                if (numberOfInitiatorsPerNetwork >= initiatorsPerNetworkForDirector) {
                    _log.info(String.format("Maximum paths per network %s (%d) reached for Director %s", net.getLabel(), numberOfInitiatorsPerNetwork, director));
                    break;
                }
                List<StoragePort> assignablePorts = null;
                if (isSwitchAffinity) {
                    // find the ports with the same switch as the initiator
                    String switchName = initiatorSwitchMap.get(initiator.getId());
                    if (!switchName.equals(NullColumnValueGetter.getNullStr())) {
                        Map<String, List<StoragePort>> switchMap = switchStoragePortsMap.get(networkURI);
                        if (switchMap != null) {
                            List<StoragePort> switchPorts = switchMap.get(switchName);
                            if (switchPorts != null && !switchPorts.isEmpty()) {
                                _log.info(String.format("Found the same switch ports, switch is %s", switchName));
                                assignablePorts = switchPorts;
                            }
                        }
                    }
                }
                List<StoragePort> portList = getStoragePortSetForDirector(portGroup.get(networkURI), directorNumber);
                if (assignablePorts != null) {
                    assignablePorts.retainAll(portList);
                }
                if (assignablePorts == null || assignablePorts.isEmpty()) {
                    assignablePorts = portList;
                }
                // find a port for the initiator
                StoragePort storagePort = VPlexBackEndOrchestratorUtil.assignPortToInitiator(assigner, assignablePorts, net, initiator, portUsage, null);
                if (storagePort != null) {
                    _log.info(String.format("%s %s   %s %s -> %s  %s %s", director, net.getLabel(), initiator.getInitiatorPort(), initiatorSwitchMap.get(initiator.getId()), storagePort.getPortNetworkId(), storagePort.getPortName(), portSwitchMap.get(storagePort.getId())));
                    StringSet ports = new StringSet();
                    ports.add(storagePort.getId().toString());
                    zoningMap.put(initiator.getId().toString(), ports);
                    numberOfInitiatorsPerNetwork++;
                } else {
                    _log.info(String.format("A port could not be assigned for %s %s   %s", director, net.getLabel(), initiator.getInitiatorPort()));
                }
            }
        }
        directorNumber++;
    }
    return zoningMap;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) NetworkLite(com.emc.storageos.util.NetworkLite) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) Initiator(com.emc.storageos.db.client.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) ArrayList(java.util.ArrayList) List(java.util.List)

Example 85 with StoragePort

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

the class CinderExportOperations method getVarrayTaggedStoragePortWWNs.

/**
 * Gets the list of storage port WWNs which are tagged with the virtual
 * array.
 *
 * @param storage
 *            StorageSystem from which ports needs to be queried.
 * @param varrayURI
 *            URI of the tagged virtual array
 * @return
 */
private Map<String, URI> getVarrayTaggedStoragePortWWNs(StorageSystem storage, URI varrayURI) {
    log.debug("START - getVarrayTaggedStoragePortWWNs");
    // Get the list of storage ports of a storage system which are varray
    // tagged
    Map<URI, List<StoragePort>> networkUriVsStoragePorts = ConnectivityUtil.getStoragePortsOfTypeAndVArray(dbClient, storage.getId(), StoragePort.PortType.frontend, varrayURI);
    Map<String, URI> varrayTaggedStoragePortWWNs = new HashMap<String, URI>();
    Set<URI> networkUriSet = networkUriVsStoragePorts.keySet();
    for (URI nwUri : networkUriSet) {
        List<StoragePort> ports = networkUriVsStoragePorts.get(nwUri);
        for (StoragePort port : ports) {
            log.info("Varray Tagged Port is " + port.getPortNetworkId());
            String wwnNoColon = port.getPortNetworkId().replaceAll(CinderConstants.COLON, "");
            varrayTaggedStoragePortWWNs.put(wwnNoColon, port.getId());
        }
    }
    log.debug("END - getVarrayTaggedStoragePortWWNs");
    return varrayTaggedStoragePortWWNs;
}
Also used : HashMap(java.util.HashMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) List(java.util.List) URI(java.net.URI)

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