Search in sources :

Example 1 with AbstractChangeTrackingSet

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

the class BlockRecoverPointIngestOrchestrator method findUnManagedRPExportMask.

/**
 * This unmanaged volume may be associated with several export masks. We need to find the export mask
 * that belongs specifically to the RP protection system supplied.
 *
 * Note: There could only be more than one mask that contains both the protection system's initiators AND the volume which
 * would indicate MetroPoint. In a MetroPoint configuration the VPLEX Distributed Source volume is exported to RP
 * via two different Storage Views. One per VPLEX cluster to two different RPA clusters.
 *
 * @param protectionSystem protection system
 * @param unManagedVolume unmanaged volume
 * @return unmanaged export masks that belong to the protection system that contains the unmanaged volume
 */
private List<UnManagedExportMask> findUnManagedRPExportMask(ProtectionSystem protectionSystem, UnManagedVolume unManagedVolume) {
    List<UnManagedExportMask> unManagedRPExportMasks = new ArrayList<UnManagedExportMask>();
    for (String maskIdStr : unManagedVolume.getUnmanagedExportMasks()) {
        // Find the mask associated with the protection system.
        UnManagedExportMask em = _dbClient.queryObject(UnManagedExportMask.class, URI.create(maskIdStr));
        if (em == null) {
            _logger.error("UnManagedExportMask with ID: " + maskIdStr + " could not be found in DB.  Could already be ingested.");
            continue;
        }
        // Check for unlikely conditions on the mask, such as no initiators assigned.
        if (em.getKnownInitiatorNetworkIds() == null || em.getKnownInitiatorNetworkIds().isEmpty()) {
            _logger.error("UnManagedExportMask with ID: " + maskIdStr + " does not contain any RP initiators.  Ignoring for ingestion.");
            continue;
        }
        boolean foundMask = false;
        for (String wwn : em.getKnownInitiatorNetworkIds()) {
            for (Entry<String, AbstractChangeTrackingSet<String>> siteInitEntry : protectionSystem.getSiteInitiators().entrySet()) {
                if (siteInitEntry.getValue().contains(wwn)) {
                    _logger.info(String.format("UnManagedVolume %s was found in UnManagedExportMask %s and will be ingested (if not ingested already)", unManagedVolume.getLabel(), em.getMaskName()));
                    unManagedRPExportMasks.add(em);
                    foundMask = true;
                    break;
                }
            }
            if (foundMask) {
                break;
            }
        }
    }
    return unManagedRPExportMasks;
}
Also used : ArrayList(java.util.ArrayList) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 2 with AbstractChangeTrackingSet

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

the class BlockVplexCGIngestDecorator method decorateCG.

