Search in sources :

Example 16 with UnManagedExportMask

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

the class VPlexCommunicationInterface method getUnManagedExportMaskFromDb.

private UnManagedExportMask getUnManagedExportMaskFromDb(VPlexStorageViewInfo storageView) {
    URIQueryResultList result = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getUnManagedExportMaskPathConstraint(storageView.getPath()), result);
    UnManagedExportMask uem = null;
    Iterator<URI> it = result.iterator();
    while (it.hasNext()) {
        s_logger.info("found an existing unmanaged export mask for storage view " + storageView.getName());
        uem = _dbClient.queryObject(UnManagedExportMask.class, it.next());
        if (uem != null) {
            break;
        }
    }
    return uem;
}
Also used : URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)

Example 17 with UnManagedExportMask

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

the class VPlexCommunicationInterface method discoverUnmanagedStorageViews.

/**
 * Discovers storage views on the VPLEX and creates UnManagedExportMasks for any
 * that are not managed by ViPR.
 *
 * @param accessProfile providing context for this discovery session
 * @param client a reference to the VPLEX API client
 * @param vvolMap map of virtual volume names to virtual volume info objects
 * @param volumeToExportMasksMap map of volumes to a set of associated UnManagedExportMasks
 * @param volumeToStorageViewMap map of volumes to a set of associated VPlexStorageViewInfos
 * @param recoverpointExportMasks recoverpoint export mask uris
 * @throws BaseCollectionException
 */
