Search in sources :

Example 36 with NamedURI

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

the class VolumeIngestionUtil method setupMirrorParentRelations.

/**
 * Setup relationships between a mirror and its parent BlockObject.
 *
 * @param mirror the mirror BlockObject
 * @param parentVolume the mirror's parent BlockObject
 * @param dbClient a reference to the database client
 */
public static void setupMirrorParentRelations(BlockObject mirror, BlockObject parent, DbClient dbClient) {
    _logger.info("Setting up relationship between mirror {} ({}) and parent {} ({})", new Object[] { mirror.getLabel(), mirror.getId(), parent.getLabel(), parent.getId() });
    ((BlockMirror) mirror).setSource(new NamedURI(parent.getId(), parent.getLabel()));
    if (parent instanceof Volume) {
        StringSet mirrors = ((Volume) parent).getMirrors();
        if (mirrors == null) {
            mirrors = new StringSet();
        }
        mirrors.add(mirror.getId().toString());
        ((Volume) parent).setMirrors(mirrors);
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) NamedURI(com.emc.storageos.db.client.model.NamedURI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 37 with NamedURI

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

the class VolumeIngestionUtil method setupSRDFParentRelations.

/**
 * Setup relationships between an SRDF BlockObject and its parent BlockObject.
 *
 * @param targetBlockObj the SRDF source BlockObject
 * @param sourceBlockObj the SRDF target BlockObject
 * @param dbClient a reference to the database client
 */
public static void setupSRDFParentRelations(BlockObject targetBlockObj, BlockObject sourceBlockObj, DbClient dbClient) {
    _logger.info("Setting up relationship between SRDF mirror {} ({}) and parent {} ({})", new Object[] { targetBlockObj.getLabel(), targetBlockObj.getId(), sourceBlockObj.getLabel(), sourceBlockObj.getId() });
    Volume targetVolume = (Volume) targetBlockObj;
    Volume sourceVolume = (Volume) sourceBlockObj;
    targetVolume.setSrdfParent(new NamedURI(sourceBlockObj.getId(), sourceBlockObj.getLabel()));
    targetVolume.setPersonality(PersonalityTypes.TARGET.toString());
    if (sourceBlockObj instanceof Volume) {
        StringSet srdfTargets = sourceVolume.getSrdfTargets();
        if (null == srdfTargets) {
            srdfTargets = new StringSet();
        }
        srdfTargets.add(targetVolume.getId().toString());
        sourceVolume.setSrdfTargets(srdfTargets);
        sourceVolume.setPersonality(PersonalityTypes.SOURCE.toString());
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 38 with NamedURI

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

the class VolumeIngestionUtil method getBlockObjectConsistencyGroup.

/**
 * Creates a BlockConsistencyGroup if it doesn't exist only when we are ingesting the last volume in unmanaged consistencygroup.
 *
 * In case if the volume is protected by RP or VPLEX, we should not create CG.
 *
 * @param unManagedVolume - UnManagedVolume object.
 * @param blockObj - Ingested BlockObject
 * @param context - current unManagedVolume Ingestion context.
 * @param dbClient - dbClient instance.
 * @return BlockConsistencyGroup
 */
public static BlockConsistencyGroup getBlockObjectConsistencyGroup(UnManagedVolume unManagedVolume, BlockObject blockObj, IngestionRequestContext context, DbClient dbClient) {
    UnManagedConsistencyGroup umcg = getUnManagedConsistencyGroup(unManagedVolume, dbClient);
    if (umcg != null) {
        // Check if the UnManagedConsistencyGroup is present in the volume context which should have the updated info
        UnManagedConsistencyGroup umcgInContext = context.findUnManagedConsistencyGroup(umcg.getLabel());
        if (umcgInContext != null) {
            umcg = umcgInContext;
        }
    }
    // CG ingestion support for such volumes.
    if (umcg == null || umcg.getUnManagedVolumesMap() == null) {
        _logger.info("There is no unmanaged consistency group associated with unmanaged volume {}, however " + "the volume has the IS_VOLUME_IN_CONSISTENCYGROUP flag set to true.  Ignoring CG operation" + " as there is not enough information to put this volume in a CG by itself.", unManagedVolume.getNativeGuid());
        return null;
    }
    List<UnManagedConsistencyGroup> umcgsToUpdate = context.getVolumeContext().getUmCGObjectsToUpdate();
    boolean isLastUmvToIngest = isLastUnManagedVolumeToIngest(umcg, unManagedVolume);
    boolean isVplexOrRPProtected = isRPOrVplexProtected(unManagedVolume);
    if (isVplexOrRPProtected || !isLastUmvToIngest) {
        _logger.info("Ignoring the CG creation as the volume is either isVplexRPProtected:{} or isLastUmvToIngest: {} exists to ingest.", isLastUmvToIngest, isVplexOrRPProtected);
        _logger.info("Remaining volumes in CG to ingest: {}", umcg.getUnManagedVolumesMap());
        // set ReplicationGroupInstance in the block object.
        blockObj.setReplicationGroupInstance(umcg.getLabel());
        if (blockObj instanceof BlockSnapshot) {
            // Check if the unmanaged volume has SNAPSHOT_CONSISTENCY_GROUP_NAME property populated. If yes,
            // use that for replicationGroupInstance
            String snapsetName = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.SNAPSHOT_CONSISTENCY_GROUP_NAME.toString(), unManagedVolume.getVolumeInformation());
            if (snapsetName != null && !snapsetName.isEmpty()) {
                blockObj.setReplicationGroupInstance(snapsetName);
            }
        }
        updateVolumeInUnManagedConsistencyGroup(umcg, unManagedVolume, blockObj);
        umcgsToUpdate.add(umcg);
        return null;
    }
    // If the UMV is last volume, mark the UnManagedConsistencyGroup inactive to true.
    if (isLastUmvToIngest) {
        umcg.setInactive(true);
        umcgsToUpdate.add(umcg);
    }
    if (null == umcg || null == umcg.getLabel()) {
        _logger.warn("UnManaged volume {} CG doesn't have label. Hence exiting", unManagedVolume.getNativeGuid());
        return null;
    }
    String cgName = umcg.getLabel();
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, unManagedVolume.getStorageSystemUri());
    _logger.info("UnManagedVolume {} is added to consistency group {}", unManagedVolume.getLabel(), cgName);
    URI projectUri = context.getProject().getId();
    URI tenantUri = context.getTenant().getId();
    URI varrayUri = context.getVarray(unManagedVolume).getId();
    VirtualPool vpool = context.getVpool(unManagedVolume);
    if (!vpool.getMultivolumeConsistency()) {
        _logger.warn("The requested Virtual Pool {} does not have " + "the Multi-Volume Consistency flag set, and this volume " + "is part of a consistency group.", vpool.getLabel());
        throw IngestionException.exceptions.unmanagedVolumeVpoolConsistencyGroupMismatch(vpool.getLabel(), unManagedVolume.getLabel());
    } else {
        List<BlockConsistencyGroup> groups = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, BlockConsistencyGroup.class, PrefixConstraint.Factory.getFullMatchConstraint(BlockConsistencyGroup.class, "label", cgName));
        BlockConsistencyGroup potentialUnclaimedCg = null;
        if (!groups.isEmpty()) {
            for (BlockConsistencyGroup cg : groups) {
                if (validateCGProjectDetails(cg, storageSystem, projectUri, tenantUri, varrayUri, unManagedVolume.getLabel(), cgName, dbClient)) {
                    return cg;
                }
                URI storageControllerUri = cg.getStorageController();
                URI virtualArrayUri = cg.getVirtualArray();
                if (NullColumnValueGetter.isNullURI(storageControllerUri) && NullColumnValueGetter.isNullURI(virtualArrayUri)) {
                    potentialUnclaimedCg = cg;
                }
            }
        }
        // used it yet in creating a volume
        if (null != potentialUnclaimedCg) {
            potentialUnclaimedCg.addConsistencyGroupTypes(Types.LOCAL.name());
            potentialUnclaimedCg.setStorageController(storageSystem.getId());
            potentialUnclaimedCg.setVirtualArray(varrayUri);
            return potentialUnclaimedCg;
        }
        _logger.info(String.format("Did not find an existing CG named %s that is associated already with the requested device %s and Virtual Array %s. ViPR will create a new one.", cgName, storageSystem.getNativeGuid(), varrayUri));
        // create a new consistency group
        BlockConsistencyGroup cg = new BlockConsistencyGroup();
        cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
        cg.setLabel(cgName);
        if (NullColumnValueGetter.isNotNullValue(umcg.getNativeId())) {
            cg.setNativeId(umcg.getNativeId());
        }
        cg.setProject(new NamedURI(projectUri, context.getProject().getLabel()));
        cg.setTenant(context.getProject().getTenantOrg());
        cg.addConsistencyGroupTypes(Types.LOCAL.name());
        cg.addSystemConsistencyGroup(storageSystem.getId().toString(), cgName);
        cg.setStorageController(storageSystem.getId());
        cg.setVirtualArray(varrayUri);
        cg.setArrayConsistency(false);
        return cg;
    }
}
Also used : UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup) NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 39 with NamedURI

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

