use of com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext in project coprhd-controller by CoprHD.
the class StoragePortsAssignerTest method testAllocationAssignmentWithSwitchAffinity.
public static Map<Initiator, List<StoragePort>> testAllocationAssignmentWithSwitchAffinity(PortAllocationContext[] contexts, Map<URI, Map<URI, List<Initiator>>> hostToNetToInitiators, int maxPaths, int minPaths, int pathsPerInitiator, int initiatorsPerPort, String arrayType, Map<Initiator, List<StoragePort>> existingAssignments) throws Exception {
Map<URI, List<Initiator>> net2InitiatorsMap = makeNet2InitiatorsMap(hostToNetToInitiators);
Map<Initiator, List<StoragePort>> assignments = new HashMap<Initiator, List<StoragePort>>();
if (pathsPerInitiator > maxPaths) {
return assignments;
}
ExportPathParams pathParams = new ExportPathParams(maxPaths, minPaths, pathsPerInitiator);
pathParams.setMaxInitiatorsPerPort(initiatorsPerPort);
try {
for (int i = 0; i < contexts.length; i++) {
contexts[i].reinitialize();
}
Map<URI, PortAllocationContext> net2ContextMap = new HashMap<URI, PortAllocationContext>();
for (int i = 0; i < contexts.length; i++) {
PortAllocationContext context = contexts[i];
net2ContextMap.put(context._initiatorNetwork.getId(), context);
}
// Map the existing (already allocated) StoragePorts to their Networks.
Map<URI, Set<StoragePort>> existingPortsMap = generateNetworkToStoragePortsMap(existingAssignments);
// Make a Map of Network to existing Initiators
Map<URI, Set<Initiator>> existingInitiatorsMap = generateNetworkToInitiatorsMap(existingAssignments);
// Compute the number of Ports needed for each Network
StoragePortsAssigner assigner = StoragePortsAssignerFactory.getAssigner(arrayType);
List<URI> networkOrder = new ArrayList<URI>();
Map<URI, Integer> net2PortsNeeded = assigner.getPortsNeededPerNetwork(net2InitiatorsMap, pathParams, existingPortsMap, existingInitiatorsMap, true, networkOrder);
// For each Network, allocate the ports required, and then assign the ports.
StoragePortsAllocator allocator = new StoragePortsAllocator();
Map<URI, List<StoragePort>> netToPortsAllocated = new HashMap<URI, List<StoragePort>>();
PortAllocationContext previousContext = null;
for (URI netURI : networkOrder) {
Integer portsNeeded = net2PortsNeeded.get(netURI);
if (portsNeeded == 0) {
System.out.println("No ports to be assigned for net: " + netURI);
continue;
}
// Get the context for this network.
PortAllocationContext context = net2ContextMap.get(netURI);
// Copy context from the previous allocation.
if (previousContext != null) {
context.copyPreviousNetworkContext(previousContext);
}
previousContext = context;
Map<String, Integer> switchMap = new HashMap<String, Integer>();
List<Initiator> inits = net2InitiatorsMap.get(netURI);
int number = inits.size() * pathsPerInitiator / 2;
System.out.println("Number ports in the switch: " + number);
switchMap.put("mds-a", number);
switchMap.put("mds-b", number);
List<StoragePort> portsAllocated = allocator.allocatePortsForNetwork(portsNeeded, context, false, existingPortsMap.get(netURI), true, switchMap);
netToPortsAllocated.put(netURI, portsAllocated);
}
// Now for each host, do the port assignment.
Map<URI, Map<String, List<StoragePort>>> switchStoragePortsByNet = getSwitchPortsByNetMap(netToPortsAllocated, net2ContextMap);
for (Map.Entry<URI, Map<URI, List<Initiator>>> entry : hostToNetToInitiators.entrySet()) {
Map<URI, Map<String, List<Initiator>>> switchInitiatorsByNet = getSwitchInitiatorByNetMap(entry.getValue());
System.out.println("Assign ports for host " + entry.getKey());
assigner.assignPortsToHost(assignments, entry.getValue(), netToPortsAllocated, pathParams, existingAssignments, entry.getKey(), null, switchInitiatorsByNet, switchStoragePortsByNet);
}
List<String> assignmentStrings = new ArrayList<String>();
for (Initiator initiator : assignments.keySet()) {
StringBuilder buf = new StringBuilder();
buf.append(String.format("%s - %s/%s -> ", initiator.getHostName(), initiator.getInitiatorPort(), getInitiatorSwitch(initiator)));
List<StoragePort> ports = assignments.get(initiator);
if (ports == null) {
buf.append("<ignored>");
} else {
for (StoragePort port : assignments.get(initiator)) {
buf.append(port.getPortName() + "/" + getPortSwitch(port, switchStoragePortsByNet) + " ");
}
}
buf.append(" ");
assignmentStrings.add(buf.toString());
}
Collections.sort(assignmentStrings);
for (String line : assignmentStrings) {
System.out.println(line);
}
verifyAssignments(assignments, arrayType, maxPaths, pathsPerInitiator, initiatorsPerPort, net2InitiatorsMap, existingAssignments);
} catch (PlacementException ex) {
System.out.println("PlacementException: " + ex.getMessage());
} catch (Exception ex) {
System.out.println("ERROR: " + ex.getMessage());
throw ex;
}
return assignments;
}
use of com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext in project coprhd-controller by CoprHD.
the class StoragePortsAssignerTest method createVmaxNet2.
protected static PortAllocationContext createVmaxNet2() {
NetworkLite tz = new NetworkLite(URI.create("net2"), "net2");
PortAllocationContext context = new PortAllocationContext(tz, "test");
StoragePort port;
port = createFCPort("FA-7F:2", "50:00:00:00:00:01:00:02");
addPort(context, port, "mds-a");
port = createFCPort("FA-7F:3", "50:00:00:00:00:01:00:03");
addPort(context, port, "mds-b");
port = createFCPort("FA-8F:2", "50:00:00:00:00:01:01:02");
addPort(context, port, "mds-a");
port = createFCPort("FA-8F:3", "50:00:00:00:00:01:01:03");
addPort(context, port, "mds-b");
port = createFCPort("FA-9F:2", "50:00:00:00:00:01:02:02");
addPort(context, port, "mds-a");
port = createFCPort("FA-9F:3", "50:00:00:00:00:01:02:03");
addPort(context, port, "mds-b");
port = createFCPort("FA-10F:2", "50:00:00:00:00:01:03:02");
addPort(context, port, "mds-a");
port = createFCPort("FA-10F:3", "50:00:00:00:00:01:03:03");
addPort(context, port, "mds-b");
port = createFCPort("FA-11F:2", "50:00:00:00:00:01:04:02");
addPort(context, port, "mds-a");
port = createFCPort("FA-11F:3", "50:00:00:00:00:01:04:03");
addPort(context, port, "mds-b");
port = createFCPort("FA-12F:2", "50:00:00:00:00:01:05:02");
addPort(context, port, "mds-a");
port = createFCPort("FA-12F:3", "50:00:00:00:00:01:05:03");
addPort(context, port, "mds-b");
return context;
}
use of com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext in project coprhd-controller by CoprHD.
the class StoragePortsAssignerTest method createVmaxNet11.
protected static PortAllocationContext createVmaxNet11() {
NetworkLite tz = new NetworkLite(URI.create("net1"), "net1");
PortAllocationContext context = new PortAllocationContext(tz, "test");
StoragePort port;
port = createFCPort("FA-7E:0", "50:00:00:00:00:00:00:00");
addPort(context, port, "mds-a");
port = createFCPort("FA-7E:1", "50:00:00:00:00:00:00:01");
addPort(context, port, "mds-b");
port = createFCPort("FA-8E:0", "50:00:00:00:00:00:01:00");
addPort(context, port, "mds-a");
port = createFCPort("FA-8E:1", "50:00:00:00:00:00:01:01");
addPort(context, port, "mds-b");
port = createFCPort("FA-9E:0", "50:00:00:00:00:00:02:00");
addPort(context, port, "mds-a");
port = createFCPort("FA-9E:1", "50:00:00:00:00:00:02:01");
addPort(context, port, "mds-b");
port = createFCPort("FA-10E:0", "50:00:00:00:00:00:03:00");
addPort(context, port, "mds-a");
port = createFCPort("FA-10E:1", "50:00:00:00:00:00:03:01");
addPort(context, port, "mds-b");
port = createFCPort("FA-11E:0", "50:00:00:00:00:00:04:00");
addPort(context, port, "mds-b");
port = createFCPort("FA-11E:1", "50:00:00:00:00:00:04:01");
addPort(context, port, "mds-a");
port = createFCPort("FA-12E:0", "50:00:00:00:00:00:05:00");
addPort(context, port, "mds-b");
port = createFCPort("FA-12E:1", "50:00:00:00:00:00:05:01");
addPort(context, port, "mds-a");
return context;
}
use of com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext in project coprhd-controller by CoprHD.
the class StoragePortsAssignerTest method createVmaxNet4.
// NBS VSAN 11
protected static PortAllocationContext createVmaxNet4() {
NetworkLite tz = new NetworkLite(URI.create("net4"), "net4");
PortAllocationContext context = new PortAllocationContext(tz, "test");
StoragePort port;
port = createFCPort("FA-1E:1", "50:00:09:75:10:04:95:01");
addPort(context, port, "mds-a");
port = createFCPort("FA-1F:1", "50:00:09:75:10:04:95:41");
addPort(context, port, "mds-a");
port = createFCPort("FA-1G:1", "50:00:09:75:10:04:95:81");
addPort(context, port, "mds-a");
port = createFCPort("FA-2E:1", "50:00:09:75:10:04:95:05");
addPort(context, port, "mds-a");
port = createFCPort("FA-2F:1", "50:00:09:75:10:04:95:45");
addPort(context, port, "mds-a");
port = createFCPort("FA-2G:1", "50:00:09:75:10:04:95:85");
addPort(context, port, "mds-a");
return context;
}
use of com.emc.storageos.volumecontroller.placement.StoragePortsAllocator.PortAllocationContext in project coprhd-controller by CoprHD.
the class StoragePortsAssignerTest method createVNXNet2.
protected static PortAllocationContext createVNXNet2() {
NetworkLite tz = new NetworkLite(URI.create("net2"), "net2");
PortAllocationContext context = new PortAllocationContext(tz, "test");
StoragePort port;
port = createFCPort("SP_A:4", "50:00:00:00:00:00:00:04");
addPort(context, port, "mds-a");
port = createFCPort("SP_A:5", "50:00:00:00:00:00:00:05");
addPort(context, port, "mds-b");
port = createFCPort("SP_A:6", "50:00:00:00:00:00:00:06");
addPort(context, port, "mds-a");
port = createFCPort("SP_A:7", "50:00:00:00:00:00:00:07");
addPort(context, port, "mds-b");
port = createFCPort("SP_B:4", "50:00:00:00:00:00:01:04");
addPort(context, port, "mds-a");
port = createFCPort("SP_B:5", "50:00:00:00:00:00:01:05");
addPort(context, port, "mds-b");
port = createFCPort("SP_B:6", "50:00:00:00:00:00:01:06");
addPort(context, port, "mds-a");
port = createFCPort("SP_B:7", "50:00:00:00:00:00:01:07");
addPort(context, port, "mds-b");
return context;
}
Aggregations