use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class BlockStorageScheduler method internalAssignStoragePorts.
/**
* Allocates and assigns StoragePorts.
*
* @param system - The StorageSystem the ports will be assigned from.
* @param varray - The VirtualArray (ex. Neighborhood) the initiators should be found in.
* @param newInitiators - The new initiators to be provisioned.
* @param volumeURIs - list of volumes
* @param pathParams - Export path parameters (maxPaths, pathsPerInitiator)
* @param existingZoningMap - A map of initiators to a set of previously allocated port URI strings.
* @return Map<URI, List<URI>> Initiator URI to list of Target StoragePort URIs
*/
private Map<URI, List<URI>> internalAssignStoragePorts(StorageSystem system, URI varray, List<Initiator> newInitiators, Collection<URI> volumeURIs, ExportPathParams pathParams, StringSetMap existingZoningMap) {
// Make reasonable defaults for the path parameters.
checkPathParams(pathParams, system);
_log.info(String.format("Assigning Ports for Array %s params %s Varray %s", system.getNativeGuid(), pathParams.toString(), varray));
// Get the existing assignments in object form.
Map<Initiator, List<StoragePort>> existingAssignments = generateInitiatorsToStoragePortsMap(existingZoningMap, varray);
// Group the new initiators by their networks - filter out those not in a network
Map<NetworkLite, List<Initiator>> initiatorsByNetwork = getInitiatorsByNetwork(newInitiators, existingZoningMap, _dbClient);
Map<Initiator, NetworkLite> initiatorsToNetworkLiteMap = getInitiatorToNetworkLiteMap(initiatorsByNetwork);
// Get the storage ports in the storage system that can be used in the initiators networks
Map<NetworkLite, List<StoragePort>> portsByNetwork = selectStoragePortsInNetworks(system.getId(), initiatorsByNetwork.keySet(), varray, pathParams);
// allocate ports balancing across networks and considering port metrics
Map<NetworkLite, List<StoragePort>> allocatedPorts = allocatePorts(system, varray, initiatorsByNetwork, portsByNetwork, volumeURIs, pathParams, existingZoningMap);
StoragePortsAssigner assigner = StoragePortsAssignerFactory.getAssigner(system.getSystemType());
Map<Initiator, List<StoragePort>> assignments = new HashMap<Initiator, List<StoragePort>>();
// Call StoragePortsAssigner once per host to do the assignments
Map<URI, Map<URI, List<Initiator>>> hostsToNetToInitiators = getHostInitiatorsMapFromNetworkLite(initiatorsByNetwork);
Map<URI, List<StoragePort>> allocatedPortsMap = getAllocatedPortsMap(allocatedPorts);
// For each host, assign the ports to the appropriate initiators.
for (URI hostURI : hostsToNetToInitiators.keySet()) {
Map<URI, Map<String, List<Initiator>>> switchInitiatorsByNet = new HashMap<URI, Map<String, List<Initiator>>>();
Map<URI, Map<String, List<StoragePort>>> switchStoragePortsByNet = new HashMap<URI, Map<String, List<StoragePort>>>();
Map<URI, List<Initiator>> initiatorByNetMap = hostsToNetToInitiators.get(hostURI);
PlacementUtils.getSwitchfoForInititaorsStoragePorts(initiatorByNetMap, allocatedPortsMap, _dbClient, system, switchInitiatorsByNet, switchStoragePortsByNet);
assigner.assignPortsToHost(assignments, initiatorByNetMap, allocatedPortsMap, pathParams, existingAssignments, hostURI, initiatorsToNetworkLiteMap, switchInitiatorsByNet, switchStoragePortsByNet);
}
// Validate that minPaths was met across all assignments (existing and new).
validateMinPaths(system, pathParams, existingAssignments, assignments, newInitiators);
return convertAssignmentsToURIs(assignments);
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class BlockStorageScheduler method getZoneMapFromAssignments.
/**
* Returns a StringSetMap containing the Initiator to StoragePort URIs.
*
* @param assignments Map<URI, List<URI>>
* @return StringSetMap with same information encoded
*/
public static StringSetMap getZoneMapFromAssignments(Map<URI, List<URI>> assignments) {
StringSetMap zoneMap = new StringSetMap();
for (URI initiatorURI : assignments.keySet()) {
StringSet portIds = new StringSet();
List<URI> portURIs = assignments.get(initiatorURI);
for (URI portURI : portURIs) {
portIds.add(portURI.toString());
}
zoneMap.put(initiatorURI.toString(), portIds);
}
return zoneMap;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class BlockStorageScheduler method assignSelectedStoragePorts.
/**
* Assigns storage ports to initiators.
*
* @param system storage system which contains storage ports
* @param storagePorts storage ports to assign
* @param virtualArray virtual array which contains storage ports
* @param initiators list of initiators
* @param pathParams the export path parameters
* @param existingZoningMap existing zoning map in the mask
* @return assignments of storage ports to initiators
* @throws DeviceControllerException
*/
public Map<URI, List<URI>> assignSelectedStoragePorts(StorageSystem system, List<StoragePort> storagePorts, URI virtualArray, List<Initiator> initiators, ExportPathParams pathParams, StringSetMap existingZoningMap) throws DeviceControllerException {
Map<Initiator, List<StoragePort>> assignments = new HashMap<>();
try {
// Group the new initiators by their networks - filter out those not in a network
Map<NetworkLite, List<Initiator>> initiatorsByNetwork = getInitiatorsByNetwork(initiators, existingZoningMap, _dbClient);
Map<Initiator, NetworkLite> initiatorsToNetworkLiteMap = getInitiatorToNetworkLiteMap(initiatorsByNetwork);
// Get the storage ports that can be used in the initiators networks
Map<NetworkLite, List<StoragePort>> portsByNetwork = selectStoragePortsInNetworks(storagePorts, initiatorsByNetwork.keySet(), virtualArray, pathParams);
StoragePortsAssigner assigner = StoragePortsAssignerFactory.getAssigner(system.getSystemType());
// Call StoragePortsAssigner once per host to do the assignments
Map<URI, Map<URI, List<Initiator>>> hostsToNetToInitiators = getHostInitiatorsMapFromNetworkLite(initiatorsByNetwork);
Map<URI, List<StoragePort>> allocatedPortsMap = getAllocatedPortsMap(portsByNetwork);
// Get the existing assignments in object form.
Map<Initiator, List<StoragePort>> existingAssignments = generateInitiatorsToStoragePortsMap(existingZoningMap, virtualArray);
// For each host, assign the ports to the appropriate initiators.
for (URI hostURI : hostsToNetToInitiators.keySet()) {
assigner.assignPortsToHost(assignments, hostsToNetToInitiators.get(hostURI), allocatedPortsMap, pathParams, existingAssignments, hostURI, initiatorsToNetworkLiteMap, null, null);
}
// Validate that minPaths was met across all assignments (existing and new).
validateMinPaths(system, pathParams, existingAssignments, assignments, initiators);
return convertAssignmentsToURIs(assignments);
} catch (PlacementException e) {
_log.error("Unable to assign storage Ports", e);
throw DeviceControllerException.exceptions.exceptionAssigningStoragePorts(e.getMessage(), e);
} catch (Exception e) {
_log.error("Unable to assign Storage Ports", e);
throw DeviceControllerException.exceptions.unexpectedExceptionAssigningPorts(e);
}
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class ZonedPortsStoragePortsAssigner method isPortAssignableToInitiator.
@Override
public boolean isPortAssignableToInitiator(NetworkLite initiatorNetwork, Initiator initiator, StoragePort port) {
StringSetMap zoneMap = zonesByNetwork.get(initiatorNetwork);
StringSet initiatorZonedPorts = zoneMap.get(initiator.getId().toString());
if (initiatorZonedPorts != null && !initiatorZonedPorts.isEmpty()) {
for (String portId : initiatorZonedPorts) {
if (portId.equals(port.getId().toString())) {
return true;
}
}
}
return false;
}
use of com.emc.storageos.db.client.model.StringSetMap in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupUtils method getGroupNamesForSystemCG.
/**
* Return a set of ReplicationGroup names for the given storage system and consistency group.
*
* @param consistencyGroup Consistency group
* @param storageSystem Storage system
* @return Set of group names or an empty set if none exist.
*/
public static Set<String> getGroupNamesForSystemCG(BlockConsistencyGroup consistencyGroup, StorageSystem storageSystem) {
checkNotNull(consistencyGroup);
checkNotNull(storageSystem);
Set<String> result = new HashSet<>();
StringSetMap systemConsistencyGroups = consistencyGroup.getSystemConsistencyGroups();
if (systemConsistencyGroups != null) {
StringSet cgsForSystem = systemConsistencyGroups.get(storageSystem.getId().toString());
if (cgsForSystem != null || !cgsForSystem.isEmpty()) {
result.addAll(cgsForSystem);
}
}
return result;
}
Aggregations