Search in sources :

Example 11 with NetworkLite

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

the class BrocadeNetworkSystemDevice method removeZones.

public BiosCommandResult removeZones(NetworkSystem networkSystem, List<Zone> zones, String fabricId, String fabricWwn, boolean activateZones) throws NetworkDeviceControllerException {
    BiosCommandResult result = null;
    Map<String, String> removedZoneResults = new HashMap<String, String>();
    try {
        validateFabric(networkSystem, fabricWwn, fabricId);
        Map<NetworkLite, List<Zone>> zonesPerFabric = getAllZonesForZones(zones, true, fabricId, fabricWwn);
        for (NetworkLite network : zonesPerFabric.keySet()) {
            WBEMClient client = getNetworkDeviceClient(networkSystem);
            removedZoneResults.putAll(removeZonesStrategy(client, zonesPerFabric.get(network), network.getNativeId(), NetworkUtil.getNetworkWwn(network), activateZones));
        }
        result = getBiosCommandResult(removedZoneResults);
        _log.info("Remove zone results {}", toMessage(removedZoneResults));
    } catch (NetworkDeviceControllerException ex) {
        _log.error("Cannot remove zones: " + ex.getLocalizedMessage());
        throw ex;
    }
    return result;
}
Also used : NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException) HashMap(java.util.HashMap) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetworkLite(com.emc.storageos.util.NetworkLite) ArrayList(java.util.ArrayList) List(java.util.List) WBEMClient(javax.wbem.client.WBEMClient)

Example 12 with NetworkLite

use of com.emc.storageos.util.NetworkLite 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 13 with NetworkLite

use of com.emc.storageos.util.NetworkLite 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 14 with NetworkLite

use of com.emc.storageos.util.NetworkLite 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 15 with NetworkLite

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

the class VPlexHDSMaskingOrchestrator 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) {
    Set<Map<URI, List<List<StoragePort>>>> portGroups = new HashSet<Map<URI, List<List<StoragePort>>>>();
    // Group the networks into sets based on the number of ports they have.
    StringSet netNames = new StringSet();
    Map<Integer, Set<URI>> numPortsToNetworkSet = new HashMap<Integer, Set<URI>>();
    for (URI networkURI : allocatablePorts.keySet()) {
        int numPorts = allocatablePorts.get(networkURI).size();
        if (numPorts > MAX_PORTS_PER_NETWORK) {
            numPorts = MAX_PORTS_PER_NETWORK;
        }
        if (numPortsToNetworkSet.get(numPorts) == null) {
            numPortsToNetworkSet.put(Integer.valueOf(numPorts), new HashSet<URI>());
        }
        numPortsToNetworkSet.get(Integer.valueOf(numPorts)).add(networkURI);
        netNames.add(networkMap.get(networkURI).getLabel());
    }
    _log.info("Calculating PortGroups for Networks %s: " + netNames.toString());
    // Eliminate ports from the same cpus, which are in the same portGroup.
    // This is to avoid the 4096 LUN limit per cpu.
    // Start with networks with fewest ports and work up. THis is because
    // in the case of duplicate us of a cpu by two ports, we want to eliminate
    // the port in the Network containing the most ports. So by starting with
    // the Network with the fewest ports to populate the cpusUsed set, we will
    // end up eliminating the port that is in the Network with a higher number of
    // ports.
    Set<String> cpusUsed = new HashSet<String>();
    for (Integer numPorts = 1; numPorts < MAX_PORTS_PER_NETWORK; numPorts++) {
        Set<URI> networkURIs = numPortsToNetworkSet.get(numPorts);
        if (networkURIs == null) {
            continue;
        }
        for (URI networkURI : networkURIs) {
            List<StoragePort> nonConflictedPorts = new ArrayList<StoragePort>();
            for (StoragePort port : allocatablePorts.get(networkURI)) {
                if (!cpusUsed.contains(port.getPortGroup())) {
                    cpusUsed.add(port.getPortGroup());
                    nonConflictedPorts.add(port);
                } else {
                    _log.info(String.format("Eliminating port %s because cpu already used", port.getPortName()));
                }
            }
            allocatablePorts.put(networkURI, nonConflictedPorts);
        }
    }
    // Determine the network with the lowest number of allocatable ports.
    int minPorts = Integer.MAX_VALUE;
    for (URI networkURI : allocatablePorts.keySet()) {
        int numPorts = allocatablePorts.get(networkURI).size();
        if (numPorts > MAX_PORTS_PER_NETWORK) {
            numPorts = MAX_PORTS_PER_NETWORK;
        }
        if (numPorts < minPorts) {
            minPorts = numPorts;
        }
    }
    // Figure out the number of ports in each network per port group (PG).
    // Then figure out the number of port groups to be generated.
    // HEURISTIC:
    // 1-3 ports, use 1 port per MV, unless there's only one Network, then use 2.
    // If it has 8 or more ports, use 2 ports per network, 4 for MV.
    // If it has 18 or more ports, use 3 ports per network, 6 per MV.
    // oneNetwork indicates if there is only one Network available.
    // portsPerPG is the number of ports to be allocated per PortGroup from the
    // network with the fewest ports.
    // numPG is the number of Port Groups that will be configured.
    boolean oneNetwork = allocatablePorts.keySet().size() == 1;
    int portsPerPG = oneNetwork ? 2 : 1;
    if (minPorts >= 8) {
        portsPerPG = 2;
    }
    if (minPorts >= 18) {
        portsPerPG = 3;
    }
    int numPG = minPorts / portsPerPG;
    if (numPG == 0) {
        return portGroups;
    }
    _log.info(String.format("Number Port Groups %d Per Network Ports Per Group %d", numPG, portsPerPG));
    // Make a map per Network of number of ports to allocate.
    Map<URI, Integer> portsAllocatedPerNetwork = new HashMap<URI, Integer>();
    for (URI netURI : allocatablePorts.keySet()) {
        Integer nports = allocatablePorts.get(netURI).size() / numPG;
        // ports from the network with the fewest ports, i.e. do not exceed 2x portsPerPG.
        if (nports > (2 * portsPerPG)) {
            nports = 2 * portsPerPG;
        }
        portsAllocatedPerNetwork.put(netURI, nports);
    }
    // Now call the StoragePortsAllocator for each Network, assigning required number of ports.
    StoragePortsAllocator allocator = new StoragePortsAllocator();
    for (int i = 0; i < numPG; 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: %s", i, portNames.toString()));
        // Reinitialize the context in the allocator; we want redundancy within PG
        if (allocator.getContext() != null) {
            allocator.getContext().reinitialize();
        }
    }
    return portGroups;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) 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) HashSet(java.util.HashSet) NetworkLite(com.emc.storageos.util.NetworkLite) StoragePort(com.emc.storageos.db.client.model.StoragePort) HashMap(java.util.HashMap) Map(java.util.Map) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) PortAllocationContext(com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)

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