the class VolumeIngestionUtil method decorateRPVolumesCGInfo.

/**
 * Decorate the RP volumes with the protection set and consistency group info after the RP CG has been fully ingested
 *
 * @param rpVolumes RP Volumes
 * @param pset protection set
 * @param rpCG RP consistency group
 * @param updatedObjects Set of objects updated
 * @param dbClient a reference to the database client
 */
public static void decorateRPVolumesCGInfo(List<Volume> rpVolumes, ProtectionSet pset, BlockConsistencyGroup rpCG, Set<DataObject> updatedObjects, DbClient dbClient, IngestionRequestContext requestContext) {
    for (Volume volume : rpVolumes) {
        // Set references to protection set/CGs properly in each volume
        volume.setConsistencyGroup(rpCG.getId());
        volume.setProtectionSet(new NamedURI(pset.getId(), pset.getLabel()));
        volume.clearInternalFlags(BlockRecoverPointIngestOrchestrator.INTERNAL_VOLUME_FLAGS);
        // Set the proper flags on the journal volumes.
        if (volume.getPersonality().equalsIgnoreCase(Volume.PersonalityTypes.METADATA.toString())) {
            volume.addInternalFlags(Flag.INTERNAL_OBJECT, Flag.SUPPORTS_FORCE);
        }
        _logger.info("Updating volume " + volume.getLabel() + " flags/settings to " + volume.getInternalFlags());
        // Find any backing volumes associated with vplex volumes and add the CG reference to them as well.
        if (volume.isVPlexVolume(dbClient)) {
            // volume may not have been ingested with backend volumes
            if (volume.getAssociatedVolumes() != null) {
                for (String associatedVolumeIdStr : volume.getAssociatedVolumes()) {
                    // Find the associated volumes using the context maps or the db if they are already there
                    Volume associatedVolume = requestContext.findDataObjectByType(Volume.class, URI.create(associatedVolumeIdStr), true);
                    if (associatedVolume != null) {
                        _logger.info("Setting BlockConsistencyGroup {} on VPLEX backend Volume {}", rpCG.forDisplay(), associatedVolume.forDisplay());
                        if (NullColumnValueGetter.isNotNullValue(associatedVolume.getReplicationGroupInstance())) {
                            _logger.info(String.format("Turning on array consistency on the consistency group because CG info exists on volume %s", associatedVolume.getLabel()));
                            rpCG.setArrayConsistency(true);
                        }
                        associatedVolume.setConsistencyGroup(rpCG.getId());
                        updatedObjects.add(associatedVolume);
                    } else {
                        // This may not be a failure if we're not ingesting backing volumes. Put a warning to the log.
                        _logger.warn("Could not find the volume in DB or volume contexts: " + associatedVolumeIdStr);
                    }
                }
            }
        }
        // in a transient way during ingestion and will be cleared at the end of ingestion.
        if (!volume.isVPlexVolume(dbClient) && NullColumnValueGetter.isNotNullValue(volume.getReplicationGroupInstance())) {
            _logger.info(String.format("Turning on array consistency on the consistency group because CG info exists on volume %s", volume.getLabel()));
            rpCG.setArrayConsistency(true);
        }
        updatedObjects.add(volume);
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI)

Example 40 with NamedURI

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

the class VolumeIngestionUtil method setupSnapParentRelations.

/**
 * Setup relationships between a snapshot and its parent BlockObject.
 *
 * @param snapshot the snapshot BlockObject
 * @param parentVolume the snapshot's parent BlockObject
 * @param dbClient a reference to the database client
 */
public static void setupSnapParentRelations(BlockObject snapshot, BlockObject parentVolume, DbClient dbClient) {
    _logger.info("Setting up relationship between snapshot {} ({}) and parent {} ({})", new Object[] { snapshot.getLabel(), snapshot.getId(), parentVolume.getLabel(), parentVolume.getId() });
    ((BlockSnapshot) snapshot).setSourceNativeId(parentVolume.getNativeId());
    ((BlockSnapshot) snapshot).setParent(new NamedURI(parentVolume.getId(), parentVolume.getLabel()));
    snapshot.setProtocol(new StringSet());
    snapshot.getProtocol().addAll(parentVolume.getProtocol());
    URI cgUri = parentVolume.getConsistencyGroup();
    // Do not associate parent's CG if it is a RP protected parent volume
    boolean isRP = (parentVolume instanceof Volume && ((Volume) parentVolume).checkForRp()) || (parentVolume instanceof BlockSnapshot && ((BlockSnapshot) parentVolume).getProtectionController() != null);
    if (!isRP && cgUri != null) {
        snapshot.setConsistencyGroup(cgUri);
    }
// TODO - check how to populate snapsetlabel if in consistency group
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Aggregations

NamedURI (com.emc.storageos.db.client.model.NamedURI)196 URI (java.net.URI)98 Volume (com.emc.storageos.db.client.model.Volume)74 StringSet (com.emc.storageos.db.client.model.StringSet)65 Project (com.emc.storageos.db.client.model.Project)54 ArrayList (java.util.ArrayList)46 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)43 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)42 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)36 Test (org.junit.Test)32 StoragePool (com.emc.storageos.db.client.model.StoragePool)31 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)27 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)26 StringMap (com.emc.storageos.db.client.model.StringMap)26 List (java.util.List)23 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)20 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)20 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)18 FileShare (com.emc.storageos.db.client.model.FileShare)17