Search in sources :

Example 6 with StoragePortsAllocator

use of com.emc.storageos.volumecontroller.placement.StoragePortsAllocator in project coprhd-controller by CoprHD.

the class VPlexXIVMaskingOrchestrator method getPortGroups.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.impl.block.
     * VplexBackEndMaskingOrchestrator#getPortGroups(java.util.Map, java.util.Map, java.net.URI, int)
     */
@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 XIV as of now.
    for (URI netURI : allocatablePorts.keySet()) {
        Integer nports = allocatablePorts.get(netURI).size() / XIV_NUM_PORT_GROUP;
        portsAllocatedPerNetwork.put(netURI, nports);
    }
    StoragePortsAllocator allocator = new StoragePortsAllocator();
    for (int i = 0; i < XIV_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 7 with StoragePortsAllocator

use of com.emc.storageos.volumecontroller.placement.StoragePortsAllocator in project coprhd-controller by CoprHD.

the class VplexUnityMaskingOrchestrator 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.info("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 (URI netURI : allocatablePorts.keySet()) {
        Integer nports = allocatablePorts.get(netURI).size();
        portsAllocatedPerNetwork.put(netURI, nports);
    }
    StoragePortsAllocator allocator = new StoragePortsAllocator();
    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;
        PortAllocationContext context = null;
        if (switchToPortNumber != null) {
            switchCountMap = switchToPortNumber.get(netURI);
        }
        if (contextMap != null) {
            context = contextMap.get(netURI);
        }
        List<StoragePort> allocatedPorts = VPlexBackEndOrchestratorUtil.allocatePorts(allocator, allocatablePorts.get(netURI), portsAllocatedPerNetwork.get(netURI), net, varrayURI, simulation, _blockScheduler, _dbClient, 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: port names in the port group {%s}", portNames.toString()));
    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)

Aggregations

StoragePort (com.emc.storageos.db.client.model.StoragePort)7 StringMap (com.emc.storageos.db.client.model.StringMap)7 StringSet (com.emc.storageos.db.client.model.StringSet)7 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)7 StoragePortsAllocator (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator)7 URI (java.net.URI)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7 List (java.util.List)7 Map (java.util.Map)7 NetworkLite (com.emc.storageos.util.NetworkLite)6 PortAllocationContext (com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext)6 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)1 Set (java.util.Set)1