use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class VPlexVnxMaskingOrchestrator 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> portAUsage = new HashMap<StoragePort, Integer>();
Map<StoragePort, Integer> portBUsage = new HashMap<StoragePort, Integer>();
// check if switch affinity is on
boolean isSwitchAffinity = false;
if (initiatorSwitchMap != null && !initiatorSwitchMap.isEmpty() && switchStoragePortsMap != null && !switchStoragePortsMap.isEmpty()) {
isSwitchAffinity = true;
}
// with one port.
for (String director : initiatorGroup.keySet()) {
for (URI networkURI : initiatorGroup.get(director).keySet()) {
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;
}
List<StoragePort> assignablePortsA = new ArrayList<StoragePort>();
List<StoragePort> assignablePortsB = new ArrayList<StoragePort>();
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));
for (StoragePort port : switchPorts) {
String groupId = port.getPortGroup();
if (groupId != null && groupId.equals(SPA)) {
assignablePortsA.add(port);
} else if (groupId != null && groupId.equals(SPB)) {
assignablePortsB.add(port);
}
}
}
}
}
}
StringSet ports = new StringSet();
// Get an A Port
String aPortName = " ", bPortName = " ";
if (assignablePortsA.isEmpty()) {
assignablePortsA = portGroup.get(networkURI).iterator().next();
}
StoragePort portA = VPlexBackEndOrchestratorUtil.assignPortToInitiator(assigner, assignablePortsA, net, initiator, portAUsage, SPA);
if (portA != null) {
aPortName = portA.getPortName();
ports.add(portA.getId().toString());
}
// Get a B Port
if (assignablePortsB.isEmpty()) {
assignablePortsB = portGroup.get(networkURI).iterator().next();
}
StoragePort portB = VPlexBackEndOrchestratorUtil.assignPortToInitiator(assigner, portGroup.get(networkURI).iterator().next(), net, initiator, portBUsage, SPB);
if (portB != null) {
bPortName = portB.getPortName();
ports.add(portB.getId().toString());
}
_log.info(String.format("%s %s %s %s -> %s %s %s %s", director, net.getLabel(), initiator.getInitiatorPort(), initiatorSwitchMap.get(initiator.getId()), aPortName, portSwitchMap.get(portA.getId()), bPortName, portSwitchMap.get(portB.getId())));
zoningMap.put(initiator.getId().toString(), ports);
}
}
}
return zoningMap;
}
use of com.emc.storageos.util.NetworkLite 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;
}
use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method getNetworksMap.
/**
* Gets the networks of the storage ports organized in a map.
* This code assumes that an end point exists in one and only one network.
*
* @param sports the ports
* @param dbClient an instance of {@link DbClient}
* @return a map of networks and the storage ports that are associated to them.
*/
private static Map<NetworkLite, List<StoragePort>> getNetworksMap(Collection<StoragePort> sports, DbClient dbClient) {
Map<NetworkLite, List<StoragePort>> networkPorts = new HashMap<NetworkLite, List<StoragePort>>();
NetworkLite network;
List<StoragePort> list = null;
for (StoragePort sport : sports) {
network = NetworkUtil.getEndpointNetworkLite(sport.getPortNetworkId(), dbClient);
if (network != null && network.getInactive() == false && network.getTransportType().equals(sport.getTransportType())) {
list = networkPorts.get(network);
if (list == null) {
list = new ArrayList<StoragePort>();
networkPorts.put(network, list);
}
list.add(sport);
}
}
return networkPorts;
}
use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class StoragePortAssociationHelper method runUpdatePortAssociationsProcessForVArrayChange.
/**
* This method executes process to update varrays for the passed port parameter.
*
* @param port storage port for which varrays have been changed
* @param dbClient
* @param coordinator
* @param pools pools which may require vpool changes as a result of port varray changes
* @param varrayAssignmentChanges varray changes for the port
*/
public static void runUpdatePortAssociationsProcessForVArrayChange(StoragePort port, DbClient dbClient, CoordinatorClient coordinator, List<StoragePool> pools, VirtualArrayAssignmentChanges varrayAssignmentChanges) {
try {
// If there was no change in connection between virtual array and storage system which owns port,
// we will run only NumPathsMatcher. Even when varray to storage system connectivity had not changed,
// change in varray ports may have impact on max. number of paths available for varray pools.
// If there was change in connectivity between virtual array and storage system, we will run all vpool
// matchers.
// This is our storage system.
URI storageSystemURI = port.getStorageDevice();
Set<String> varraysToAddIds = new HashSet<>();
Set<String> varraysToRemoveIds = new HashSet<>();
VirtualArrayAssignments varraysToAdd = varrayAssignmentChanges.getAdd();
if (varraysToAdd != null) {
varraysToAddIds = varraysToAdd.getVarrays();
}
VirtualArrayAssignments varraysToRemove = varrayAssignmentChanges.getRemove();
if (varraysToRemove != null) {
varraysToRemoveIds = varraysToRemove.getVarrays();
}
Set<String> varraysWithOutChangedConnectivity = new HashSet<>(varraysToAddIds);
varraysWithOutChangedConnectivity.addAll(varraysToRemoveIds);
// Set of varrays which changed connection to our storage system as result of storage port to varrays assignment change.
Set<String> varraysWithChangedConnectivity = StoragePortAssociationHelper.getVArraysWithChangedConnectivityToStorageSystem(port, varraysToAddIds, varraysToRemoveIds, dbClient);
varraysWithOutChangedConnectivity.removeAll(varraysWithChangedConnectivity);
Collection<StoragePort> ports = Collections.singleton(port);
if (null == pools) {
pools = new ArrayList<StoragePool>();
}
// for better reading, added a method to group Ports by Network
Map<NetworkLite, List<StoragePort>> portsByNetwork = groupPortsByNetwork(ports, dbClient);
if (!portsByNetwork.isEmpty()) {
updatePortAssociations(ports, portsByNetwork, dbClient);
// if any ports are associated with network, then add pools to existing list and run matching pools
Set<URI> poolUris = getStoragePoolIds(pools);
List<StoragePool> modifiedPools = StoragePoolAssociationHelper.getStoragePoolsFromPorts(dbClient, ports, null);
for (StoragePool pool : modifiedPools) {
if (!poolUris.contains(pool.getId())) {
pools.add(pool);
}
}
}
if (!varraysWithChangedConnectivity.isEmpty()) {
// If there are varrays which changed connectivity to our storage system, we need to process all their vpools to match them
// to
// our system's storage pools.
// Match the VPools defined in VArrays with changed connectivity to the StoragePools with all vpool matchers
_log.info("Varrays which changed connectivity to storage system {} are {}", storageSystemURI, varraysWithChangedConnectivity);
List<URI> vpoolURIs = getVpoolsForVarrays(varraysWithChangedConnectivity, dbClient);
_log.info("There are {} vpools for varrays. Execute all vpool matchers for vpools {}", vpoolURIs.size(), vpoolURIs);
StringBuffer errorMessage = new StringBuffer();
ImplicitPoolMatcher.matchModifiedStoragePoolsWithVirtualPools(pools, vpoolURIs, dbClient, coordinator, AttributeMatcher.VPOOL_MATCHERS, errorMessage);
}
if (!varraysWithOutChangedConnectivity.isEmpty()) {
_log.info("Varrays which did not change connection to storage system {} are {}", storageSystemURI, varraysWithOutChangedConnectivity);
// Match the VPools defined in VArrays without changed connectivity to the StoragePools only with num paths matcher
List<URI> vpoolURIs = getVpoolsForVarrays(varraysWithOutChangedConnectivity, dbClient);
_log.info("There are {} vpools for varrays. Execute num paths matcher for vpools {}", vpoolURIs.size(), vpoolURIs);
StringBuffer errorMessage = new StringBuffer();
ImplicitPoolMatcher.matchModifiedStoragePoolsWithVirtualPools(pools, vpoolURIs, dbClient, coordinator, AttributeMatcher.CONNECTIVITY_PLACEMENT_MATCHERS, errorMessage);
}
// get all the system that were affected and update their virtual
// arrays
HashSet<URI> systemsToProcess = StoragePoolAssociationHelper.getStorageSytemsFromPorts(ports, null);
// Now that pools have changed varrays, we need to update RP systems
ConnectivityUtil.updateRpSystemsConnectivity(systemsToProcess, dbClient);
} catch (Exception e) {
_log.error("Update Port Association process failed", e);
}
}
use of com.emc.storageos.util.NetworkLite 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;
}
Aggregations