private void discoverUnmanagedStorageViews(AccessProfile accessProfile, VPlexApiClient client, Map<String, VPlexVirtualVolumeInfo> vvolMap, Map<String, Set<UnManagedExportMask>> volumeToExportMasksMap, Map<String, Set<VPlexStorageViewInfo>> volumeToStorageViewMap, Set<String> recoverPointExportMasks) throws BaseCollectionException {
    String statusMessage = "Starting discovery of Unmanaged VPLEX Storage Views.";
    s_logger.info(statusMessage + " Access Profile Details :  IpAddress : " + "PortNumber : {}, namespace : {}", accessProfile.getIpAddress() + accessProfile.getPortNumber(), accessProfile.getnamespace());
    URI vplexUri = accessProfile.getSystemId();
    StorageSystem vplex = _dbClient.queryObject(StorageSystem.class, vplexUri);
    if (null == vplex) {
        s_logger.error("No VPLEX Device was found in ViPR for URI: " + vplexUri);
        s_logger.error("Unmanaged VPLEX StorageView discovery cannot continue.");
        return;
    }
    try {
        // this is a map of cluster id (1 or 2) to the actual cluster name
        Map<String, String> clusterIdToNameMap = client.getClusterIdToNameMap();
        // this is a map of the cluster names to a map of its target port names to wwpns
        Map<String, Map<String, String>> clusterPortMap = new HashMap<String, Map<String, String>>();
        for (String clusterName : clusterIdToNameMap.values()) {
            Map<String, String> targetPortToPwwnMap = VPlexControllerUtils.getTargetPortToPwwnMap(client, clusterName);
            clusterPortMap.put(clusterName, targetPortToPwwnMap);
        }
        Set<URI> allCurrentUnManagedExportMaskUris = new HashSet<URI>();
        List<UnManagedExportMask> unManagedExportMasksToCreate = new ArrayList<UnManagedExportMask>();
        List<UnManagedExportMask> unManagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
        Set<URI> rpPortInitiators = RPHelper.getBackendPortInitiators(_dbClient);
        for (String clusterName : clusterIdToNameMap.values()) {
            List<VPlexStorageViewInfo> storageViews = client.getStorageViewsForCluster(clusterName);
            for (VPlexStorageViewInfo storageView : storageViews) {
                s_logger.info("discovering storage view: " + storageView.toString());
                List<Initiator> knownInitiators = new ArrayList<Initiator>();
                List<StoragePort> knownPorts = new ArrayList<StoragePort>();
                UnManagedExportMask uem = getUnManagedExportMaskFromDb(storageView);
                if (uem != null) {
                    s_logger.info("found an existing unmanaged export mask for storage view " + storageView.getName());
                    unManagedExportMasksToUpdate.add(uem);
                    // clean up collections (we'll be refreshing them)
                    uem.getKnownInitiatorUris().clear();
                    uem.getKnownInitiatorNetworkIds().clear();
                    uem.getKnownStoragePortUris().clear();
                    uem.getKnownVolumeUris().clear();
                    uem.getUnmanagedInitiatorNetworkIds().clear();
                    uem.getUnmanagedStoragePortNetworkIds().clear();
                    uem.getUnmanagedVolumeUris().clear();
                } else {
                    s_logger.info("creating a new unmanaged export mask for storage view " + storageView.getName());
                    uem = new UnManagedExportMask();
                    unManagedExportMasksToCreate.add(uem);
                }
                // set basic info
                uem.setNativeId(storageView.getPath());
                uem.setMaskingViewPath(storageView.getPath());
                uem.setMaskName(storageView.getName());
                uem.setStorageSystemUri(accessProfile.getSystemId());
                s_logger.info("now discovering host initiators in storage view " + storageView.getName());
                for (String initiatorNetworkId : storageView.getInitiatorPwwns()) {
                    s_logger.info("looking at initiator network id " + initiatorNetworkId);
                    if (initiatorNetworkId != null && initiatorNetworkId.matches(ISCSI_PATTERN) && (iSCSIUtility.isValidIQNPortName(initiatorNetworkId) || iSCSIUtility.isValidEUIPortName(initiatorNetworkId))) {
                        s_logger.info("\tiSCSI network id normalized to " + initiatorNetworkId);
                    } else if (initiatorNetworkId != null && initiatorNetworkId.matches(REGISTERED_PATTERN)) {
                        initiatorNetworkId = initiatorNetworkId.substring(REGISTERED_PORT_PREFIX.length());
                        initiatorNetworkId = WWNUtility.getWWNWithColons(initiatorNetworkId);
                        s_logger.info("\tRegistered network id normalized to " + initiatorNetworkId);
                    } else if (WWNUtility.isValidWWNAlias(initiatorNetworkId)) {
                        initiatorNetworkId = WWNUtility.getWWNWithColons(initiatorNetworkId);
                        s_logger.info("\twwn normalized to " + initiatorNetworkId);
                    } else {
                        s_logger.warn("\tthis is not a valid network id format, skipping");
                        continue;
                    }
                    // check if a host initiator exists for this id
                    // if so, add to _knownInitiators
                    // otherwise, add to _unmanagedInitiators
                    Initiator knownInitiator = NetworkUtil.getInitiator(initiatorNetworkId, _dbClient);
                    if (knownInitiator != null) {
                        s_logger.info("   found an initiator in ViPR on host " + knownInitiator.getHostName());
                        uem.getKnownInitiatorUris().add(knownInitiator.getId().toString());
                        uem.getKnownInitiatorNetworkIds().add(knownInitiator.getInitiatorPort());
                        knownInitiators.add(knownInitiator);
                    } else {
                        s_logger.info("   no hosts in ViPR found configured for initiator " + initiatorNetworkId);
                        uem.getUnmanagedInitiatorNetworkIds().add(initiatorNetworkId);
                    }
                }
                s_logger.info("now discovering storage ports in storage view " + storageView.getName());
                List<String> targetPortNames = storageView.getPorts();
                if (targetPortNames.isEmpty()) {
                    s_logger.info("no storage ports found in storage view " + storageView.getName());
                // continue; ?
                }
                // target port has value like - P0000000046E01E80-A0-FC02
                // PortWwn has value like - 0x50001442601e8002
                List<String> portWwns = new ArrayList<String>();
                for (String targetPortName : targetPortNames) {
                    Map<String, String> portToWwpnMap = clusterPortMap.get(clusterName);
                    if (portToWwpnMap.keySet().contains(targetPortName)) {
                        portWwns.add(WwnUtils.convertWWN(portToWwpnMap.get(targetPortName), WwnUtils.FORMAT.COLON));
                    }
                }
                for (String portNetworkId : portWwns) {
                    s_logger.info("looking at storage port network id " + portNetworkId);
                    // check if a storage port exists for this id in ViPR
                    // if so, add to _storagePorts
                    StoragePort knownStoragePort = NetworkUtil.getStoragePort(portNetworkId, _dbClient);
                    if (knownStoragePort != null) {
                        s_logger.info("   found a matching storage port in ViPR " + knownStoragePort.getLabel());
                        uem.getKnownStoragePortUris().add(knownStoragePort.getId().toString());
                        knownPorts.add(knownStoragePort);
                    } else {
                        s_logger.info("   no storage port in ViPR found matching portNetworkId " + portNetworkId);
                        uem.getUnmanagedStoragePortNetworkIds().add(portNetworkId);
                    }
                }
                s_logger.info("now discovering storage volumes in storage view " + storageView.getName());
                for (String volumeNameStr : storageView.getVirtualVolumes()) {
                    s_logger.info("found volume " + volumeNameStr);
                    // volumeNameStr contains value like
                    // (161,dd_V000195701573-00D57_VAPM00140801303-00614_vol,VPD83T3:6000144000000010f07dc46a0717e61d,2G)
                    String[] tokens = volumeNameStr.split(",");
                    String volumeName = tokens[1];
                    VPlexVirtualVolumeInfo vvol = vvolMap.get(volumeName);
                    Volume volume = findVirtualVolumeManagedByVipr(vvol);
                    if (volume != null) {
                        s_logger.info("this is a volume already managed by ViPR: " + volume.getLabel());
                        uem.getKnownVolumeUris().add(volume.getId().toString());
                    }
                    // add to map of volume paths to export masks
                    if (vvol != null) {
                        String nativeGuid = vvol.getPath();
                        s_logger.info("nativeGuid UnManagedVolume key for locating UnManagedExportMasks is " + nativeGuid);
                        Set<UnManagedExportMask> maskSet = volumeToExportMasksMap.get(nativeGuid);
                        if (maskSet == null) {
                            maskSet = new HashSet<UnManagedExportMask>();
                            s_logger.info("   creating new maskSet for nativeGuid " + nativeGuid);
                            volumeToExportMasksMap.put(nativeGuid, maskSet);
                        }
                        maskSet.add(uem);
                    }
                    // add this storage view to the volume to storage view map for this volume
                    Set<VPlexStorageViewInfo> storageViewSet = volumeToStorageViewMap.get(volumeName);
                    if (storageViewSet == null) {
                        storageViewSet = new HashSet<VPlexStorageViewInfo>();
                    }
                    storageViewSet.add(storageView);
                    volumeToStorageViewMap.put(volumeName, storageViewSet);
                }
                if (uem.getId() == null) {
                    uem.setId(URIUtil.createId(UnManagedExportMask.class));
                }
                if (checkRecoverPointExportMask(uem, knownInitiators, rpPortInitiators)) {
                    recoverPointExportMasks.add(uem.getId().toString());
                }
                updateZoningMap(uem, knownInitiators, knownPorts);
                persistUnManagedExportMasks(unManagedExportMasksToCreate, unManagedExportMasksToUpdate, false);
                allCurrentUnManagedExportMaskUris.add(uem.getId());
            }
        }
        persistUnManagedExportMasks(unManagedExportMasksToCreate, unManagedExportMasksToUpdate, true);
        cleanUpOrphanedExportMasks(vplexUri, allCurrentUnManagedExportMaskUris);
    } catch (Exception ex) {
        s_logger.error(ex.getLocalizedMessage(), ex);
        String vplexLabel = vplexUri.toString();
        if (null != vplex) {
            vplexLabel = vplex.getLabel();
        }
        throw VPlexCollectionException.exceptions.vplexUnmanagedExportMaskDiscoveryFailed(vplexLabel, ex.getLocalizedMessage());
    } finally {
        if (null != vplex) {
            try {
                vplex.setLastDiscoveryStatusMessage(statusMessage);
                _dbClient.updateObject(vplex);
            } catch (Exception ex) {
                s_logger.error("Error while saving VPLEX discovery status message: {} - Exception: {}", statusMessage, ex.getLocalizedMessage());
            }
        }
    }
}
Also used : VPlexStorageViewInfo(com.emc.storageos.vplex.api.VPlexStorageViewInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) VPlexVirtualVolumeInfo(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo) Initiator(com.emc.storageos.db.client.model.Initiator) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) StoragePort(com.emc.storageos.db.client.model.StoragePort) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexCollectionException(com.emc.storageos.plugins.metering.vplex.VPlexCollectionException) IOException(java.io.IOException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) TreeMap(java.util.TreeMap) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 18 with UnManagedExportMask

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

