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;
}
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;
}
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;
}
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;
}
Aggregations