Search in sources :

Example 6 with ZoneInfoMap

use of com.emc.storageos.db.client.model.ZoneInfoMap in project coprhd-controller by CoprHD.

the class ExportProcessor method updateZoningMap.

private void updateZoningMap(UnManagedExportMask mask, List<Initiator> initiators, List<StoragePort> storagePorts) {
    NetworkDeviceController networkDeviceController = (NetworkDeviceController) _keyMap.get(Constants.networkDeviceController);
    try {
        ZoneInfoMap zoningMap = networkDeviceController.getInitiatorsZoneInfoMap(initiators, storagePorts);
        for (ZoneInfo zoneInfo : zoningMap.values()) {
            _logger.info("Found zone: {} for initiator {} and port {}", new Object[] { zoneInfo.getZoneName(), zoneInfo.getInitiatorWwn(), zoneInfo.getPortWwn() });
        }
        mask.setZoningMap(zoningMap);
    } catch (Exception ex) {
        _logger.error("Failed to get the zoning map for mask {}", mask.getMaskName());
        mask.setZoningMap(null);
    }
}
Also used : NetworkDeviceController(com.emc.storageos.networkcontroller.impl.NetworkDeviceController) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) ZoneInfo(com.emc.storageos.db.client.model.ZoneInfo) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 7 with ZoneInfoMap

use of com.emc.storageos.db.client.model.ZoneInfoMap 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)

Example 8 with ZoneInfoMap

use of com.emc.storageos.db.client.model.ZoneInfoMap 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;
}
Also used : NetworkLite(com.emc.storageos.util.NetworkLite) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) 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)

Example 9 with ZoneInfoMap

use of com.emc.storageos.db.client.model.ZoneInfoMap in project coprhd-controller by CoprHD.

the class NetworkDeviceController method getInitiatorsInNetworkZoneInfoMap.

/**
 * 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 initiators the initiators for which the zones will be read
 * @param initiatorPortsMap the storage ports of interest in the networks.
 * @return a ZoneInfoMap a map of zones found that have at least one of initiators and one of the ports
 */
private ZoneInfoMap getInitiatorsInNetworkZoneInfoMap(NetworkLite network, List<Initiator> initiators, Map<String, StoragePort> initiatorPortsMap) {
    ZoneInfoMap map = new ZoneInfoMap();
    fetchInitiatorsInNetworkZoneInfoMap(network, map, initiators, initiatorPortsMap);
    return map;
}
Also used : ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap)

Aggregations

ZoneInfoMap (com.emc.storageos.db.client.model.ZoneInfoMap)9 ZoneInfo (com.emc.storageos.db.client.model.ZoneInfo)7 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 StoragePort (com.emc.storageos.db.client.model.StoragePort)3 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Initiator (com.emc.storageos.db.client.model.Initiator)2 StringMap (com.emc.storageos.db.client.model.StringMap)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 NetworkFCZoneInfo (com.emc.storageos.networkcontroller.NetworkFCZoneInfo)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)1 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)1 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)1 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)1