Search in sources :

Example 96 with BlockSnapshotSession

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

the class BlockServiceUtils method createFailedTaskOnSnapshotSession.

/**
 * Creates a Task on given snapshot session with Error state
 *
 * @param opr the opr
 * @param session the snap session
 * @param sc the sc
 * @return the failed task for snap session
 */
public static TaskResourceRep createFailedTaskOnSnapshotSession(DbClient dbClient, BlockSnapshotSession session, ResourceOperationTypeEnum opr, ServiceCoded sc) {
    String taskId = UUID.randomUUID().toString();
    Operation op = new Operation();
    op.setResourceType(opr);
    dbClient.createTaskOpStatus(BlockSnapshotSession.class, session.getId(), taskId, op);
    session = dbClient.queryObject(BlockSnapshotSession.class, session.getId());
    op = session.getOpStatus().get(taskId);
    op.error(sc);
    session.getOpStatus().updateTaskStatus(taskId, op);
    dbClient.updateObject(session);
    return TaskMapper.toTask(session, taskId, op);
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) Operation(com.emc.storageos.db.client.model.Operation)

Example 97 with BlockSnapshotSession

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

the class BlockSnapshotSessionUtils method querySnapshotSession.

/**
 * Validates and returns the BlockSnapshotSession instance with the passed URI.
 *
 * @param sourceURI The URI for a BlockSnapshotSession instance.
 * @param uriInfo A reference to the URI information.
 * @param dbClient A reference to a database client.
 * @param checkInactive true to check if the snapshot session is inactive.
 *
 * @return A reference to the BlockSnapshotSession instance.
 */
public static BlockSnapshotSession querySnapshotSession(URI snapSessionURI, UriInfo uriInfo, DbClient dbClient, boolean checkInactive) {
    ArgValidator.checkUri(snapSessionURI);
    BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
    ArgValidator.checkEntity(snapSession, snapSessionURI, BlockServiceUtils.isIdEmbeddedInURL(snapSessionURI, uriInfo), checkInactive);
    return snapSession;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession)

Example 98 with BlockSnapshotSession

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

the class DefaultBlockSnapshotSessionApiImpl method prepareSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public BlockSnapshotSession prepareSnapshotSession(List<BlockObject> sourceObjList, String snapSessionLabel, int newTargetCount, String newTargetsName, List<Map<URI, BlockSnapshot>> snapSessionSnapshots, String taskId, boolean inApplication) {
    // Create a single snap session based on a sample volume in the CG
    BlockObject source = sourceObjList.get(0);
    BlockSnapshotSession snapSession = prepareSnapshotSessionFromSource(source, snapSessionLabel, snapSessionLabel, taskId, inApplication);
    /*
         * If linked targets are requested...
         * 
         * Non-CG case for source ["src"] with 2 targets named "linked":
         * [
         * ["linked-1"],
         * ["linked-2"]
         * ]
         * 
         * CG case for sources ["src-1", "src-2"] with 2 targets named "linked":
         * [
         * ["linked-1-1", "linked-1-2"],
         * ["linked-2-1", "linked-2-2"]
         * ]
         * 
         * i.e. treat non-CG single volumes as single member groups, then for however
         * many target requests, copy each group.
         */
    if (newTargetCount > 0) {
        // Create <newTargetCount> lists of targets
        // Snapset labels use format <newTargetsName>-<currentTargetCount>
        // Labels will look like <snapsetLabel>-<count>
        List<Map<URI, BlockSnapshot>> targetMaps = prepareSnapshotsForSession(sourceObjList, sourceObjList.size(), newTargetCount, newTargetsName, inApplication);
        snapSessionSnapshots.addAll(targetMaps);
    }
    // Create and return the prepared snapshot session.
    _dbClient.createObject(snapSession);
    return snapSession;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) HashMap(java.util.HashMap) Map(java.util.Map) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 99 with BlockSnapshotSession

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

the class DefaultBlockSnapshotSessionApiImpl method prepareSnapshotSessionFromSource.

/**
 * {@inheritDoc}
 */
