Search in sources :

Example 21 with UnManagedExportMask

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

the class PortMetricsProcessor method updateUnmanagedVolumeAndInitiatorCounts.

/**
 * Updates the volumes and initiators that are mapped to the port by UnManagedExportMasks.
 * Note that if there is also a corresponding (managed) ExportMask the unmanaged information is not used.
 * (COP-16349).
 * This is called only from the processing of the port metrics.
 *
 * @param sp -- StoragePort
 * @param countMetaMembers -- count meta members instead of volumes
 * @param dbMetrics -- the MetricsKeys values from the database record to be updated
 */
private void updateUnmanagedVolumeAndInitiatorCounts(StoragePort sp, boolean countMetaMembers, StringMap dbMetrics) {
    Long volumeCount = 0L;
    Long initiatorCount = 0L;
    // Find all the Export Masks containing the port.
    URIQueryResultList queryResult = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedMaskByPort(sp.getId().toString()), queryResult);
    Iterator<URI> maskIt = queryResult.iterator();
    while (maskIt.hasNext()) {
        UnManagedExportMask umask = _dbClient.queryObject(UnManagedExportMask.class, maskIt.next());
        if (umask != null && umask.getInactive() == false && !checkForMatchingExportMask(umask.getMaskName(), umask.getNativeId(), umask.getStorageSystemUri())) {
            StringSet unmanagedVolumeUris = umask.getUnmanagedVolumeUris();
            Long unmanagedVolumes = (unmanagedVolumeUris != null ? unmanagedVolumeUris.size() : 0L);
            if (countMetaMembers && unmanagedVolumeUris != null) {
                unmanagedVolumes = 0L;
                // For VMAX2, count the meta-members instead of the volumes.
                for (String unmanagedVolumeUri : unmanagedVolumeUris) {
                    UnManagedVolume uVolume = _dbClient.queryObject(UnManagedVolume.class, URI.create(unmanagedVolumeUri));
                    Long metaMemberCount = getUnManagedVolumeMetaMemberCount(uVolume);
                    unmanagedVolumes += (metaMemberCount != null ? metaMemberCount : 1L);
                }
            }
            // Determine initiator count from zoning map in unmanaged export mask.
            // If the zoningInfoMap is empty, assume one initiator.
            Long unmanagedInitiators = 0L;
            ZoneInfoMap zoneInfoMap = umask.getZoningMap();
            if (!zoneInfoMap.isEmpty()) {
                for (ZoneInfo info : zoneInfoMap.values()) {
                    if (info.getPortWwn().equals(sp.getPortNetworkId())) {
                        unmanagedInitiators += 1L;
                    }
                }
            } else {
                // Assume one initiator for the unmanaged mask
                unmanagedInitiators += 1L;
            }
            _log.info(String.format("Port %s UnManagedExportMask %s " + "unmanagedVolumes %d unmanagedInitiators %d", sp.getPortName(), umask.getMaskName(), unmanagedVolumes, unmanagedInitiators));
            volumeCount += unmanagedVolumes;
            initiatorCount += unmanagedInitiators;
        }
    }
    MetricsKeys.putLong(MetricsKeys.unmanagedInitiatorCount, initiatorCount, dbMetrics);
    MetricsKeys.putLong(MetricsKeys.unmanagedVolumeCount, volumeCount, dbMetrics);
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ZoneInfo(com.emc.storageos.db.client.model.ZoneInfo) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 22 with UnManagedExportMask

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

the class DiscoveryUtils method markInActiveUnManagedExportMask.

