Search in sources :

Example 11 with ZoneInfo

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;
}
Also used : HashMap(java.util.HashMap) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) Initiator(com.emc.storageos.db.client.model.Initiator) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ZoneMember(com.emc.storageos.networkcontroller.impl.mds.ZoneMember) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap) NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) ZoneInfo(com.emc.storageos.db.client.model.ZoneInfo)

Aggregations

ZoneInfo (com.emc.storageos.db.client.model.ZoneInfo)11 ZoneInfoMap (com.emc.storageos.db.client.model.ZoneInfoMap)7 Initiator (com.emc.storageos.db.client.model.Initiator)4 ArrayList (java.util.ArrayList)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)3 NetworkFCZoneInfo (com.emc.storageos.networkcontroller.NetworkFCZoneInfo)3 FCZoneReference (com.emc.storageos.db.client.model.FCZoneReference)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)2 URI (java.net.URI)2 List (java.util.List)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)1 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)1 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1