@Override
public void decorateCG(BlockConsistencyGroup cg, Collection<BlockObject> associatedObjects, IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) throws Exception {
    if (null == associatedObjects || associatedObjects.isEmpty()) {
        logger.info("No associated BlockObject's found for cg {}", cg.getLabel());
        return;
    }
    for (BlockObject blockObj : associatedObjects) {
        StringSetMap systemCGs = cg.getSystemConsistencyGroups();
        // No entries yet in the system consistency groups list. That's OK, we'll create it.
        if (null == systemCGs || systemCGs.isEmpty()) {
            cg.setSystemConsistencyGroups(new StringSetMap());
        }
        // This volume is not in a CG of this type
        if (NullColumnValueGetter.isNullValue(blockObj.getReplicationGroupInstance())) {
            logger.info("BlockObject {} doesn't have replicationGroup name {}. No need to set system cg information.", blockObj.getNativeGuid());
            continue;
        }
        boolean found = false;
        // Look through the existing entries in the CG and see if we find a match.
        for (Entry<String, AbstractChangeTrackingSet<String>> systemCGEntry : systemCGs.entrySet()) {
            if (systemCGEntry.getKey().equalsIgnoreCase(blockObj.getStorageController().toString())) {
                if (checkIfCGNameAlreadyExists(systemCGEntry.getValue(), blockObj.getReplicationGroupInstance())) {
                    logger.info(String.format("Found BlockObject %s,%s system details in cg %s", blockObj.getNativeGuid(), blockObj.getReplicationGroupInstance(), cg.getLabel()));
                    found = true;
                    break;
                }
            }
        }
        // If we didn't find this storage:cg combo, let's add it.
        if (!found) {
            logger.info(String.format("Adding BlockObject %s/%s in CG %s", blockObj.getNativeGuid(), blockObj.getReplicationGroupInstance(), cg.getLabel()));
            if (blockObj instanceof Volume) {
                Volume volume = (Volume) blockObj;
                if (volume.getAssociatedVolumes() != null && volume.getAssociatedVolumes().size() > 1) {
                    // Since this is a distributed volume, ensure there is a CG entry for each cluster
                    String cgName = BlockConsistencyGroupUtils.fetchCgName(volume.getReplicationGroupInstance());
                    cg.addSystemConsistencyGroup(volume.getStorageController().toString(), BlockConsistencyGroupUtils.buildClusterCgName(BlockConsistencyGroupUtils.CLUSTER_1, cgName));
                    cg.addSystemConsistencyGroup(volume.getStorageController().toString(), BlockConsistencyGroupUtils.buildClusterCgName(BlockConsistencyGroupUtils.CLUSTER_2, cgName));
                    logger.info(String.format("Found BlockObject [%s] is a Distributed VPLEX volume. " + "Adding cg entry [%s] for both cluster1 and cluster2.", blockObj.getNativeGuid(), cgName));
                } else {
                    cg.addSystemConsistencyGroup(volume.getStorageController().toString(), volume.getReplicationGroupInstance());
                }
            }
        }
        // the virtual volume's replicationGroupInstance reference.  This does not impact the backing volumes.
        if (blockObj instanceof Volume) {
            Volume volume = (Volume) blockObj;
            logger.info(String.format("Moving replication group instance name %s on virtual volume %s to backingReplicationGroupInstance", volume.getReplicationGroupInstance(), volume.getLabel()));
            volume.setBackingReplicationGroupInstance(volume.getReplicationGroupInstance());
            volume.setReplicationGroupInstance(NullColumnValueGetter.getNullStr());
            requestContext.addDataObjectToUpdate(volume, unManagedVolume);
            if (volume.getAssociatedVolumes() != null) {
                // setting BlockConsistencyGroup on the backend volumes
                for (String volumeUriStr : volume.getAssociatedVolumes()) {
                    BlockObject backendVolume = requestContext.findDataObjectByType(Volume.class, URI.create(volumeUriStr), true);
                    if (backendVolume != null) {
                        logger.info("Setting BlockConsistencyGroup {} on VPLEX backend Volume {}", cg.forDisplay(), backendVolume.forDisplay());
                        backendVolume.setConsistencyGroup(cg.getId());
                    // this volume is already set for creation by its parent volume context
                    // so there's no need to add it into an updated objects collection at this point
                    }
                }
            }
        }
        if (!cg.getTypes().contains(Types.VPLEX.toString())) {
            cg.getTypes().add(Types.VPLEX.toString());
        }
    }
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 3 with AbstractChangeTrackingSet

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

the class RegistryImpl method getDriverAttributesForKey.

@Override
public Map<String, List<String>> getDriverAttributesForKey(String driverName, String key) {
    validateRegistryRequest(driverName, key);
    Map<String, List<String>> attributesMap = new HashMap<>();
    // find existing entry for driver name and a given key
    URIQueryResultList registryEntriesUris = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getDriverRegistryEntriesByDriverName(driverName), registryEntriesUris);
    while (registryEntriesUris.iterator().hasNext()) {
        URI registryEntryUri = registryEntriesUris.iterator().next();
        DriverRegistryRecord registryEntry = dbClient.queryObject(DriverRegistryRecord.class, registryEntryUri);
        if (registryEntry.getRegistryKey().equals(key)) {
            StringSetMap attributes = registryEntry.getAttributes();
            for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : attributes.entrySet()) {
                attributesMap.put(entry.getKey(), new ArrayList<>(entry.getValue()));
            }
            break;
        }
    }
    return attributesMap;
}
Also used : DriverRegistryRecord(com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) URI(java.net.URI) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Map(java.util.Map) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 4 with AbstractChangeTrackingSet

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