the class VPlexCommunicationInterface method discoverUnmanagedVolumes.

/**
 * Implementation for discovering unmanaged virtual volumes in a VPLEX storage system.
 *
 * @param accessProfile providing context for this discovery session
 * @param client a reference to the VPLEX API client
 * @param vvolMap map of virtual volume names to virtual volume info objects
 * @param volumeToExportMasksMap map of volumes to a set of associated UnManagedExportMasks
 * @param volumeToStorageViewMap map of volumes to a set of associated VPlexStorageViewInfos
 * @param recoverpointExportMasks recoverpoint export mask uris
 * @param tracker the performance report tracking object for this discovery process
 * @throws BaseCollectionException
 */
private void discoverUnmanagedVolumes(AccessProfile accessProfile, VPlexApiClient client, Map<String, VPlexVirtualVolumeInfo> allVirtualVolumes, Map<String, Set<UnManagedExportMask>> volumeToExportMasksMap, Map<String, Set<VPlexStorageViewInfo>> volumeToStorageViewMap, Set<String> recoverPointExportMasks, UnmanagedDiscoveryPerformanceTracker tracker) throws BaseCollectionException {
    String statusMessage = "Starting discovery of Unmanaged VPLEX Volumes.";
    s_logger.info(statusMessage + " Access Profile Details :  IpAddress : " + "PortNumber : {}, namespace : {}", accessProfile.getIpAddress() + accessProfile.getPortNumber(), accessProfile.getnamespace());
    URI vplexUri = accessProfile.getSystemId();
    StorageSystem vplex = _dbClient.queryObject(StorageSystem.class, vplexUri);
    if (null == vplex) {
        s_logger.error("No VPLEX Device was found in ViPR for URI: " + vplexUri);
        s_logger.error("Unmanaged VPLEX Volume discovery cannot continue.");
        return;
    }
    Set<URI> allUnmanagedVolumes = new HashSet<URI>();
    List<UnManagedVolume> newUnmanagedVolumes = new ArrayList<UnManagedVolume>();
    List<UnManagedVolume> knownUnmanagedVolumes = new ArrayList<UnManagedVolume>();
    List<UnManagedExportMask> unmanagedExportMasksToUpdate = new ArrayList<UnManagedExportMask>();
    Map<String, String> backendVolumeGuidToVvolGuidMap = new HashMap<String, String>();
    try {
        long timer = System.currentTimeMillis();
        Map<String, String> volumesToCgs = new HashMap<String, String>();
        List<VPlexConsistencyGroupInfo> cgs = client.getConsistencyGroups();
        s_logger.info("Found {} Consistency Groups.", cgs.size());
        for (VPlexConsistencyGroupInfo cg : cgs) {
            for (String volumeName : cg.getVirtualVolumes()) {
                volumesToCgs.put(volumeName, cg.getName());
            }
        }
        s_logger.info("Volume to Consistency Group Map is: " + volumesToCgs.toString());
        tracker.consistencyGroupFetch = System.currentTimeMillis() - timer;
        Map<String, String> clusterIdToNameMap = client.getClusterIdToNameMap();
        Map<String, String> varrayToClusterIdMap = new HashMap<String, String>();
        Map<String, String> distributedDevicePathToClusterMap = VPlexControllerUtils.getDistributedDevicePathToClusterMap(vplexUri, _dbClient);
        if (null != allVirtualVolumes) {
            // Pre-populate the virtual pools
            List<URI> allVpoolUris = _dbClient.queryByType(VirtualPool.class, true);
            Iterator<VirtualPool> vpoolIter = _dbClient.queryIterativeObjects(VirtualPool.class, allVpoolUris);
            List<VirtualPool> allVpools = new ArrayList<VirtualPool>();
            while (vpoolIter.hasNext()) {
                VirtualPool vpool = vpoolIter.next();
                // Only cache vplex virtual pools for vpool filtering
                if (VirtualPool.vPoolSpecifiesHighAvailability(vpool)) {
                    allVpools.add(vpool);
                }
            }
            for (String name : allVirtualVolumes.keySet()) {
                timer = System.currentTimeMillis();
                s_logger.info("Discovering Virtual Volume {}", name);
                // UnManagedVolume discover does a pretty expensive
                // iterative call into the VPLEX API to get extended details
                String discoveryKillSwitch = ControllerUtils.getPropertyValueFromCoordinator(_coordinator, VplexBackendIngestionContext.DISCOVERY_KILL_SWITCH);
                if ("stop".equals(discoveryKillSwitch)) {
                    s_logger.warn("discovery kill switch was set to stop, " + "so discontinuing unmanaged volume discovery");
                    return;
                }
                // on every volume in each cluster. First it gets all the
                // volume names/paths (the inexpensive "lite" call), then
                // iterates through them getting the details to populate the
                String discoveryFilter = ControllerUtils.getPropertyValueFromCoordinator(_coordinator, VplexBackendIngestionContext.DISCOVERY_FILTER);
                if ((discoveryFilter != null && !discoveryFilter.isEmpty()) && !(name.matches(discoveryFilter))) {
                    s_logger.warn("name {} doesn't match discovery filter {}", name, discoveryFilter);
                    continue;
                }
                // VPlexVirtualVolumeInfo objects with extended details
                VPlexVirtualVolumeInfo info = allVirtualVolumes.get(name);
                // to here null, it would mean a 404 happened earlier.
                if (null == info) {
                    continue;
                }
                Volume managedVolume = findVirtualVolumeManagedByVipr(info);
                UnManagedVolume unmanagedVolume = findUnmanagedVolumeKnownToVipr(info);
                if (null == managedVolume) {
                    s_logger.info("Virtual Volume {} is not managed by ViPR", name);
                    if (null != unmanagedVolume) {
                        // just refresh / update the existing unmanaged volume
                        s_logger.info("Unmanaged Volume {} is already known to ViPR", name);
                        updateUnmanagedVolume(info, vplex, unmanagedVolume, volumesToCgs, clusterIdToNameMap, varrayToClusterIdMap, distributedDevicePathToClusterMap, backendVolumeGuidToVvolGuidMap, volumeToStorageViewMap, allVpools);
                        knownUnmanagedVolumes.add(unmanagedVolume);
                    } else {
                        // set up new unmanaged vplex volume
                        s_logger.info("Unmanaged Volume {} is not known to ViPR", name);
                        unmanagedVolume = createUnmanagedVolume(info, vplex, volumesToCgs, clusterIdToNameMap, varrayToClusterIdMap, distributedDevicePathToClusterMap, backendVolumeGuidToVvolGuidMap, volumeToStorageViewMap, allVpools);
                        newUnmanagedVolumes.add(unmanagedVolume);
                    }
                    boolean nonRpExported = false;
                    Set<UnManagedExportMask> uems = volumeToExportMasksMap.get(unmanagedVolume.getNativeGuid());
                    if (uems != null) {
                        s_logger.info("{} UnManagedExportMasks found in the map for volume {}", uems.size(), unmanagedVolume.getNativeGuid());
                        for (UnManagedExportMask uem : uems) {
                            s_logger.info("   adding UnManagedExportMask {} to UnManagedVolume", uem.getMaskingViewPath());
                            unmanagedVolume.getUnmanagedExportMasks().add(uem.getId().toString());
                            uem.getUnmanagedVolumeUris().add(unmanagedVolume.getId().toString());
                            unmanagedExportMasksToUpdate.add(uem);
                            // add the known initiators, too
                            for (String initUri : uem.getKnownInitiatorUris()) {
                                s_logger.info("   adding known Initiator URI {} to UnManagedVolume", initUri);
                                unmanagedVolume.getInitiatorUris().add(initUri);
                                Initiator init = _dbClient.queryObject(Initiator.class, URI.create(initUri));
                                unmanagedVolume.getInitiatorNetworkIds().add(init.getInitiatorPort());
                            }
                            // log this info for debugging
                            for (String path : uem.getUnmanagedInitiatorNetworkIds()) {
                                s_logger.info("   UnManagedExportMask has this initiator unknown to ViPR: {}", path);
                            }
                            // volume if it is
                            if (!recoverPointExportMasks.isEmpty() && recoverPointExportMasks.contains(uem.getId().toString())) {
                                s_logger.info("unmanaged volume {} is an RP volume", unmanagedVolume.getLabel());
                                unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_RECOVERPOINT_ENABLED.toString(), TRUE);
                            } else {
                                // this volume is contained in at least one export mask that is non-RP
                                nonRpExported = true;
                            }
                        }
                    }
                    persistUnManagedExportMasks(null, unmanagedExportMasksToUpdate, false);
                    // this as a convenience to ingest features.
                    if (nonRpExported) {
                        s_logger.info("unmanaged volume {} is exported to something other than RP.  Marking IS_NONRP_EXPORTED.", unmanagedVolume.getLabel());
                        unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), TRUE);
                        unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), TRUE);
                    } else {
                        s_logger.info("unmanaged volume {} is not exported OR not exported to something other than RP.  Not marking IS_NONRP_EXPORTED.", unmanagedVolume.getLabel());
                        unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_NONRP_EXPORTED.toString(), FALSE);
                        unmanagedVolume.putVolumeCharacterstics(SupportedVolumeCharacterstics.IS_VOLUME_EXPORTED.toString(), FALSE);
                    }
                    persistUnManagedVolumes(newUnmanagedVolumes, knownUnmanagedVolumes, false);
                } else {
                    s_logger.info("Virtual Volume {} is already managed by ViPR", managedVolume.forDisplay());
                    Long currentCapacity = info.getCapacityBytes();
                    if (currentCapacity != null && currentCapacity > managedVolume.getCapacity()) {
                        // update the managed volume's capacity if it changed. this could possibly happen
                        // if the volume were expanded and the final status was not processed successfully by ViPR due to timeout
                        s_logger.info("Virtual Volume {} capacity on VPLEX is different ({}) than in database ({}), updating...", managedVolume.forDisplay(), info.getCapacityBytes(), managedVolume.getCapacity());
                        managedVolume.setAllocatedCapacity(Long.parseLong(String.valueOf(0)));
                        managedVolume.setProvisionedCapacity(currentCapacity);
                        managedVolume.setCapacity(currentCapacity);
                        _dbClient.updateObject(managedVolume);
                    }
                }
                if (null != unmanagedVolume && !unmanagedVolume.getInactive()) {
                    allUnmanagedVolumes.add(unmanagedVolume.getId());
                }
                tracker.volumeTimeResults.put(name, System.currentTimeMillis() - timer);
                tracker.totalVolumesDiscovered++;
                s_logger.info("estimated discovery time remaining: " + tracker.getDiscoveryTimeRemaining());
            }
        } else {
            s_logger.warn("No virtual volumes were found on VPLEX.");
        }
        persistUnManagedVolumes(newUnmanagedVolumes, knownUnmanagedVolumes, true);
        persistUnManagedExportMasks(null, unmanagedExportMasksToUpdate, true);
        cleanUpOrphanedVolumes(vplex.getId(), allUnmanagedVolumes);
        // this has to happen at the very end so that the map is complete,
        // and by supplying the vplex id, we'll re-fetch all the volumes
        // now that everything has been persisted and orphans cleared out
        processBackendClones(vplex.getId(), backendVolumeGuidToVvolGuidMap);
    } catch (Exception ex) {
        s_logger.error("An error occurred during VPLEX unmanaged volume discovery", ex);
        String vplexLabel = vplexUri.toString();
        if (null != vplex) {
            vplexLabel = vplex.getLabel();
        }
        throw VPlexCollectionException.exceptions.vplexUnmanagedVolumeDiscoveryFailed(vplexLabel, ex.toString());
    } finally {
        if (null != vplex) {
            try {
                vplex.setLastDiscoveryStatusMessage(statusMessage);
                _dbClient.updateObject(vplex);
            } catch (Exception ex) {
                s_logger.error("Error while saving VPLEX discovery status message: {} - Exception: {}", statusMessage, ex.getLocalizedMessage());
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) URI(java.net.URI) VPlexVirtualVolumeInfo(com.emc.storageos.vplex.api.VPlexVirtualVolumeInfo) Initiator(com.emc.storageos.db.client.model.Initiator) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VPlexApiException(com.emc.storageos.vplex.api.VPlexApiException) VPlexCollectionException(com.emc.storageos.plugins.metering.vplex.VPlexCollectionException) IOException(java.io.IOException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) VPlexConsistencyGroupInfo(com.emc.storageos.vplex.api.VPlexConsistencyGroupInfo)

Example 19 with UnManagedExportMask

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

the class StorageVolumeInfoProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    CloseableIterator<CIMInstance> volumeInstances = null;
    EnumerateResponse<CIMInstance> volumeInstanceChunks = null;
    CIMObjectPath storagePoolPath = null;
    WBEMClient client = null;
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        client = SMICommunicationInterface.getCIMClient(keyMap);
        _profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        Map<String, VolHostIOObject> exportedVolumes = (Map<String, VolHostIOObject>) keyMap.get(Constants.EXPORTED_VOLUMES);
        Set<String> existingVolumesInCG = (Set<String>) keyMap.get(Constants.VOLUMES_PART_OF_CG);
        @SuppressWarnings("unchecked") Map<String, RemoteMirrorObject> volumeToRAGroupMap = (Map<String, RemoteMirrorObject>) keyMap.get(Constants.UN_VOLUME_RAGROUP_MAP);
        @SuppressWarnings("unchecked") Map<String, LocalReplicaObject> volumeToLocalReplicaMap = (Map<String, LocalReplicaObject>) keyMap.get(Constants.UN_VOLUME_LOCAL_REPLICA_MAP);
        @SuppressWarnings("unchecked") Map<String, Map<String, String>> volumeToSyncAspectMap = (Map<String, Map<String, String>>) keyMap.get(Constants.SNAPSHOT_NAMES_SYNCHRONIZATION_ASPECT_MAP);
        @SuppressWarnings("unchecked") Map<String, Set<String>> duplicateSyncAspectElementNameMap = (Map<String, Set<String>>) keyMap.get(Constants.DUPLICATE_SYNC_ASPECT_ELEMENT_NAME_MAP);
        @SuppressWarnings("unchecked") Map<String, Set<String>> vmax2ThinPoolToBoundVolumesMap = (Map<String, Set<String>>) keyMap.get(Constants.VMAX2_THIN_POOL_TO_BOUND_VOLUMES);
        Set<String> boundVolumes = null;
        storagePoolPath = getObjectPathfromCIMArgument(_args);
        String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(storagePoolPath);
        StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
        if (pool == null) {
            _logger.error("Skipping unmanaged volume discovery as the storage pool with path {} doesn't exist in ViPR", storagePoolPath.toString());
            return;
        }
        StorageSystem system = _dbClient.queryObject(StorageSystem.class, _profile.getSystemId());
        _unManagedVolumesInsert = new ArrayList<UnManagedVolume>();
        _unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
        _unManagedExportMasksUpdate = new ArrayList<UnManagedExportMask>();
        // get bound volumes list for VMAX2 Thin pools
        boundVolumes = vmax2ThinPoolToBoundVolumesMap.get(storagePoolPath.toString());
        Set<String> poolSupportedSLONames = (Set<String>) keyMap.get(poolNativeGuid);
        _logger.debug("Pool Supporting SLO Names:{}", poolSupportedSLONames);
        _metaVolumeViewPaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES_VIEWS);
        if (_metaVolumeViewPaths == null) {
            _metaVolumeViewPaths = new ArrayList<CIMObjectPath>();
            keyMap.put(Constants.META_VOLUMES_VIEWS, _metaVolumeViewPaths);
        }
        // create empty place holder list for meta volume paths (cannot
        // define this in xml)
        _metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
        if (_metaVolumePaths == null) {
            _metaVolumePaths = new ArrayList<CIMObjectPath>();
            keyMap.put(Constants.META_VOLUMES, _metaVolumePaths);
        }
        _volumeToSpaceConsumedMap = (Map<String, String>) keyMap.get(Constants.VOLUME_SPACE_CONSUMED_MAP);
        // get VolumeInfo Object and inject Fast Policy Name.
        volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
        volumeInstances = volumeInstanceChunks.getResponses();
        Set<URI> srdfEnabledTargetVPools = SRDFUtils.fetchSRDFTargetVirtualPools(_dbClient);
        processVolumes(volumeInstances, keyMap, operation, pool, system, exportedVolumes, existingVolumesInCG, volumeToRAGroupMap, volumeToLocalReplicaMap, volumeToSyncAspectMap, poolSupportedSLONames, boundVolumes, srdfEnabledTargetVPools, duplicateSyncAspectElementNameMap);
        while (!volumeInstanceChunks.isEnd()) {
            _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
            volumeInstanceChunks = client.getInstancesWithPath(storagePoolPath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumes(volumeInstanceChunks.getResponses(), keyMap, operation, pool, system, exportedVolumes, existingVolumesInCG, volumeToRAGroupMap, volumeToLocalReplicaMap, volumeToSyncAspectMap, poolSupportedSLONames, boundVolumes, srdfEnabledTargetVPools, duplicateSyncAspectElementNameMap);
        }
        if (null != _unManagedVolumesUpdate && !_unManagedVolumesUpdate.isEmpty()) {
            _partitionManager.updateAndReIndexInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, UNMANAGED_VOLUME);
        }
        if (null != _unManagedVolumesInsert && !_unManagedVolumesInsert.isEmpty()) {
            _partitionManager.insertInBatches(_unManagedVolumesInsert, getPartitionSize(keyMap), _dbClient, UNMANAGED_VOLUME);
        }
        if (null != _unManagedExportMasksUpdate && !_unManagedExportMasksUpdate.isEmpty()) {
            _partitionManager.updateAndReIndexInBatches(_unManagedExportMasksUpdate, getPartitionSize(keyMap), _dbClient, UNMANAGED_EXPORT_MASK);
        }
        performStorageUnManagedVolumeBookKeeping(pool.getId());
    } catch (Exception e) {
        _logger.error("Processing Storage Volume Information failed :", e);
    } finally {
        _unManagedVolumesInsert = null;
        _unManagedVolumesUpdate = null;
        if (null != volumeInstances) {
            volumeInstances.close();
        }
        if (null != volumeInstanceChunks) {
            try {
                client.closeEnumeration(storagePoolPath, volumeInstanceChunks.getContext());
            } catch (Exception e) {
                _logger.debug("Exception occurred while closing enumeration", e);
            }
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) StoragePool(com.emc.storageos.db.client.model.StoragePool) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) IOException(java.io.IOException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap)

