use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class VplexXtremIOMaskingOrchestrator method getUsablePortsSet.
/**
* Returns a Set of Storage Ports selected equally across networks. Minimum of 2 and maximum of 4 storage ports.
* It returns null when all storage ports have been processed and the minimum requirement is not met.
*
* @param allocatablePorts
* the allocatable ports
* @param orderedNetworks
* the ordered networks
* @param usedPorts
* the used ports
* @param networkToSelectedXbricks
* @param xBricksToSelectedSCs
* @param networkMap
* @param allocator
* Storage Ports Allocator
* @param sanZoningEnabled
* on vArray
* @return the usable ports set
*/
private Map<URI, List<StoragePort>> getUsablePortsSet(Map<URI, List<StoragePort>> allocatablePorts, List<URI> orderedNetworks, Set<String> usedPorts, Map<String, List<String>> xBricksToSelectedSCs, Map<URI, List<String>> networkToSelectedXbricks, Map<URI, NetworkLite> networkMap, StoragePortsAllocator allocator, boolean sanZoningEnabled, Map<URI, Map<String, Integer>> switchToPortNumber, Map<URI, PortAllocationContext> contextMap) {
Map<URI, List<StoragePort>> useablePorts = new HashMap<URI, List<StoragePort>>();
Set<String> usedPortsSet = new HashSet<String>();
Set<String> portsSelected = new HashSet<String>(usedPorts);
do {
int previousSize = usedPortsSet.size();
Iterator<URI> networkItr = orderedNetworks.iterator();
while (networkItr.hasNext() && usedPortsSet.size() < MAXIMUM_NUMBER_OF_STORAGE_PORTS_PER_SET) {
URI networkURI = networkItr.next();
_log.debug(String.format("network: %s, xBricksToSelectedSCs: %s, networkToSelectedXbricks: %s", networkURI, xBricksToSelectedSCs.entrySet(), networkToSelectedXbricks.get(networkURI)));
NetworkLite net = networkMap.get(networkURI);
// Determine if we should check connectivity from the Network's varray.auto_san_zoning
boolean checkConnectivity = sanZoningEnabled && !StorageProtocol.Transport.IP.name().equals(net.getTransportType());
Map<String, Integer> switchNumberMap = null;
PortAllocationContext context = null;
if (switchToPortNumber != null) {
switchNumberMap = switchToPortNumber.get(networkURI);
}
if (contextMap != null) {
context = contextMap.get(networkURI);
}
StoragePort port = getNetworkPortUniqueXbrick(networkURI, allocatablePorts.get(networkURI), portsSelected, networkToSelectedXbricks, xBricksToSelectedSCs, allocator, checkConnectivity, switchNumberMap, context);
_log.debug("Port selected {} for network {}", port != null ? port.getPortName() : null, networkURI);
if (port != null) {
usedPortsSet.add(port.getPortName());
portsSelected.add(port.getPortName());
if (!useablePorts.containsKey(networkURI)) {
useablePorts.put(networkURI, new ArrayList<StoragePort>());
}
useablePorts.get(networkURI).add(port);
}
}
// If No ports have been selected in this round, then clear the X-bricks map
if (previousSize == usedPortsSet.size()) {
xBricksToSelectedSCs.clear();
networkToSelectedXbricks.clear();
}
_log.debug("Ports selected so far : {}", usedPortsSet);
} while (usedPortsSet.size() < MAXIMUM_NUMBER_OF_STORAGE_PORTS_PER_SET && !isAllPortsLooped(orderedNetworks, allocatablePorts, portsSelected));
_log.info("Set Done: Ports selected in this set: {}", usedPortsSet);
if (usedPortsSet.size() < REQUIRED_MINIMUM_NUMBER_OF_STORAGE_PORTS_PER_SET) {
// requirement not met
return null;
}
// if usedPortsSet.size() >= 2, satisfies minimum requirement, min 2 paths
// add to all usedPorts list
usedPorts.addAll(usedPortsSet);
return useablePorts;
}
use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class NetworkAssociationHelper method setNetworkConnectedVirtualArrays.
public static void setNetworkConnectedVirtualArrays(Network network, boolean cascade, DbClient dbClient) {
// compute the new virtual arrays
StringSet newSet = getNetworkConnectedVirtualArrays(network.getId(), network.getRoutedNetworks(), network.getAssignedVirtualArrays(), dbClient);
// check the new list of virtual arrays is different from the old
boolean changed = StringSetUtil.isChanged(network.getConnectedVirtualArrays(), newSet);
if (changed) {
_log.info("Updating connected virtual arrays for network {}. New virtual arrays {}", network.getId(), newSet);
network.replaceConnectedVirtualArrays(newSet);
dbClient.updateObject(network);
if (cascade) {
// now update the routed networks
List<Network> routednetworks = getNetworkRoutedNetworksForUpdate(network, dbClient);
for (Network routedNetwork : routednetworks) {
NetworkLite lite = NetworkUtil.getNetworkLite(routedNetwork.getId(), dbClient);
newSet = getNetworkConnectedVirtualArrays(routedNetwork.getId(), lite.getRoutedNetworks(), lite.getAssignedVirtualArrays(), dbClient);
_log.info("Updating connected virtual arrays for routed network {}. New virtual arrays {}", network.getId(), newSet);
routedNetwork.replaceConnectedVirtualArrays(newSet);
dbClient.updateObject(routedNetwork);
}
}
} else {
_log.info("The new virtual arrays {} are the same as the existing ones. " + "No update is needed for network {}", newSet, network.getId());
}
}
use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class NetworkDeviceController method updateAltDeviceid.
/**
* Ensures every fabricInfo has its altNetworkDevice that is not null when
* the calling code did not already supply a value for this field.
*
* @param fabricInfo the fabric info to be updated
* @param fabricId the fabric id of the network where zoning will be performed
* @param fabricWWN the WWN of the network where zoning will be performed
* @param key the key used to save already retrieved networks in the map
* this key is the fabric WWN unless it is null, then it is the fabric id
* @param fabricId2Network a map where retrieved networks are saved between calls
* into this function. This is done to avoid repeated db retrieves of same objects
*/
private void updateAltDeviceid(NetworkFCZoneInfo fabricInfo, String fabricId, String fabricWWN, String key, Map<String, NetworkLite> fabricId2Network) {
if (fabricInfo != null && fabricInfo.getAltNetworkDeviceId() == null) {
if (fabricId2Network.get(key) == null) {
NetworkLite network = NetworkUtil.getNetworkLiteByFabricId(fabricId, fabricWWN, _dbClient);
if (network != null) {
fabricId2Network.put(key, network);
URI id = fabricInfo.getNetworkDeviceId();
for (String strUri : network.getNetworkSystems()) {
if (!strUri.equals(id.toString())) {
id = URI.create(strUri);
break;
}
}
fabricInfo.setAltNetworkDeviceId(id);
}
}
}
}
use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class NetworkDeviceController method getInitiatorsZoneInfoMap.
/**
* Given a list of initiators, and a list of ports, for each initiator, find the
* zones on the network system where the initiator port WWN and the storage port
* WWN is a member. Returns the results as {@link ZoneInfoMap} which is map
* of initiator port WWN and storage port WWN keyed by zone-key, where zone-key
* is the concatenation of the initiator port WWN and the storage port WWN.
* <p>
* Note that a zone in the network system can have more than one initiator and one storage port. For such zone, there can be multiple
* entries in the map, one for each initiator/port pairs.
* <p>
* If the initiator is not in a network or no zones could be found for the initiator, there will be no entries for this initiator in the
* map. An empty map will be returned if no zones could be found for any initiator.
*
* @param initiators the list of initiators.
* @param storagePorts
* @return an instance of {@link ZoneInfoMap} which is which is map
* of initiator port WWN and storage port WWN keyed by zone-key, where zone-key
* is the concatenation of the initiator port WWN and the storage port WWN.
*/
public ZoneInfoMap getInitiatorsZoneInfoMap(List<Initiator> initiators, List<StoragePort> storagePorts) {
ZoneInfoMap zoningMap = new ZoneInfoMap();
Map<NetworkLite, List<Initiator>> initiatorsByNetworkMap = NetworkUtil.getInitiatorsByNetwork(initiators, _dbClient);
for (Map.Entry<NetworkLite, List<Initiator>> entry : initiatorsByNetworkMap.entrySet()) {
if (!Transport.FC.toString().equals(entry.getKey().getTransportType())) {
continue;
}
Map<String, StoragePort> initiatorPortsMap = NetworkUtil.getPortsInNetworkMap(entry.getKey(), storagePorts);
if (initiatorPortsMap.size() > 0) {
zoningMap.putAll(getInitiatorsInNetworkZoneInfoMap(entry.getKey(), entry.getValue(), initiatorPortsMap));
}
}
return zoningMap;
}
use of com.emc.storageos.util.NetworkLite in project coprhd-controller by CoprHD.
the class NetworkDeviceController method updateZoningMapForInitiators.
/**
* Update the zoning map for a newly "accepted" export mask. This applies to
* brown field scenarios where a export mask was found on the storage array.
* This function finds the zones of the export mask initiators and
* existing ports and creates the zoning map between the two sets.
*
* @param exportGroup the masking view export group
* @param exportMask the export mask being updated.
* @param doPersist a boolean that indicates if the changes should be persisted in the db
*/
public void updateZoningMapForInitiators(ExportGroup exportGroup, ExportMask exportMask, boolean doPersist) {
if (exportMask.getZoningMap() == null || exportMask.getZoningMap().isEmpty()) {
Long start = System.currentTimeMillis();
// possibly the first time this export mask is processed, populate from existing zones
List<StoragePort> storagePorts = ExportUtils.getStoragePorts(exportMask, _dbClient);
Set<Initiator> initiators = ExportMaskUtils.getInitiatorsForExportMask(_dbClient, exportMask, Transport.FC);
Map<NetworkLite, List<Initiator>> initiatorsByNetworkMap = NetworkUtil.getInitiatorsByNetwork(initiators, _dbClient);
StringSetMap zoningMap = new StringSetMap();
for (NetworkLite network : initiatorsByNetworkMap.keySet()) {
if (!Transport.FC.toString().equals(network.getTransportType())) {
continue;
}
Map<String, StoragePort> initiatorPortsMap = NetworkUtil.getPortsInNetworkMap(network, storagePorts);
if (!initiatorPortsMap.isEmpty()) {
Map<String, List<Zone>> initiatorWwnToZonesMap = new HashMap<String, List<Zone>>();
URI[] networkSystemURIUsed = new URI[1];
zoningMap.putAll(getZoningMap(network, initiatorsByNetworkMap.get(network), initiatorPortsMap, initiatorWwnToZonesMap, networkSystemURIUsed));
createZoneReferences(network, networkSystemURIUsed[0], exportGroup, exportMask, initiatorWwnToZonesMap);
}
}
_log.info(String.format("Elapsed time to updateZoningMap %d seconds", ((System.currentTimeMillis() - start) / 1000L)));
exportMask.setZoningMap(zoningMap);
if (doPersist) {
_dbClient.updateAndReindexObject(exportMask);
}
} else {
_log.info((String.format("Export mask %s (%s, args) already has a zoning map, not importing zones", exportMask.getMaskName(), exportMask.getId())));
}
}
Aggregations