public static void markInActiveUnManagedExportMask(URI storageSystemUri, Set<URI> discoveredUnManagedExportMasks, DbClient dbClient, PartitionManager partitionManager) {
    URIQueryResultList result = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageSystemUnManagedExportMaskConstraint(storageSystemUri), result);
    Set<URI> allMasksInDatabase = new HashSet<URI>();
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
        allMasksInDatabase.add(it.next());
    }
    SetView<URI> onlyAvailableinDB = Sets.difference(allMasksInDatabase, discoveredUnManagedExportMasks);
    if (!onlyAvailableinDB.isEmpty()) {
        _log.info("these UnManagedExportMasks are orphaned and will be cleaned up:" + Joiner.on("\t").join(onlyAvailableinDB));
        List<UnManagedExportMask> unManagedExportMasksToBeDeleted = new ArrayList<UnManagedExportMask>();
        Iterator<UnManagedExportMask> unManagedExportMasks = dbClient.queryIterativeObjects(UnManagedExportMask.class, new ArrayList<URI>(onlyAvailableinDB));
        while (unManagedExportMasks.hasNext()) {
            UnManagedExportMask uem = unManagedExportMasks.next();
            if (null == uem || uem.getInactive()) {
                continue;
            }
            _log.info("Setting UnManagedExportMask {} inactive", uem.getMaskingViewPath());
            uem.setStorageSystemUri(NullColumnValueGetter.getNullURI());
            uem.setInactive(true);
            unManagedExportMasksToBeDeleted.add(uem);
        }
        if (!unManagedExportMasksToBeDeleted.isEmpty()) {
            partitionManager.updateAndReIndexInBatches(unManagedExportMasksToBeDeleted, unManagedExportMasksToBeDeleted.size(), dbClient, UNMANAGED_EXPORT_MASK);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashSet(java.util.HashSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 23 with UnManagedExportMask

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

the class VNXUnityUnManagedObjectDiscoverer method discoverUnmanagedExportMasks.

/**
 * Create unmanaged export masks per host
 *
 * @param systemId
 * @param hostVolumesMap
 *            host-- exportedvolume list
 * @param apiClient
 * @param dbClient
 * @param partitionManager
 * @throws Exception
 */
private void discoverUnmanagedExportMasks(URI systemId, Map<String, List<UnManagedVolume>> hostVolumesMap, VNXeApiClient apiClient, DbClient dbClient, PartitionManager partitionManager) throws Exception {
    unManagedExportMasksToCreate = new ArrayList<UnManagedExportMask>();
    unManagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
    List<UnManagedVolume> unManagedExportVolumesToUpdate = new ArrayList<UnManagedVolume>();
    // In Unity, the volumes are exposed through all the storage ports.
    // Get all the storage ports to be added as known ports in the unmanaged export mask
    // If the host ports are FC, then add all FC storage ports to the mask
    // else add all IP ports
    StringSet knownFCStoragePortUris = new StringSet();
    StringSet knownIPStoragePortUris = new StringSet();
    List<StoragePort> matchedFCPorts = new ArrayList<StoragePort>();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(systemId), storagePortURIs);
    Iterator<URI> portsItr = storagePortURIs.iterator();
    while (portsItr.hasNext()) {
        URI storagePortURI = portsItr.next();
        StoragePort port = dbClient.queryObject(StoragePort.class, storagePortURI);
        if (TransportType.FC.toString().equals(port.getTransportType())) {
            knownFCStoragePortUris.add(storagePortURI.toString());
            matchedFCPorts.add(port);
        } else if (TransportType.IP.toString().equals(port.getTransportType())) {
            knownIPStoragePortUris.add(storagePortURI.toString());
        }
    }
    for (Map.Entry<String, List<UnManagedVolume>> entry : hostVolumesMap.entrySet()) {
        String hostId = entry.getKey();
        List<UnManagedVolume> volumes = entry.getValue();
        StringSet knownInitSet = new StringSet();
        StringSet knownNetworkIdSet = new StringSet();
        StringSet knownVolumeSet = new StringSet();
        List<Initiator> matchedFCInitiators = new ArrayList<Initiator>();
        VNXeHost host = apiClient.getHostById(hostId);
        List<VNXeBase> fcInits = host.getFcHostInitiators();
        List<VNXeBase> iScsiInits = host.getIscsiHostInitiators();
        boolean isVplexHost = false;
        boolean isRPHost = false;
        Set<URI> hostURIs = new HashSet<>();
        if (fcInits != null && !fcInits.isEmpty()) {
            for (VNXeBase init : fcInits) {
                VNXeHostInitiator initiator = apiClient.getHostInitiator(init.getId());
                String portwwn = initiator.getPortWWN();
                if (portwwn == null || portwwn.isEmpty()) {
                    continue;
                }
                Initiator knownInitiator = NetworkUtil.getInitiator(portwwn, dbClient);
                if (knownInitiator != null) {
                    knownInitSet.add(knownInitiator.getId().toString());
                    knownNetworkIdSet.add(portwwn);
                    matchedFCInitiators.add(knownInitiator);
                    URI hostURI = knownInitiator.getHost();
                    if (!NullColumnValueGetter.isNullURI(hostURI) && URIUtil.isType(hostURI, Host.class)) {
                        hostURIs.add(hostURI);
                    }
                } else {
                    knownInitiator = new Initiator();
                    knownInitiator.setInitiatorPort(portwwn);
                }
                if (!isVplexHost && VPlexControllerUtils.isVplexInitiator(knownInitiator, dbClient)) {
                    isVplexHost = true;
                }
            }
        }
        if (!matchedFCInitiators.isEmpty() && ExportUtils.checkIfInitiatorsForRP(matchedFCInitiators)) {
            log.info("host {} contains RP initiators, " + "so this mask contains RP protected volumes", host.getName());
            isRPHost = true;
        }
        if (iScsiInits != null && !iScsiInits.isEmpty()) {
            for (VNXeBase init : iScsiInits) {
                VNXeHostInitiator initiator = apiClient.getHostInitiator(init.getId());
                String portwwn = initiator.getInitiatorId();
                if (portwwn == null || portwwn.isEmpty()) {
                    continue;
                }
                Initiator knownInitiator = NetworkUtil.getInitiator(portwwn, dbClient);
                if (knownInitiator != null) {
                    knownInitSet.add(knownInitiator.getId().toString());
                    knownNetworkIdSet.add(portwwn);
                    URI hostURI = knownInitiator.getHost();
                    if (!NullColumnValueGetter.isNullURI(hostURI) && URIUtil.isType(hostURI, Host.class)) {
                        hostURIs.add(hostURI);
                    }
                }
            }
        }
        if (knownNetworkIdSet.isEmpty()) {
            log.info(String.format("The host %s does not have any known initiators", hostId));
            continue;
        }
        if (hostURIs.size() > 1) {
            log.warn(String.format("Skip export on host %s as the initiators on the host belong to more than one hosts in DB %s", hostId, Joiner.on(",").join(hostURIs)));
            continue;
        }
        String firstNetworkId = knownNetworkIdSet.iterator().next();
        UnManagedExportMask mask = getUnManagedExportMask(firstNetworkId, dbClient, systemId);
        mask.setStorageSystemUri(systemId);
        // set the host name as the mask name
        mask.setMaskName(host.getName());
        allCurrentUnManagedExportMaskUris.add(mask.getId());
        for (UnManagedVolume hostUnManagedVol : volumes) {
            hostUnManagedVol.getInitiatorNetworkIds().addAll(knownNetworkIdSet);
            hostUnManagedVol.getInitiatorUris().addAll(knownInitSet);
            hostUnManagedVol.getUnmanagedExportMasks().add(mask.getId().toString());
            if (isVplexHost) {
                log.info("marking unmanaged unity volume {} as a VPLEX backend volume", hostUnManagedVol.getLabel());
                hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_VPLEX_BACKEND_VOLUME.toString(), Boolean.TRUE.toString());
            }
            if (isRPHost) {
                log.info("unmanaged volume {} is an RP volume", hostUnManagedVol.getLabel());
                hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), Boolean.TRUE.toString());
            } else {
                log.info("unmanaged volume {} is exported to something other than RP.  Marking IS_NONRP_EXPORTED.", hostUnManagedVol.forDisplay());
                hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), Boolean.TRUE.toString());
            }
            mask.getUnmanagedVolumeUris().add(hostUnManagedVol.getId().toString());
            // update mask to HLU information
            StringSet nativeId = hostUnManagedVol.getVolumeInformation().get(SupportedVolumeInformation.NATIVE_ID.name());
            String nativeGuid = hostUnManagedVol.getNativeGuid();
            String lunId = (nativeId != null && nativeId.iterator().hasNext()) ? nativeId.iterator().next() : nativeGuid.substring(nativeGuid.lastIndexOf(Constants.PLUS) + 1);
            String idCharSequence = HostLunRequests.ID_SEQUENCE_LUN;
            if (Boolean.valueOf(hostUnManagedVol.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_SNAP_SHOT.name()))) {
                idCharSequence = HostLunRequests.ID_SEQUENCE_SNAP;
                Snap snap = apiClient.getSnapshot(lunId);
                // get snap's parent id
                lunId = snap.getLun().getId();
            }
            HostLun hostLun = apiClient.getHostLun(lunId, hostId, idCharSequence);
            if (hostLun != null) {
                String hostHlu = host.getName() + "=" + hostLun.getHlu();
                StringSet existingHostHlu = hostUnManagedVol.getVolumeInformation().get(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name());
                if (existingHostHlu != null) {
                    existingHostHlu.add(hostHlu);
                } else {
                    hostUnManagedVol.getVolumeInformation().put(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.name(), hostHlu);
                }
            }
            unManagedExportVolumesToUpdate.add(hostUnManagedVol);
        }
        mask.replaceNewWithOldResources(knownInitSet, knownNetworkIdSet, knownVolumeSet, !matchedFCInitiators.isEmpty() ? knownFCStoragePortUris : knownIPStoragePortUris);
        updateZoningMap(mask, matchedFCInitiators, matchedFCPorts);
    }
    if (!unManagedExportMasksToCreate.isEmpty()) {
        partitionManager.insertInBatches(unManagedExportMasksToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
        unManagedExportMasksToCreate.clear();
    }
    if (!unManagedExportMasksToUpdate.isEmpty()) {
        partitionManager.updateInBatches(unManagedExportMasksToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
        unManagedExportMasksToUpdate.clear();
    }
    if (!unManagedExportVolumesToUpdate.isEmpty()) {
        partitionManager.updateAndReIndexInBatches(unManagedExportVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
        unManagedExportVolumesToUpdate.clear();
    }
    DiscoveryUtils.markInActiveUnManagedExportMask(systemId, allCurrentUnManagedExportMaskUris, dbClient, partitionManager);
}
Also used : ArrayList(java.util.ArrayList) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) URI(java.net.URI) Snap(com.emc.storageos.vnxe.models.Snap) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VNXeBase(com.emc.storageos.vnxe.models.VNXeBase) Initiator(com.emc.storageos.db.client.model.Initiator) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) HashSet(java.util.HashSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) HostLun(com.emc.storageos.vnxe.models.HostLun) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) Host(com.emc.storageos.db.client.model.Host) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 24 with UnManagedExportMask

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

