use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class NetworkDeviceController method removeInitiatorsFromZoningMap.
/**
* Processes the initiators that were removed and removes them from the
* ExportMask.zoningMap so the zoningMap will now be indicative of current state.
*
* @param exportMasksToInitiators
*/
private void removeInitiatorsFromZoningMap(List<NetworkZoningParam> zoningParams) {
for (NetworkZoningParam zoningParam : zoningParams) {
ExportMask mask = _dbClient.queryObject(ExportMask.class, zoningParam.getMaskId());
if (mask == null || mask.getInactive()) {
continue;
}
List<URI> initiators = StringSetUtil.stringSetToUriList(zoningParam.getZoningMap().keySet());
for (URI initiatorURI : initiators) {
if (mask.getZoningMap() != null) {
mask.removeZoningMapEntry(initiatorURI.toString());
}
}
_dbClient.persistObject(mask);
}
}
use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class NetworkDeviceController method updateZoningMap.
/**
* This method updates zoning map. This will mostly be called when volume(s) is/are removed
* from the ExportMask which is shared across two/more varrays and varrays do not have same
* storage ports which results in creating zoning based on the ports in the varray.
*
* lastReferenceZoneInfo contains the zones that were removed from the device,
* according to this if there is initiator in the zoningMap with just one storage port
* for which zone is removed then that entry is removed from the zoningMap.
* If initiator has more than one storage port in the zoningMap for the initiator then
* only storage port for which zone is removed is removed from the zoning map.
* ExportMasks with ImmutableZoningMap set are skipped.
*
* @param lastReferenceZoneInfo list of NetworkFCZoneInfo for the zones that are removed.
* @param exportGroupURI reference to exportGroup
* @param exportMaskURIs list of reference to exportMask
*/
private void updateZoningMap(List<NetworkFCZoneInfo> lastReferenceZoneInfo, URI exportGroupURI, List<URI> exportMaskURIs) {
List<URI> emURIs = new ArrayList<URI>();
if (exportMaskURIs == null || exportMaskURIs.isEmpty()) {
ExportGroup exportGroup = _dbClient.queryObject(ExportGroup.class, exportGroupURI);
List<ExportMask> exportMasks = ExportMaskUtils.getExportMasks(_dbClient, exportGroup);
if (exportGroup != null && !exportMasks.isEmpty()) {
for (ExportMask mask : exportMasks) {
emURIs.add(mask.getId());
}
}
} else {
emURIs.addAll(exportMaskURIs);
}
for (URI emURI : emURIs) {
ExportMask exportMask = _dbClient.queryObject(ExportMask.class, emURI);
if (exportMask != null && !exportMask.getInactive() && !exportMask.fetchDeviceDataMapEntry(ExportMask.DeviceDataMapKeys.ImmutableZoningMap.name()).contains(Boolean.TRUE.toString())) {
for (NetworkFCZoneInfo zoneInfo : lastReferenceZoneInfo) {
StringSetMap existingZoningMap = exportMask.getZoningMap();
if (exportMask.getVolumes() == null) {
continue;
}
Set<String> exportMaskVolumes = exportMask.getVolumes().keySet();
if (existingZoningMap != null && zoneInfo.getVolumeId() != null && exportMaskVolumes.contains(zoneInfo.getVolumeId().toString()) && zoneInfo.getEndPoints().size() == 2) {
Initiator initiator = NetworkUtil.findInitiatorInDB(zoneInfo.getEndPoints().get(0), _dbClient);
List<StoragePort> storagePorts = NetworkUtil.findStoragePortsInDB(zoneInfo.getEndPoints().get(1), _dbClient);
for (StoragePort storagePort : storagePorts) {
if (initiator != null && storagePort != null) {
for (String initiatorId : existingZoningMap.keySet()) {
if (initiator.getId().toString().equals(initiatorId)) {
StringSet ports = existingZoningMap.get(initiatorId);
if (ports != null) {
if (ports.contains(storagePort.getId().toString())) {
ports.remove(storagePort.getId().toString());
if (ports.isEmpty()) {
exportMask.removeZoningMapEntry(initiatorId);
_log.info("Removing zoning map entry for initiator {}, in exportmask {}", initiatorId, emURI);
} else {
exportMask.addZoningMapEntry(initiatorId, ports);
_log.info("Removing storagePort " + storagePort.getId() + " from zoning map for initiator " + initiatorId + " in export mask " + emURI);
}
}
}
}
}
}
}
}
_dbClient.persistObject(exportMask);
}
}
}
}
use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class NetworkScheduler method getZoningTargetsForPaths.
/**
* Returns a list of zoning targets for adding paths to the export mask.
*
* @param exportGroup ExportGroup
* @param exportMaskURIs export mask URIs
* @param path Map of initiator URI to List of storage port 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> getZoningTargetsForPaths(URI storageSystemURI, ExportGroup exportGroup, Collection<URI> exportMaskURIs, Map<URI, List<URI>> paths, Map<String, List<Zone>> zonesMap, DbClient dbClient) throws DeviceControllerException {
List<NetworkFCZoneInfo> zones = new ArrayList<NetworkFCZoneInfo>();
if (!isZoningRequired(dbClient, exportGroup.getVirtualArray())) {
_log.info("Zoning not required, returning empty zones list");
return zones;
}
for (URI maskURI : exportMaskURIs) {
ExportMask mask = _dbClient.queryObject(ExportMask.class, maskURI);
StringMap volumeMap = mask.getVolumes();
if (volumeMap == null || volumeMap.isEmpty()) {
_log.info(String.format("There are no volumes in the export mask %s, skipping", mask.getMaskName()));
continue;
}
List<URI> maskVolumes = StringSetUtil.stringSetToUriList(volumeMap.keySet());
List<ExportGroup> maskExportGroups = ExportMaskUtils.getExportGroups(dbClient, mask);
// Filter the paths based on the initiators in zoningMap of this ExportMask
Map<URI, List<URI>> pathsForMask = new HashMap<URI, List<URI>>();
for (String initiatorString : mask.getInitiators()) {
URI initiatorKey = URI.create(initiatorString);
if (paths.containsKey(initiatorKey)) {
pathsForMask.put(initiatorKey, paths.get(initiatorKey));
}
}
// Use the intersection of the volumes in the ExportMask and ExportGroup.
for (ExportGroup group : maskExportGroups) {
if (group.getVolumes() != null) {
List<URI> volumes = new ArrayList<URI>(maskVolumes);
volumes.retainAll(StringSetUtil.stringSetToUriList(group.getVolumes().keySet()));
zones.addAll(getZoningTargetsForPaths(group, volumes, exportGroup.getVirtualArray(), pathsForMask, zonesMap));
}
}
// Check for zones needed in alternate varray for VPLEX cross-connected
if (exportGroup.hasAltVirtualArray(storageSystemURI.toString())) {
URI altVirtualArray = URI.create(exportGroup.getAltVirtualArrays().get(storageSystemURI.toString()));
if (isZoningRequired(dbClient, altVirtualArray)) {
for (ExportGroup group : maskExportGroups) {
if (group.getVolumes() != null) {
List<URI> volumes = new ArrayList<URI>(maskVolumes);
volumes.retainAll(StringSetUtil.stringSetToUriList(group.getVolumes().keySet()));
zones.addAll(getZoningTargetsForPaths(group, volumes, altVirtualArray, pathsForMask, zonesMap));
}
}
}
}
}
return zones;
}
use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class ExportUtils method isInitiatorSharedByMasks.
/**
* Check if initiator is used by multiple masks of same storage array
*
* @param dbClient DbClient
* @param mask ExportMask
* @initiatorUri URI of initiator
* @return true if shared by multiple masks, otherwise false
*/
public static boolean isInitiatorSharedByMasks(DbClient dbClient, ExportMask mask, URI initiatorUri) {
URI storageUri = mask.getStorageDevice();
if (NullColumnValueGetter.isNullURI(storageUri)) {
return false;
}
List<ExportMask> results = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, ExportMask.class, ContainmentConstraint.Factory.getConstraint(ExportMask.class, "initiators", initiatorUri));
for (ExportMask exportMask : results) {
if (exportMask != null && !exportMask.getId().equals(mask.getId()) && storageUri.equals(exportMask.getStorageDevice())) {
return true;
}
}
return false;
}
use of com.emc.storageos.db.client.model.ExportMask in project coprhd-controller by CoprHD.
the class ExportUtils method cleanStaleZoningMapEntries.
/**
* Cleanup any stale entries in the zoning maps for the export masks with the passed URIs.
*
* @param maskURIs The URIs of the export masks to examine.
* @param dbClient A reference to a database client.
*/
private static void cleanStaleZoningMapEntries(List<URI> maskURIs, DbClient dbClient) {
Iterator<ExportMask> maskIter = dbClient.queryIterativeObjects(ExportMask.class, maskURIs);
while (maskIter.hasNext()) {
ExportMask maskObj = maskIter.next();
StringSetMap zoningMap = maskObj.getZoningMap();
StringSet maskInitIds = maskObj.getInitiators();
Set<String> zoningMapInitIds = new HashSet<>(zoningMap.keySet());
for (String zoningMapInitId : zoningMapInitIds) {
if (maskInitIds == null || maskInitIds.isEmpty() || !maskInitIds.contains(zoningMapInitId)) {
zoningMap.remove(zoningMapInitId);
}
}
maskObj.setZoningMap(zoningMap);
dbClient.updateObject(maskObj);
}
}
Aggregations