the class RegistryImpl method getDriverAttributes.

@Override
public Map<String, Map<String, List<String>>> getDriverAttributes(String driverName) {
    Map<String, Map<String, List<String>>> keyMap = new HashMap<>();
    // find existing entries for driver name
    URIQueryResultList registryEntriesUris = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getDriverRegistryEntriesByDriverName(driverName), registryEntriesUris);
    while (registryEntriesUris.iterator().hasNext()) {
        Map<String, List<String>> attributesMap = new HashMap<>();
        URI registryEntryUri = registryEntriesUris.iterator().next();
        DriverRegistryRecord registryEntry = dbClient.queryObject(DriverRegistryRecord.class, registryEntryUri);
        StringSetMap attributes = registryEntry.getAttributes();
        for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : attributes.entrySet()) {
            attributesMap.put(entry.getKey(), new ArrayList<>(entry.getValue()));
        }
        keyMap.put(registryEntry.getRegistryKey(), attributesMap);
    }
    return keyMap;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) HashMap(java.util.HashMap) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DriverRegistryRecord(com.emc.storageos.db.client.model.storagedriver.DriverRegistryRecord) ArrayList(java.util.ArrayList) List(java.util.List) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap) Map(java.util.Map) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Example 5 with AbstractChangeTrackingSet

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

the class ConnectivityUtil method getProtectionSystemsForStoragePool.

/**
 * Gets a list of the RP Protection systems for the passed pool.
 *
 * @param dbClient Reference to a DB client
 * @param storagePool Reference to a storage pool
 * @param varrayId Optional, filter by varray
 * @param isRPVPlex Optional, specifies whether or not this is an RP+VPLEX/MetroPoint request
 *
 * @return A list of the RP protection systems.
 */
