use of com.emc.storageos.db.client.model.ZoneInfo in project coprhd-controller by CoprHD.
the class NetworkDeviceController method fetchInitiatorsInNetworkZoneInfoMap.
/**
* For the given network and initiators, which are in the network,
* and a given list of storage ports, find all the zones on the network
* system for the initiators. Search the zones to find ones that have
* one or more of the ports and create the zoning map between the
* initiators and ports. 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 the map returned contains only the zones that were selected for use by ViPR. In the case of duplicate zones between an
* initiator-port pair, ViPR applies a selection criteria to choose one. See {@link #selectZonesForInitiatorsAndPorts}
* <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 network the network of the initiators
* @param map an OUT parameter where ZoneInfoMap is stored
* @param initiators the initiators for which the zones will be read
* @param initiatorPortsMap the storage ports of interest in the networks.
* @return the network system used to read the zones
*/
private NetworkSystem fetchInitiatorsInNetworkZoneInfoMap(NetworkLite network, ZoneInfoMap map, List<Initiator> initiators, Map<String, StoragePort> initiatorPortsMap) {
Map<String, Initiator> wwnToInitiatorMap = wwnToInitiatorMap(initiators);
// retrieve the zones
Map<String, List<Zone>> wwnToZones = new HashMap<String, List<Zone>>();
NetworkSystem networkSystem = fetchInitiatorsZones(network, initiators, wwnToZones);
wwnToZones = selectZonesForInitiatorsAndPorts(network, wwnToZones, initiatorPortsMap);
// if we successfully retrieved the zones
if (networkSystem != null && !wwnToZones.isEmpty()) {
ZoneInfo info = null;
Initiator initiator = null;
for (Map.Entry<String, List<Zone>> entry : wwnToZones.entrySet()) {
initiator = wwnToInitiatorMap.get(entry.getKey());
for (Zone zone : entry.getValue()) {
// I need some logic here to make sure I select the best zone
for (ZoneMember member : zone.getMembers()) {
if (initiatorPortsMap.containsKey(member.getAddress())) {
// double check WWN formatting
StoragePort port = initiatorPortsMap.get(member.getAddress());
info = new ZoneInfo();
info.setZoneName(zone.getName());
info.setInitiatorWwn(initiator.getInitiatorPort());
info.setInitiatorId(initiator.getId().toString());
info.setPortWwn(port.getPortNetworkId());
info.setPortId(port.getId().toString());
info.setNetworkId(network.getId().toString());
info.setNetworkWwn(NetworkUtil.getNetworkWwn(network));
info.setFabricId(network.getNativeId());
info.setNetworkSystemId(networkSystem.getId().toString());
info.setMemberCount(zone.getMembers().size());
map.put(info.getZoneReferenceKey(), info);
}
}
}
}
}
return networkSystem;
}
Aggregations