the class XtremIOUnManagedVolumeDiscoverer method discoverUnmanagedExportMasks.

/**
 * Group existing known initiators by Host.
 * For each HostName in HostGroup
 * 1. Get List of IGs associated with Host
 * 2. For each IG, get unmanaged and managed volumes
 * 3. create/update mask with volumes/initiators/ports
 *
 * @param systemId
 * @param igUnmanagedVolumesMap IgName--Unmanaged volume list
 * @param igKnownVolumesMap IgName -- managed volume list
 * @param xtremIOClient
 * @param dbClient
 * @param partitionManager
 * @param volumeIGHLUMap
 * @throws Exception
 */
private void discoverUnmanagedExportMasks(URI systemId, Map<String, List<UnManagedVolume>> igUnmanagedVolumesMap, Map<String, StringSet> igKnownVolumesMap, XtremIOClient xtremIOClient, String xioClusterName, DbClient dbClient, PartitionManager partitionManager, Map<String, Map<String, Integer>> volumeIGHLUMap) throws Exception {
    unManagedExportMasksToCreate = new ArrayList<UnManagedExportMask>();
    unManagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
    List<UnManagedVolume> unManagedExportVolumesToUpdate = new ArrayList<UnManagedVolume>();
    // In XtremIO, the volumes are exposed through all the storage ports.
    // Get all the storage ports of xtremIO to be added as known ports in the unmanaged export mask
    // If the host ports are FC, then all add all FC storage ports to the mask
    // else add all IP ports
    StringSet knownFCStoragePortUris = new StringSet();
    StringSet knownIPStoragePortUris = new StringSet();
    List<StoragePort> matchedFCPorts = new ArrayList<StoragePort>();
    URIQueryResultList storagePortURIs = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePortConstraint(systemId), storagePortURIs);
    Iterator<URI> portsItr = storagePortURIs.iterator();
    while (portsItr.hasNext()) {
        URI storagePortURI = portsItr.next();
        StoragePort port = dbClient.queryObject(StoragePort.class, storagePortURI);
        if (TransportType.FC.toString().equals(port.getTransportType())) {
            knownFCStoragePortUris.add(storagePortURI.toString());
            matchedFCPorts.add(port);
        } else if (TransportType.IP.toString().equals(port.getTransportType())) {
            knownIPStoragePortUris.add(storagePortURI.toString());
        }
    }
    // Group all the initiators and their initiator groups based on ViPR host.
    // To be used for constructing unmanaged export masks
    Map<String, List<Initiator>> hostInitiatorsMap = new HashMap<String, List<Initiator>>();
    Map<String, Set<String>> hostIGNamesMap = new HashMap<String, Set<String>>();
    List<XtremIOInitiator> initiators = xtremIOClient.getXtremIOInitiatorsInfo(xioClusterName);
    for (XtremIOInitiator initiator : initiators) {
        String initiatorNetworkId = initiator.getPortAddress();
        // check if a host initiator exists for this id
        Initiator knownInitiator = NetworkUtil.getInitiator(initiatorNetworkId, dbClient);
        if (knownInitiator == null) {
            // TODO need to think of ways to handle unknown initiators
            continue;
        }
        // Special case for RP: group masks by cluster.
        String hostName = knownInitiator.checkInternalFlags(Flag.RECOVERPOINT) ? knownInitiator.getClusterName() : knownInitiator.getHostName();
        if (hostName != null && !hostName.isEmpty()) {
            log.info("   found an initiator in ViPR on host " + hostName);
            String igName = initiator.getInitiatorGroup().get(1);
            List<Initiator> hostInitiators = hostInitiatorsMap.get(hostName);
            Set<String> hostIGNames = hostIGNamesMap.get(hostName);
            if (hostInitiators == null) {
                hostInitiators = new ArrayList<Initiator>();
                hostInitiatorsMap.put(hostName, hostInitiators);
            }
            if (hostIGNames == null) {
                hostIGNames = new HashSet<String>();
                hostIGNamesMap.put(hostName, hostIGNames);
            }
            hostInitiators.add(knownInitiator);
            hostIGNames.add(igName);
        }
    }
    // create export mask per vipr host
    for (String hostname : hostInitiatorsMap.keySet()) {
        StringSet knownIniSet = new StringSet();
        StringSet knownNetworkIdSet = new StringSet();
        StringSet knownVolumeSet = new StringSet();
        List<Initiator> matchedFCInitiators = new ArrayList<Initiator>();
        List<Initiator> hostInitiators = hostInitiatorsMap.get(hostname);
        Set<String> hostIGs = hostIGNamesMap.get(hostname);
        Map<String, List<String>> rpVolumeSnapMap = new HashMap<String, List<String>>();
        Map<String, UnManagedVolume> rpVolumeMap = new HashMap<String, UnManagedVolume>();
        boolean isRpBackendMask = false;
        if (ExportUtils.checkIfInitiatorsForRP(hostInitiators)) {
            log.info("host {} contains RP initiators, " + "so this mask contains RP protected volumes", hostname);
            isRpBackendMask = true;
        }
        boolean isVplexBackendMask = false;
        for (Initiator hostInitiator : hostInitiators) {
            if (!isVplexBackendMask && VPlexControllerUtils.isVplexInitiator(hostInitiator, dbClient)) {
                log.info("host {} contains VPLEX backend ports, " + "so this mask contains VPLEX backend volumes", hostname);
                isVplexBackendMask = true;
            }
            knownIniSet.add(hostInitiator.getId().toString());
            knownNetworkIdSet.add(hostInitiator.getInitiatorPort());
            if (HostInterface.Protocol.FC.toString().equals(hostInitiator.getProtocol())) {
                matchedFCInitiators.add(hostInitiator);
            }
        }
        UnManagedExportMask mask = getUnManagedExportMask(hostInitiators.get(0).getInitiatorPort(), dbClient, systemId);
        mask.setStorageSystemUri(systemId);
        // set the host name as the mask name
        mask.setMaskName(hostname);
        allCurrentUnManagedExportMaskUris.add(mask.getId());
        for (String igName : hostIGs) {
            StringSet knownVols = igKnownVolumesMap.get(igName);
            if (knownVols != null) {
                knownVolumeSet.addAll(knownVols);
            }
            List<UnManagedVolume> hostUnManagedVols = igUnmanagedVolumesMap.get(igName);
            if (hostUnManagedVols != null) {
                for (UnManagedVolume hostUnManagedVol : hostUnManagedVols) {
                    hostUnManagedVol.getInitiatorNetworkIds().addAll(knownNetworkIdSet);
                    hostUnManagedVol.getInitiatorUris().addAll(knownIniSet);
                    hostUnManagedVol.getUnmanagedExportMasks().add(mask.getId().toString());
                    String nativeGuid = hostUnManagedVol.getNativeGuid();
                    Map<String, Integer> igHLUMap = volumeIGHLUMap.get(nativeGuid);
                    if (igHLUMap != null) {
                        Integer hlu = igHLUMap.get(igName);
                        if (hlu != null) {
                            StringSet hostHlu = new StringSet();
                            hostHlu.add(hostname + "=" + hlu);
                            StringSet existingHostHlu = (StringSet) hostUnManagedVol.getVolumeInformation().get(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.toString());
                            if (existingHostHlu != null) {
                                hostHlu.addAll(existingHostHlu);
                            }
                            hostUnManagedVol.getVolumeInformation().put(SupportedVolumeInformation.HLU_TO_EXPORT_MASK_NAME_MAP.toString(), hostHlu);
                        }
                    }
                    if (isVplexBackendMask) {
                        log.info("marking unmanaged Xtremio volume {} as a VPLEX backend volume", hostUnManagedVol.getLabel());
                        hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_VPLEX_BACKEND_VOLUME.toString(), TRUE);
                    }
                    // volume IS associated with RP, we want to mark that volume as RP enabled.
                    if (!isRpBackendMask) {
                        log.info("unmanaged volume {} is exported to something other than RP.  Marking IS_NONRP_EXPORTED.", hostUnManagedVol.forDisplay());
                        hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), TRUE);
                    } else {
                        log.info("unmanaged volume {} is an RP volume", hostUnManagedVol.getLabel());
                        hostUnManagedVol.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), TRUE);
                        rpVolumeMap.put(hostUnManagedVol.getNativeGuid(), hostUnManagedVol);
                    }
                    if (hostUnManagedVol != null) {
                        mask.getUnmanagedVolumeUris().add(hostUnManagedVol.getId().toString());
                        unManagedExportVolumesToUpdate.add(hostUnManagedVol);
                    }
                }
            }
        }
        mask.replaceNewWithOldResources(knownIniSet, knownNetworkIdSet, knownVolumeSet, !matchedFCInitiators.isEmpty() ? knownFCStoragePortUris : knownIPStoragePortUris);
        updateZoningMap(mask, matchedFCInitiators, matchedFCPorts);
        if (!unManagedExportMasksToCreate.isEmpty()) {
            partitionManager.insertInBatches(unManagedExportMasksToCreate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
            unManagedExportMasksToCreate.clear();
        }
        if (!unManagedExportMasksToUpdate.isEmpty()) {
            partitionManager.updateInBatches(unManagedExportMasksToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_MASK);
            unManagedExportMasksToUpdate.clear();
        }
        if (!unManagedExportVolumesToUpdate.isEmpty()) {
            partitionManager.updateAndReIndexInBatches(unManagedExportVolumesToUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_VOLUME);
            unManagedExportVolumesToUpdate.clear();
        }
        DiscoveryUtils.markInActiveUnManagedExportMask(systemId, allCurrentUnManagedExportMaskUris, dbClient, partitionManager);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) XtremIOInitiator(com.emc.storageos.xtremio.restapi.model.response.XtremIOInitiator) Initiator(com.emc.storageos.db.client.model.Initiator) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)