public static Set<ProtectionSystem> getProtectionSystemsForStoragePool(DbClient dbClient, StoragePool storagePool, URI varrayId, boolean isRPVPlex) {
    Set<ProtectionSystem> rpSystems = new HashSet<ProtectionSystem>();
    Set<ProtectionSystem> rpSystemsWithIsolatedVarrayEntry = new HashSet<ProtectionSystem>();
    List<String> isolatedRPSites = new ArrayList<String>();
    List<String> storageSystems = new ArrayList<String>();
    _log.info(String.format("Find Protection Systems using the Storage System of Storage pool [%s]", storagePool.getLabel()));
    // the VPLEX.
    if (isRPVPlex) {
        _log.info(String.format("RP+VPlex/MetroPoint - only consider Protection Systems associated to the VPLEX."));
        // Get the VPLEXs associated with the Storage Pool
        List<String> vplexSystemsForPool = VPlexHighAvailabilityMatcher.getVPlexStorageSystemsForStorageSystem(dbClient, storagePool.getStorageDevice(), null);
        // Loop through all the VPLEXs
        for (String vplexId : vplexSystemsForPool) {
            if (varrayId != null) {
                // Find the VPLEX(s) that are associated to this varray
                List<URI> vplexVarrays = ConnectivityUtil.getVPlexSystemVarrays(dbClient, URI.create(vplexId));
                if (vplexVarrays.contains(varrayId)) {
                    _log.info(String.format("Candidate VPLEX Storage System [%s]", vplexId));
                    storageSystems.add(vplexId);
                }
            } else {
                _log.info(String.format("Candidate VPLEX Storage System [%s]", vplexId));
                storageSystems.add(vplexId);
            }
        }
    } else {
        _log.info(String.format("Candidate Storage System [%s]", storagePool.getStorageDevice().toASCIIString()));
        storageSystems.add(storagePool.getStorageDevice().toASCIIString());
    }
    // Find all the Protection Systems for these Storage Systems
    for (String storageSystemId : storageSystems) {
        Set<URI> rpSystemURIs = ConnectivityUtil.getProtectionSystemsAssociatedWithArray(dbClient, URI.create(storageSystemId));
        for (URI uri : rpSystemURIs) {
            ProtectionSystem ps = dbClient.queryObject(ProtectionSystem.class, uri);
            // Make sure the ProtectionSystem is active
            if (ps != null && !ps.getInactive()) {
                // We could be isolating the varray in question to specific RPA clusters/sites.
                // If there is an entry for this varray in the siteAssignedVirtualArrays field
                // we need to honour that isolation and only return Protection Systems
                // with an entry for that varray.
                boolean varrayHasBeenIsolated = false;
                if (varrayId != null) {
                    if (ps.getSiteAssignedVirtualArrays() != null && !ps.getSiteAssignedVirtualArrays().isEmpty()) {
                        // Loop over all entries to see if this Protection System has an entry for this varray to be isolated
                        for (Map.Entry<String, AbstractChangeTrackingSet<String>> entry : ps.getSiteAssignedVirtualArrays().entrySet()) {
                            // Check to see if this entry contains the varray
                            if (entry.getValue().contains(varrayId.toString())) {
                                // This varray has been isolated to a RP cluster/site
                                varrayHasBeenIsolated = true;
                                isolatedRPSites.add(entry.getKey());
                                break;
                            }
                        }
                    }
                }
                _log.info(String.format("Found Protection System [%s]", ps.getLabel()));
                if (varrayHasBeenIsolated) {
                    rpSystemsWithIsolatedVarrayEntry.add(ps);
                } else {
                    rpSystems.add(ps);
                }
            } else {
                _log.info(String.format("Excluding ProtectionSystem %s because it is inactive or invalid.", uri));
            }
        }
    }
    // connectivity.
    if (!rpSystemsWithIsolatedVarrayEntry.isEmpty()) {
        // Only use RP Systems that have an entry for this varray,
        // we will ignore the others.
        rpSystems = rpSystemsWithIsolatedVarrayEntry;
        StringBuffer logMsg = new StringBuffer();
        logMsg.append(String.format("Varray [%s] has been isolated to these RP Sites: %s %n", varrayId.toString(), Joiner.on(',').join(isolatedRPSites)));
        logMsg.append("Therefore only these Protection Systems can be used: ");
        for (ProtectionSystem ps : rpSystems) {
            logMsg.append(ps.getLabel() + " ");
        }
        _log.info(logMsg.toString());
    }
    return rpSystems;
}
Also used : ArrayList(java.util.ArrayList) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) URI(java.net.URI) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) AbstractChangeTrackingSet(com.emc.storageos.db.client.model.AbstractChangeTrackingSet)

Aggregations

AbstractChangeTrackingSet (com.emc.storageos.db.client.model.AbstractChangeTrackingSet)19 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)11 URI (java.net.URI)10 ArrayList (java.util.ArrayList)9 Map (java.util.Map)9 HashMap (java.util.HashMap)7 AbstractChangeTrackingMap (com.emc.storageos.db.client.model.AbstractChangeTrackingMap)4 DataObject (com.emc.storageos.db.client.model.DataObject)4 StringMap (com.emc.storageos.db.client.model.StringMap)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 AbstractChangeTrackingSetMap (com.emc.storageos.db.client.model.AbstractChangeTrackingSetMap)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)3 StringSet (com.emc.storageos.db.client.model.StringSet)3 HashSet (java.util.HashSet)3 List (java.util.List)3 AbstractSerializableNestedObject (com.emc.storageos.db.client.model.AbstractSerializableNestedObject)2 BlockObject (com.emc.storageos.db.client.model.BlockObject)2 Initiator (com.emc.storageos.db.client.model.Initiator)2