Search in sources :

Example 21 with NetworkFCZoneInfo

use of com.emc.storageos.networkcontroller.NetworkFCZoneInfo in project coprhd-controller by CoprHD.

the class NetworkScheduler method getZoningTargetsForInitiators.

/**
 * Returns a list of zoning targets for multiple export masks each adding their own
 * list of initiators.
 *
 * @param exportGroup ExportGroup
 * @param exportMasksToInitiators Map of ExportMask URI to List of Initiator URIs
 * @param zonesMap a list of existing zones mapped by the initiator port WWN
 * @param dbClient
 * @return List of Zones (NetworkFCZoneInfo)
 * @throws DeviceControllerException
 */
public List<NetworkFCZoneInfo> getZoningTargetsForInitiators(ExportGroup exportGroup, Map<URI, List<URI>> exportMasksToInitiators, Map<String, List<Zone>> zonesMap, DbClient dbClient) throws DeviceControllerException {
    List<NetworkFCZoneInfo> zones = new ArrayList<NetworkFCZoneInfo>();
    for (URI maskURI : exportMasksToInitiators.keySet()) {
        ExportMask mask = ExportMaskUtils.getExportMask(_dbClient, maskURI);
        if (mask == null) {
            continue;
        }
        List<Initiator> initiators = getInitiators(exportMasksToInitiators.get(maskURI));
        _log.info(String.format("Generating zoning targets for ExportMask: %s (%s) Initiators: %s", mask.getMaskName(), mask.getId(), exportMasksToInitiators.get(maskURI).toString()));
        checkZoningMap(exportGroup.getVirtualArray(), mask, initiators);
        if (isZoningRequired(dbClient, exportGroup.getVirtualArray())) {
            zones.addAll(getZoningTargetsForInitiators(exportGroup, mask, exportGroup.getVirtualArray(), initiators, zonesMap));
        }
        // so check to see if we can add zones for the alternate Varray.
        if (exportGroup.hasAltVirtualArray(mask.getStorageDevice().toString())) {
            URI altVirtualArray = URI.create(exportGroup.getAltVirtualArrays().get(mask.getStorageDevice().toString()));
            if (isZoningRequired(dbClient, altVirtualArray)) {
                zones.addAll(getZoningTargetsForInitiators(exportGroup, mask, altVirtualArray, initiators, zonesMap));
            }
        }
    }
    return zones;
}
Also used : NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) Initiator(com.emc.storageos.db.client.model.Initiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 22 with NetworkFCZoneInfo

use of com.emc.storageos.networkcontroller.NetworkFCZoneInfo in project coprhd-controller by CoprHD.

the class NetworkScheduler method getZoneInfoForExistingZone.

/**
 * Search the list of existing zones for the initiator-port pair to decide which to use.
 * Preference is given to zones according to this priority:
 * <ol>
 * <li>The zone is in ViPR DB and was created by ViPR</li>
 * <li>The zone is in ViPR DB but was not created by ViPR</li>
 * <li>The zone follows the single initiator-target pair per zone</li>
 * <li>The last zone in the list</li>
 * </ol>
 * Create a new FCZoneInfo object from an existing zone, otherwise return a null.
 *
 * @param network the initiator network
 * @param initiatorWwn the initiator WWN
 * @param portWwn the target WWN
 * @param existingZones a list of zones found on the network system for the initiator
 * @return an instance of FCZoneInfo
 */
private NetworkFCZoneInfo getZoneInfoForExistingZone(NetworkLite network, String initiatorWwn, String portWwn, List<Zone> existingZones) {
    NetworkFCZoneInfo zoneInfo = null;
    Zone zone = selectExistingZoneForInitiatorPort(network, initiatorWwn, portWwn, existingZones);
    if (zone != null) {
        zoneInfo = new NetworkFCZoneInfo(URI.create(network.getNetworkSystems().iterator().next()), network.getNativeId(), NetworkUtil.getNetworkWwn(network));
        zoneInfo.setEndPoints(Arrays.asList(new String[] { initiatorWwn, portWwn }));
        zoneInfo.setZoneName(zone.getName());
        zoneInfo.setExistingZone(zone.getExistingZone());
        zoneInfo.setCanBeRolledBack(false);
    }
    return zoneInfo;
}
Also used : NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) Zone(com.emc.storageos.networkcontroller.impl.mds.Zone)

Example 23 with NetworkFCZoneInfo

use of com.emc.storageos.networkcontroller.NetworkFCZoneInfo in project coprhd-controller by CoprHD.

the class NetworkScheduler method getZoningTargetsForExportMasks.

/**
 * Generate the zoning targets for a newly created ExportGroup.
 * The group may include arbitrary numbers of initiators, volumes, ports, export masks, etc.
 *
 * @param exportGroup ExportGroup
 * @param volumeURIs Collection of volumes to be generated
 * @param existingZonesMap a map of initiator ports WWN to its existing zones
 * @param checkZones Flag to enable or disable zoning check on a Network System
 * @param dbClient an instance of DbClient
 * @return List<NetworkFCZoneInfo> representing zones to be created
 * @throws DeviceControllerException
 */