Example 25 with UnManagedExportMask

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

the class ExternalDeviceUnManagedVolumeDiscoverer method processUnManagedMasksForVolumes.

/**
 * This method processes export info for volumes and returns unmanaged masks to create and existing unmanaged masks to update.
 *
 * @param storageSystem                   storage system [IN]
 * @param exportInfosForExistingMasks     [IN] map: key --- mask uri, value --- volume export info to add to the mask.
 * @param exportInfosForNewMasks          [IN] list of volume export info for which we need to create new masks.
 * @param unManagedVolumeNativeIdToUriMap [IN] map of unmanaged volume native id to unmanaged volume URI
 * @param unManagedExportMasksToUpdate    [OUT] list of unmanaged export masks to update
 * @param unManagedExportMasksToCreate    [OUT] list of unmanaged export masks to create
 * @param dbClient                        reference to db client [IN]
 */
private void processUnManagedMasksForVolumes(com.emc.storageos.db.client.model.StorageSystem storageSystem, Map<URI, HostExportInfo> exportInfosForExistingMasks, List<HostExportInfo> exportInfosForNewMasks, Map<String, URI> unManagedVolumeNativeIdToUriMap, Map<String, URI> managedVolumeNativeIdToUriMap, List<UnManagedExportMask> unManagedExportMasksToUpdate, List<UnManagedExportMask> unManagedExportMasksToCreate, DbClient dbClient) {
    log.info("Processing unmanaged volumes: {} .", unManagedVolumeNativeIdToUriMap);
    // update/create unManaged masks for unManaged volumes
    log.info("Processing masks to update: {} .", exportInfosForExistingMasks);
    for (Map.Entry<URI, HostExportInfo> entry : exportInfosForExistingMasks.entrySet()) {
        URI maskUri = entry.getKey();
        HostExportInfo exportInfo = entry.getValue();
        Set<String> unManagedVolumesUris = new HashSet<>();
        Set<String> managedVolumesUris = new HashSet<>();
        List<String> volumesNativeIds = exportInfo.getStorageObjectNativeIds();
        for (String volumeNativeId : volumesNativeIds) {
            URI volumeUri = unManagedVolumeNativeIdToUriMap.get(volumeNativeId);
            if (volumeUri != null) {
                unManagedVolumesUris.add(volumeUri.toString());
            } else {
                volumeUri = managedVolumeNativeIdToUriMap.get(volumeNativeId);
                if (volumeUri != null) {
                    managedVolumesUris.add(volumeUri.toString());
                }
            }
        }
        // process unmanaged volumes
        UnManagedExportMask unManagedMask = dbClient.queryObject(UnManagedExportMask.class, maskUri);
        StringSet unmangedVolumesInMask = unManagedMask.getUnmanagedVolumeUris();
        // check for null, since existing mask may only have "known" volumes.
        if (unmangedVolumesInMask == null) {
            unmangedVolumesInMask = new StringSet();
            unManagedMask.setUnmanagedVolumeUris(unmangedVolumesInMask);
        }
        unmangedVolumesInMask.addAll(unManagedVolumesUris);
        // process managed volumes
        StringSet managedVolumesInMask = unManagedMask.getKnownVolumeUris();
        // check for null, since existing mask may only have unManaged volumes.
        if (managedVolumesInMask == null) {
            managedVolumesInMask = new StringSet();
            unManagedMask.setKnownVolumeUris(managedVolumesInMask);
        }
        managedVolumesInMask.addAll(managedVolumesUris);
        unManagedExportMasksToUpdate.add(unManagedMask);
    }
    log.info("Processing masks to create: {} .", exportInfosForNewMasks);
    for (HostExportInfo hostExportInfo : exportInfosForNewMasks) {
        Set<String> unManagedVolumesUris = new HashSet<>();
        Set<String> managedVolumesUris = new HashSet<>();
        List<String> volumesNativeIds = hostExportInfo.getStorageObjectNativeIds();
        for (String volumeNativeId : volumesNativeIds) {
            URI volumeUri = unManagedVolumeNativeIdToUriMap.get(volumeNativeId);
            if (volumeUri != null) {
                unManagedVolumesUris.add(volumeUri.toString());
            } else {
                volumeUri = managedVolumeNativeIdToUriMap.get(volumeNativeId);
                if (volumeUri != null) {
                    managedVolumesUris.add(volumeUri.toString());
                }
            }
        }
        // we will create new unManaged mask for host/array.
        UnManagedExportMask newMask = createUnManagedExportMask(storageSystem, hostExportInfo, unManagedVolumesUris, managedVolumesUris, dbClient);
        unManagedExportMasksToCreate.add(newMask);
    }
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) HostExportInfo(com.emc.storageos.storagedriver.HostExportInfo) ZoneInfoMap(com.emc.storageos.db.client.model.ZoneInfoMap) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) URI(java.net.URI) HashSet(java.util.HashSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Aggregations

UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)46 URI (java.net.URI)33 ArrayList (java.util.ArrayList)26 HashSet (java.util.HashSet)20 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)19 StringSet (com.emc.storageos.db.client.model.StringSet)17 Initiator (com.emc.storageos.db.client.model.Initiator)15 HashMap (java.util.HashMap)14 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)13 ExportMask (com.emc.storageos.db.client.model.ExportMask)8 NamedURI (com.emc.storageos.db.client.model.NamedURI)8 Map (java.util.Map)8 Set (java.util.Set)8 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)7 Volume (com.emc.storageos.db.client.model.Volume)7 StoragePort (com.emc.storageos.db.client.model.StoragePort)6 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)6 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)6 CIMInstance (javax.cim.CIMInstance)5 CIMObjectPath (javax.cim.CIMObjectPath)5