Search in sources :

Example 61 with UnManagedVolume

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

the class RPUnManagedObjectDiscoverer method findUnManagedVolumeForWwn.

/**
 * Find an UnManagedVolume for the given WWN by first checking in the
 * UnManagedVolumesToUpdate collection (in case we've already fetched it
 * and updated it elsewhere), and then check the database.
 *
 * @param wwn the WWN to find an UnManagedVolume for
 * @param dbClient a reference to the database client
 * @param cachedStorageNativeIds see comments, cached list of storage native GUIDs
 * @return an UnManagedVolume object for the given WWN
 */
private UnManagedVolume findUnManagedVolumeForWwn(String wwn, DbClient dbClient, List<String> cachedStorageNativeIds) {
    UnManagedVolume unManagedVolume = unManagedVolumesToUpdateByWwn.get(wwn);
    if (null == unManagedVolume) {
        unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDBByWwn(dbClient, wwn);
    }
    // Someday RP will return the short WWN in the CG information and this inefficient code can be removed.
    if (null == unManagedVolume && cachedStorageNativeIds != null) {
        for (String storageNativeIdPrefix : cachedStorageNativeIds) {
            // Search for the unmanaged volume based on the native GUID
            String searchCriteria = storageNativeIdPrefix + "+UNMANAGEDVOLUME+" + wwn.toLowerCase();
            List<UnManagedVolume> volumes = CustomQueryUtility.getUnManagedVolumeByNativeGuid(dbClient, searchCriteria);
            if (volumes != null && !volumes.isEmpty()) {
                log.info("Found XIO unmanaged volume: " + volumes.get(0).getLabel());
                return volumes.get(0);
            }
        }
    }
    return unManagedVolume;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)

Example 62 with UnManagedVolume

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

the class RPUnManagedObjectDiscoverer method discoverUnManagedObjects.

/**
 * Discovers the RP CGs and all the volumes therein. It updates/creates the UnManagedProtectionSet
 * objects and updates (if it exists) the UnManagedVolume objects with RP information needed for
 * ingestion
 *
 * @param accessProfile access profile
 * @param dbClient db client
 * @param partitionManager partition manager
 * @throws Exception
 */