Example 20 with UnManagedExportMask

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

the class ExportProcessor method processResult.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.plugins.common.Processor#processResult(com.emc.storageos.plugins.common.domainmodel.Operation,
     * java.lang.Object, java.util.Map)
     */
@SuppressWarnings("unchecked")
@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    initialize(operation, resultObj, keyMap);
    CloseableIterator<CIMInstance> it = null;
    EnumerateResponse<CIMInstance> response = null;
    List<Initiator> matchedInitiators = new ArrayList<Initiator>();
    List<StoragePort> matchedPorts = new ArrayList<StoragePort>();
    WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
    StringSet knownIniSet = new StringSet();
    StringSet knownNetworkIdSet = new StringSet();
    StringSet knownPortSet = new StringSet();
    StringSet knownVolumeSet = new StringSet();
    try {
        // set lun masking view CIM path
        CIMObjectPath path = this.getObjectPathfromCIMArgument(_args, keyMap);
        UnManagedExportMask mask = this.getUnManagedExportMask(path);
        mask.setMaskingViewPath(path.toString());
        _logger.info("looking at lun masking view: " + path.toString());
        CIMInstance lunMaskingView = client.getInstance(path, false, false, null);
        if (lunMaskingView != null) {
            String maskName = CIMPropertyFactory.getPropertyValue(lunMaskingView, SmisConstants.CP_NAME);
            if (maskName != null) {
                mask.setMaskName(maskName);
            }
            _logger.info("set UnManagedExportMask maskName to " + mask.getMaskName());
        } else {
            _logger.info("lunMaskingView was null");
        }
        CIMProperty<String> deviceIdProperty = (CIMProperty<String>) path.getKey(SmisConstants.CP_DEVICE_ID);
        if (deviceIdProperty != null) {
            mask.setNativeId(deviceIdProperty.getValue());
        }
        _logger.info("set UnManagedExportMask nativeId to " + mask.getNativeId());
        // set storage system id
        URI systemId = (URI) keyMap.get(Constants.SYSTEMID);
        mask.setStorageSystemUri(systemId);
        response = (EnumerateResponse<CIMInstance>) resultObj;
        processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
        while (!response.isEnd()) {
            _logger.info("Processing next Chunk");
            response = client.getInstancesWithPath(Constants.MASKING_PATH, response.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumesAndInitiatorsPaths(response.getResponses(), mask, matchedInitiators, matchedPorts, knownIniSet, knownNetworkIdSet, knownPortSet, knownVolumeSet);
        }
        // CTRL - 8918 - always update the mask with new initiators and volumes.
        mask.replaceNewWithOldResources(knownIniSet, knownNetworkIdSet, knownVolumeSet, knownPortSet);
        // get zones and store them?
        updateZoningMap(mask, matchedInitiators, matchedPorts);
        updateVplexBackendVolumes(mask, matchedInitiators);
        updateRecoverPointVolumes(mask, matchedInitiators);
    } catch (Exception e) {
        _logger.error("something failed", e);
    } finally {
        if (it != null) {
            it.close();
        }
        wrapUp();
        if (response != null) {
            try {
                client.closeEnumeration(Constants.MASKING_PATH, response.getContext());
            } catch (Exception e) {
                _logger.debug("Exception occurred while closing enumeration", e);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Initiator(com.emc.storageos.db.client.model.Initiator) CIMProperty(javax.cim.CIMProperty) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) 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