@Override
public BlockSnapshotSession prepareSnapshotSessionFromSource(BlockObject sourceObj, String snapSessionLabel, String instanceLabel, String taskId, boolean inApplication) {
    BlockSnapshotSession snapSession = new BlockSnapshotSession();
    Project sourceProject = BlockSnapshotSessionUtils.querySnapshotSessionSourceProject(sourceObj, _dbClient);
    snapSession.setId(URIUtil.createId(BlockSnapshotSession.class));
    snapSession.setProject(new NamedURI(sourceProject.getId(), sourceObj.getLabel()));
    snapSession.setStorageController(sourceObj.getStorageController());
    if (NullColumnValueGetter.isNotNullValue(sourceObj.getReplicationGroupInstance())) {
        snapSession.setConsistencyGroup(sourceObj.getConsistencyGroup());
        snapSession.setSessionSetName(snapSessionLabel);
        String rgName = sourceObj.getReplicationGroupInstance();
        if (NullColumnValueGetter.isNotNullValue(rgName)) {
            snapSession.setReplicationGroupInstance(rgName);
            if (inApplication) {
                // append RG name to user given label to uniquely identify sessions
                // when there are multiple RGs in a CG
                instanceLabel = String.format("%s-%s", instanceLabel, rgName);
            }
        }
    } else {
        snapSession.setParent(new NamedURI(sourceObj.getId(), sourceObj.getLabel()));
    }
    snapSession.setLabel(instanceLabel);
    snapSession.setSessionLabel(ResourceOnlyNameGenerator.removeSpecialCharsForName(snapSessionLabel, SmisConstants.MAX_SNAPSHOT_NAME_LENGTH));
    return snapSession;
}
Also used : Project(com.emc.storageos.db.client.model.Project) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) NamedURI(com.emc.storageos.db.client.model.NamedURI)

Example 100 with BlockSnapshotSession

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

the class BlockRecoverPointIngestOrchestrator method clearReplicaFlagsInIngestionContext.

/**
 * Clear the flags of replicas which have been updated during the ingestion process
 *
 * @param volumeContext
 * @param volumes RP volumes
 */
private void clearReplicaFlagsInIngestionContext(RecoverPointVolumeIngestionContext volumeContext, List<Volume> volumes) {
    for (Set<DataObject> updatedObjects : volumeContext.getDataObjectsToBeUpdatedMap().values()) {
        for (DataObject updatedObject : updatedObjects) {
            if (updatedObject instanceof BlockMirror || updatedObject instanceof BlockSnapshot || updatedObject instanceof BlockSnapshotSession || (updatedObject instanceof Volume && !NullColumnValueGetter.isNullURI(((Volume) updatedObject).getAssociatedSourceVolume()))) {
                _logger.info("Clearing internal volume flag of replica {} of RP volume ", updatedObject.getLabel());
                updatedObject.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
            }
        }
    }
    // We need to look for all snapshots and snapshot session in the contexts related to the rp volumes and its backend volumes and
    // clear their flags.
    List<String> rpVolumes = new ArrayList<String>();
    for (Volume volume : volumes) {
        rpVolumes.add(volume.getId().toString());
        if (RPHelper.isVPlexVolume(volume, _dbClient) && volumeContext instanceof RpVplexVolumeIngestionContext) {
            VplexVolumeIngestionContext vplexVolumeContext = ((RpVplexVolumeIngestionContext) volumeContext.getVolumeContext()).getVplexVolumeIngestionContext();
            StringSet associatedVolumes = vplexVolumeContext.getAssociatedVolumeIds(volume);
            rpVolumes.addAll(associatedVolumes);
        }
    }
    for (VolumeIngestionContext volumeIngestionContext : volumeContext.getRootIngestionRequestContext().getProcessedUnManagedVolumeMap().values()) {
        if (volumeIngestionContext instanceof IngestionRequestContext) {
            for (Set<DataObject> objectsToBeUpdated : ((IngestionRequestContext) volumeIngestionContext).getDataObjectsToBeUpdatedMap().values()) {
                for (DataObject o : objectsToBeUpdated) {
                    if (o instanceof BlockSnapshot && rpVolumes.contains(((BlockSnapshot) o).getParent().getURI().toString())) {
                        _logger.info("Clearing internal volume flag of BlockSnapshot {} of RP volume ", o.getLabel());
                        o.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
                    } else if (o instanceof BlockSnapshotSession && rpVolumes.contains(((BlockSnapshotSession) o).getParent().getURI().toString())) {
                        _logger.info("Clearing internal volume flag of BlockSnapshotSession {} of RP volume ", o.getLabel());
                        o.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
                    }
                }
            }
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) DataObject(com.emc.storageos.db.client.model.DataObject) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) IngestionRequestContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.IngestionRequestContext) StringSet(com.emc.storageos.db.client.model.StringSet) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext) VplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.VplexVolumeIngestionContext) RecoverPointVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RecoverPointVolumeIngestionContext) VolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.VolumeIngestionContext) RpVplexVolumeIngestionContext(com.emc.storageos.api.service.impl.resource.blockingestorchestration.context.impl.RpVplexVolumeIngestionContext)

Aggregations

BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)112 URI (java.net.URI)64 Volume (com.emc.storageos.db.client.model.Volume)43 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)41 NamedURI (com.emc.storageos.db.client.model.NamedURI)38 ArrayList (java.util.ArrayList)33 BlockObject (com.emc.storageos.db.client.model.BlockObject)29 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)27 StringSet (com.emc.storageos.db.client.model.StringSet)25 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)17 HashMap (java.util.HashMap)17 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)16 CIMObjectPath (javax.cim.CIMObjectPath)13 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)11 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)11 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)11 DataObject (com.emc.storageos.db.client.model.DataObject)10 Project (com.emc.storageos.db.client.model.Project)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)10