public void discoverUnManagedObjects(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) throws Exception {
    this.partitionManager = partitionManager;
    log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
    ProtectionSystem protectionSystem = dbClient.queryObject(ProtectionSystem.class, accessProfile.getSystemId());
    if (protectionSystem == null) {
        log.error("Discovery is not run!  Protection System not found: " + accessProfile.getSystemId());
        return;
    }
    RecoverPointClient rp = RPHelper.getRecoverPointClient(protectionSystem);
    unManagedCGsInsert = new ArrayList<UnManagedProtectionSet>();
    unManagedCGsUpdate = new ArrayList<UnManagedProtectionSet>();
    unManagedVolumesToDelete = new ArrayList<UnManagedVolume>();
    unManagedVolumesToUpdateByWwn = new HashMap<String, UnManagedVolume>();
    unManagedCGsReturnedFromProvider = new HashSet<URI>();
    // Get all of the consistency groups (and their volumes) from RP
    Set<GetCGsResponse> cgs = rp.getAllCGs();
    if (cgs == null) {
        log.warn("No CGs were found on protection system: " + protectionSystem.getLabel());
        return;
    }
    // This section of code allows us to cache XIO native GUID to workaround an issue
    // with RP's understanding of XIO volume WWNs (128-bit) and the rest of the world's
    // understanding of the XIO volume WWN once it's exported (64-bit)
    Map<String, String> rpWwnToNativeWwn = new HashMap<String, String>();
    List<URI> storageSystemIds = dbClient.queryByType(StorageSystem.class, true);
    List<String> storageNativeIdPrefixes = new ArrayList<String>();
    if (storageSystemIds != null) {
        Iterator<StorageSystem> storageSystemsItr = dbClient.queryIterativeObjects(StorageSystem.class, storageSystemIds);
        while (storageSystemsItr.hasNext()) {
            StorageSystem storageSystem = storageSystemsItr.next();
            if (storageSystem.getSystemType().equalsIgnoreCase(Type.xtremio.name())) {
                storageNativeIdPrefixes.add(storageSystem.getNativeGuid());
            }
        }
    }
    for (GetCGsResponse cg : cgs) {
        try {
            log.info("Processing returned CG: " + cg.getCgName());
            boolean newCG = false;
            // UnManagedProtectionSet native GUID is protection system GUID + consistency group ID
            String nativeGuid = protectionSystem.getNativeGuid() + Constants.PLUS + cg.getCgId();
            // First check to see if this protection set is already part of our managed DB
            if (null != DiscoveryUtils.checkProtectionSetExistsInDB(dbClient, nativeGuid)) {
                log.info("Protection Set " + nativeGuid + " already is managed by ViPR, skipping unmanaged discovery");
                continue;
            }
            // Now check to see if the unmanaged CG exists in the database
            UnManagedProtectionSet unManagedProtectionSet = DiscoveryUtils.checkUnManagedProtectionSetExistsInDB(dbClient, nativeGuid);
            if (null == unManagedProtectionSet) {
                log.info("Creating new unmanaged protection set for CG: " + cg.getCgName());
                unManagedProtectionSet = new UnManagedProtectionSet();
                unManagedProtectionSet.setId(URIUtil.createId(UnManagedProtectionSet.class));
                unManagedProtectionSet.setNativeGuid(nativeGuid);
                unManagedProtectionSet.setProtectionSystemUri(protectionSystem.getId());
                StringSet protectionId = new StringSet();
                protectionId.add("" + cg.getCgId());
                unManagedProtectionSet.putCGInfo(SupportedCGInformation.PROTECTION_ID.toString(), protectionId);
                // Default MP to false until proven otherwise
                unManagedProtectionSet.getCGCharacteristics().put(UnManagedProtectionSet.SupportedCGCharacteristics.IS_MP.name(), Boolean.FALSE.toString());
                newCG = true;
            } else {
                log.info("Found existing unmanaged protection set for CG: " + cg.getCgName() + ", using " + unManagedProtectionSet.getId().toString());
            }
            unManagedCGsReturnedFromProvider.add(unManagedProtectionSet.getId());
            // Update the fields for the CG
            unManagedProtectionSet.setCgName(cg.getCgName());
            unManagedProtectionSet.setLabel(cg.getCgName());
            // Indicate whether the CG is in a healthy state or not to ingest.
            unManagedProtectionSet.getCGCharacteristics().put(UnManagedProtectionSet.SupportedCGCharacteristics.IS_HEALTHY.name(), cg.getCgState().equals(GetCGStateResponse.HEALTHY) ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
            // Indicate whether the CG is sync or async
            unManagedProtectionSet.getCGCharacteristics().put(UnManagedProtectionSet.SupportedCGCharacteristics.IS_SYNC.name(), cg.getCgPolicy().synchronous ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
            // Fill in RPO type and value information
            StringSet rpoType = new StringSet();
            rpoType.add(cg.getCgPolicy().rpoType);
            unManagedProtectionSet.putCGInfo(SupportedCGInformation.RPO_TYPE.toString(), rpoType);
            StringSet rpoValue = new StringSet();
            rpoValue.add(cg.getCgPolicy().rpoValue.toString());
            unManagedProtectionSet.putCGInfo(SupportedCGInformation.RPO_VALUE.toString(), rpoValue);
            if (null == cg.getCopies()) {
                log.info("Protection Set " + nativeGuid + " does not contain any copies.  Skipping...");
                continue;
            }
            if (null == cg.getRsets()) {
                log.info("Protection Set " + nativeGuid + " does not contain any replication sets.  Skipping...");
                continue;
            }
            // clean up the existing journal and replicationsets info in the unmanaged protection set, so that updated info is populated
            if (!newCG) {
                cleanUpUnManagedResources(unManagedProtectionSet, unManagedVolumesToUpdateByWwn, dbClient);
            }
            // Now map UnManagedVolume objects to the journal and rset (sources/targets) and put RP fields in them
            Map<String, String> rpCopyAccessStateMap = new HashMap<String, String>();
            mapCgJournals(unManagedProtectionSet, cg, rpCopyAccessStateMap, rpWwnToNativeWwn, storageNativeIdPrefixes, dbClient);
            mapCgSourceAndTargets(unManagedProtectionSet, cg, rpCopyAccessStateMap, rpWwnToNativeWwn, storageNativeIdPrefixes, dbClient);
            if (newCG) {
                unManagedCGsInsert.add(unManagedProtectionSet);
            } else {
                unManagedCGsUpdate.add(unManagedProtectionSet);
            }
        } catch (Exception ex) {
            log.error("Error processing RP CG {}", cg.getCgName(), ex);
        }
    }
    handlePersistence(dbClient, false);
    cleanUp(protectionSystem, dbClient);
}
Also used : GetCGsResponse(com.emc.storageos.recoverpoint.responses.GetCGsResponse) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) UnManagedProtectionSet(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet) URI(java.net.URI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) RecoverPointClient(com.emc.storageos.recoverpoint.impl.RecoverPointClient) StringSet(com.emc.storageos.db.client.model.StringSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 63 with UnManagedVolume

use of com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume 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 64 with UnManagedVolume

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

the class DiscoveryUtils method addParentMatchedVpoolsIfVplexBackendVolume.

/**
 * Add any matched virtual pools in the parent volume if the unManagedVolume is
 * a VPLEX backend volume.
 *
 * @param volume the UnManagedVolume in question
 * @param matchedVPools the StringSet of vpool URIs to add to
 * @param dbClient a reference to the database client
 */
public static void addParentMatchedVpoolsIfVplexBackendVolume(UnManagedVolume unManagedVolume, StringSet matchedVPools, DbClient dbClient) {
    if (null == unManagedVolume || null == unManagedVolume.getVolumeCharacterstics()) {
        return;
    }
    String status = unManagedVolume.getVolumeCharacterstics().get(SupportedVolumeCharacterstics.IS_VPLEX_BACKEND_VOLUME.toString());
    if (TRUE.equals(status)) {
        String vplexParentVolume = VplexBackendIngestionContext.extractValueFromStringSet(SupportedVolumeInformation.VPLEX_PARENT_VOLUME.toString(), unManagedVolume.getVolumeInformation());
        if (StringUtils.isNotEmpty(vplexParentVolume)) {
            URIQueryResultList unManagedVolumeList = new URIQueryResultList();
            dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(vplexParentVolume), unManagedVolumeList);
            if (unManagedVolumeList.iterator().hasNext()) {
                UnManagedVolume parentVolume = dbClient.queryObject(UnManagedVolume.class, unManagedVolumeList.iterator().next());
                StringSet parentMatchedPools = parentVolume.getSupportedVpoolUris();
                if (parentMatchedPools != null && !parentMatchedPools.isEmpty()) {
                    _log.info("Adding the following matched vpools from VPLEX parent volume {} to backend volume {}: {}", parentVolume.getLabel(), unManagedVolume.getLabel(), parentMatchedPools);
                    matchedVPools.addAll(parentMatchedPools);
                }
            }
        }
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 65 with UnManagedVolume

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

the class DiscoveryUtils method checkUnManagedVolumeExistsInDB.

/**
 * check UnManagedVolume exists in DB
 *
 * @param nativeGuid
 * @param dbClient
 * @return
 * @throws IOException
 */
public static UnManagedVolume checkUnManagedVolumeExistsInDB(DbClient dbClient, String nativeGuid) {
    URIQueryResultList unManagedVolumeList = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(nativeGuid), unManagedVolumeList);
    if (unManagedVolumeList.iterator().hasNext()) {
        URI unManagedVolumeURI = unManagedVolumeList.iterator().next();
        UnManagedVolume volumeInfo = dbClient.queryObject(UnManagedVolume.class, unManagedVolumeURI);
        if (!volumeInfo.getInactive()) {
            return volumeInfo;
        }
    }
    return null;
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)146 StringSet (com.emc.storageos.db.client.model.StringSet)66 URI (java.net.URI)53 Volume (com.emc.storageos.db.client.model.Volume)48 ArrayList (java.util.ArrayList)48 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)33 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)31 BlockObject (com.emc.storageos.db.client.model.BlockObject)30 HashMap (java.util.HashMap)29 HashSet (java.util.HashSet)24 NamedURI (com.emc.storageos.db.client.model.NamedURI)19 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)19 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)18 DataObject (com.emc.storageos.db.client.model.DataObject)13 UnManagedExportMask (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask)13 CIMObjectPath (javax.cim.CIMObjectPath)13 UnManagedProtectionSet (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedProtectionSet)12 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)11 Map (java.util.Map)11 StringMap (com.emc.storageos.db.client.model.StringMap)10