public List<NetworkFCZoneInfo> getZoningTargetsForExportMasks(ExportGroup exportGroup, List<URI> exportMaskURIs, Collection<URI> volumeURIs, Map<String, List<Zone>> existingZonesMap, boolean checkZones, DbClient dbClient) {
    List<NetworkFCZoneInfo> zoneInfos = new ArrayList<NetworkFCZoneInfo>();
    for (URI maskURI : exportMaskURIs) {
        ExportMask exportMask = ExportMaskUtils.getExportMask(_dbClient, maskURI);
        if (exportMask == null) {
            continue;
        }
        Collection<URI> filteredVolumesURIs = filterVolumes(volumeURIs, exportMask);
        if (filteredVolumesURIs.isEmpty()) {
            continue;
        }
        checkZoningMap(exportGroup, exportMask, ExportMaskUtils.getInitiatorsForExportMask(_dbClient, exportMask, Transport.FC), _dbClient);
        if (isZoningRequired(dbClient, exportGroup.getVirtualArray())) {
            _log.info(String.format("Generating zoning targets for ExportMask %s (%s)", exportMask.getMaskName(), exportMask.getId()));
            zoneInfos.addAll(generateRequestedZonesForExportMask(exportGroup.getVirtualArray(), exportGroup, exportMask, filteredVolumesURIs, existingZonesMap, checkZones));
        }
        // so check to see if we can add zones for the alternate Varray.
        if (exportGroup.hasAltVirtualArray(exportMask.getStorageDevice().toString())) {
            URI altVirtualArray = URI.create(exportGroup.getAltVirtualArrays().get(exportMask.getStorageDevice().toString()));
            if (isZoningRequired(dbClient, altVirtualArray)) {
                zoneInfos.addAll(generateRequestedZonesForExportMask(altVirtualArray, exportGroup, exportMask, filteredVolumesURIs, existingZonesMap, checkZones));
            }
        }
    }
    return zoneInfos;
}
Also used : NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) ExportMask(com.emc.storageos.db.client.model.ExportMask) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 24 with NetworkFCZoneInfo

use of com.emc.storageos.networkcontroller.NetworkFCZoneInfo in project coprhd-controller by CoprHD.

the class NetworkScheduler method getZoningTargetsForInitiators.

/**
 * This is called when ExportGroupService adds initiators.
 * Creates list of NetworkFabricInfo structures for zoning each volume
 * to the newly added Initiator.
 *
 * @param exportGroup - The ExportGroup structure.
 * @param varrayUri - The URI of the virtual array, this can be the export group's
 *            virtual array or its alternate virtual array
 * @param exportMask - The ExportMask structure.
 * @param initiators - Contains the initiators
 * @param zonesMap a list of existing zones mapped by the initiator port WWN
 * @return List<NetworkFCZoneInfo> indicating zones and zone references to be created.
 * @throws IOException
 * @throws DeviceControllerException
 */
private List<NetworkFCZoneInfo> getZoningTargetsForInitiators(ExportGroup exportGroup, ExportMask exportMask, URI varrayUri, List<Initiator> initiators, Map<String, List<Zone>> zonesMap) throws DeviceControllerException {
    List<NetworkFCZoneInfo> fabricInfos = new ArrayList<NetworkFCZoneInfo>();
    for (Initiator initiator : initiators) {
        // Determine storage ports.
        StringSet storagePorts = null;
        if (exportMask.getZoningMap() != null) {
            // Get the explicit zone assignments from the port assigner
            storagePorts = exportMask.getZoningMap().get(initiator.getId().toString());
        }
        if (storagePorts == null || storagePorts.isEmpty()) {
            continue;
        }
        if (StorageProtocol.block2Transport(initiator.getProtocol()) != Transport.FC) {
            continue;
        }
        for (String storagePort : storagePorts) {
            StoragePort sp = _dbClient.queryObject(StoragePort.class, URI.create(storagePort));
            if (sp == null || sp.getTaggedVirtualArrays() == null || !sp.getTaggedVirtualArrays().contains(varrayUri.toString())) {
                continue;
            }
            if (!exportMask.getStorageDevice().equals(sp.getStorageDevice())) {
                continue;
            }
            try {
                NetworkFCZoneInfo fabricInfo = placeZones(exportGroup.getId(), varrayUri, initiator.getProtocol(), formatWWN(initiator.getInitiatorPort()), sp, initiator.getHostName(), zonesMap.get(initiator.getInitiatorPort()), true);
                if (fabricInfo != null) {
                    for (String volId : exportMask.getVolumes().keySet()) {
                        NetworkFCZoneInfo volFabricInfo = fabricInfo.clone();
                        volFabricInfo.setVolumeId(URI.create(volId));
                        fabricInfos.add(volFabricInfo);
                    }
                }
            } catch (DeviceControllerException ex) {
                _log.info(String.format("Initiator %s could not be paired with port %s", initiator.getInitiatorPort(), sp.getPortNetworkId()));
            }
        }
    }
    return fabricInfos;
}
Also used : NetworkFCZoneInfo(com.emc.storageos.networkcontroller.NetworkFCZoneInfo) Initiator(com.emc.storageos.db.client.model.Initiator) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetworkDeviceControllerException(com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)

Aggregations

NetworkFCZoneInfo (com.emc.storageos.networkcontroller.NetworkFCZoneInfo)24 ArrayList (java.util.ArrayList)16 URI (java.net.URI)14 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)10 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)9 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)9 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)8 ControllerException (com.emc.storageos.volumecontroller.ControllerException)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 NetworkFCContext (com.emc.storageos.networkcontroller.NetworkFCContext)7 HashMap (java.util.HashMap)7 ExportGroup (com.emc.storageos.db.client.model.ExportGroup)6 Initiator (com.emc.storageos.db.client.model.Initiator)6 List (java.util.List)6 StoragePort (com.emc.storageos.db.client.model.StoragePort)5 StringSet (com.emc.storageos.db.client.model.StringSet)5 ExportMask (com.emc.storageos.db.client.model.ExportMask)4 StringMap (com.emc.storageos.db.client.model.StringMap)4 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)4