Search in sources :

Example 36 with BlockSnapshotSession

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

the class BlockSnapshotSessionUnlinkTargetCompleter method processSnapshot.

private void processSnapshot(URI snapshotURI, DbClient dbClient) {
    BlockSnapshot snapshotObj = dbClient.queryObject(BlockSnapshot.class, snapshotURI);
    BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, getId());
    StringSet linkedTargets = snapSession.getLinkedTargets();
    List<BlockSnapshot> snapshots = getRelatedSnapshots(snapshotObj, dbClient);
    for (BlockSnapshot snapshot : snapshots) {
        snapshot.setInactive(true);
        if ((linkedTargets != null) && (linkedTargets.contains(snapshot.getId().toString()))) {
            linkedTargets.remove(snapshot.getId().toString());
        }
    }
    // Note that even if the target is not deleted, mark the associated
    // BlockSnapshot inactive. Since the target is no longer associated
    // with an array snapshot, it is really no longer a BlockSnapshot
    // instance in ViPR. In the unlink job we have created a ViPR Volume
    // to represent the former snapshot target volume. So here we mark the
    // BlockSnapshot inactive so it is garbage collected.
    dbClient.updateObject(snapshots);
    dbClient.updateObject(snapSession);
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) StringSet(com.emc.storageos.db.client.model.StringSet)

Example 37 with BlockSnapshotSession

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

the class BlockSnapshotSessionUnlinkTargetsWorkflowCompleter method complete.

/**
 * {@inheritDoc}
 */
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
    URI snapSessionURI = getId();
    try {
        BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, snapSessionURI);
        List<BlockObject> allSources = getAllSources(snapSession, dbClient);
        BlockObject sourceObj = allSources.get(0);
        // Record the results.
        recordBlockSnapshotSessionOperation(dbClient, _opType, status, snapSession, sourceObj);
        // Update the status map of the snapshot session.
        switch(status) {
            case error:
                setErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
                break;
            case ready:
                setReadyOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
                break;
            case suspended_error:
                setSuspendedErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI, coded);
                break;
            case suspended_no_error:
                setSuspendedNoErrorOnDataObject(dbClient, BlockSnapshotSession.class, snapSessionURI);
                break;
            default:
                String errMsg = String.format("Unexpected status %s for completer for task %s", status.name(), getOpId());
                s_logger.info(errMsg);
                throw DeviceControllerException.exceptions.unexpectedCondition(errMsg);
        }
        s_logger.info("Done unlink targets from snapshot session task {} with status: {}", getOpId(), status.name());
    } catch (Exception e) {
        s_logger.error("Failed updating status for unlink targets from snapshot session task {}", getOpId(), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 38 with BlockSnapshotSession

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

the class ReplicaDeviceController method processSnapSessionsAndLinkedTargets.

private String processSnapSessionsAndLinkedTargets(List<Volume> existingVolumesInCG, Workflow workflow, String waitFor, List<Volume> volumesToAdd, URI cgUri) {
    /**
     * Get # of existing sessions for RG volumes
     * for every existing session:
     * -get # of existing snapshot groups
     * -for every new volume:
     * --create new session
     * --For every new session, create new linked targets as many as existing snap groups
     */
    Volume existingVolume = existingVolumesInCG.get(0);
    log.info("Processing RG {}", existingVolume.getReplicationGroupInstance());
    URI system = existingVolume.getStorageController();
    List<BlockSnapshotSession> sessions = getSnapSessionsForCGVolume(existingVolume);
    for (BlockSnapshotSession session : sessions) {
        log.info("Processing SnapSession {} for RG {}", session.getSessionLabel(), session.getReplicationGroupInstance());
        waitFor = createSnapshotSessionAndLinkSessionStep(workflow, waitFor, system, existingVolumesInCG, volumesToAdd, session, cgUri);
    }
    return waitFor;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 39 with BlockSnapshotSession

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

the class ReplicaDeviceController method createSnapshotSessionsStep.

public String createSnapshotSessionsStep(final Workflow workflow, String waitFor, URI systemURI, List<Volume> volumes, String repGroupName, BlockSnapshotSession existingSession) {
    // create session for each volume (session's parent is volume. i.e as a non-CG session)
    for (Volume volume : volumes) {
        // delete the new session object at the end from DB
        BlockSnapshotSession session = prepareSnapshotSessionFromSource(volume, existingSession);
        log.info("adding snapshot session create step for volume {}", volume.getLabel());
        waitFor = _blockDeviceController.addStepToCreateSnapshotSession(workflow, systemURI, session.getId(), repGroupName, waitFor);
        // add step to delete the newly created session object from DB
        waitFor = workflow.createStep(MARK_SNAP_SESSIONS_INACTIVE_OR_REMOVE_TARGET_ID, String.format("marking snap session %s inactive", session.getLabel()), waitFor, systemURI, _blockDeviceController.getDeviceType(systemURI), this.getClass(), markSnapSessionInactiveOrRemoveTargetIdsMethod(session.getId(), null), _blockDeviceController.rollbackMethodNullMethod(), null);
    }
    return waitFor;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) Volume(com.emc.storageos.db.client.model.Volume)

Example 40 with BlockSnapshotSession

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

the class VmaxSnapshotOperations method establishVolumeSnapshotGroupRelation.

@Override
public void establishVolumeSnapshotGroupRelation(StorageSystem storage, URI sourceVolume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("establishVolumeSnapshotGroupRelation operation START");
    try {
        /**
         * get groupPath for source volume
         * get groupPath for snapshot
         * get snapshots belonging to the same Replication Group
         * get Element synchronizations between volumes and snapshots
         * call CreateGroupReplicaFromElementSynchronizations
         */
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volumeObj = _dbClient.queryObject(Volume.class, sourceVolume);
        CIMObjectPath srcRepSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
        String volumeGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(volumeObj, _dbClient);
        CIMObjectPath volumeGroupPath = _cimPath.getReplicationGroupPath(storage, volumeGroupName);
        CIMObjectPath snapshotGroupPath = _cimPath.getReplicationGroupPath(storage, snapshotObj.getReplicationGroupInstance());
        // Check if snapshot is referenced by a BlockSnapshotSession
        // if so, we must pass in the RelationshipName with the value of the session name.
        // NB. a SourceGroup aspect must exist
        List<BlockSnapshotSession> snapshotSessions = queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, getLinkedTargetSnapshotSessionConstraint(snapshot));
        String relationshipName = null;
        if (!snapshotSessions.isEmpty()) {
            relationshipName = snapshotSessions.get(0).getSessionLabel();
            _log.info("Found snapshot session relationship: {}", relationshipName);
        }
        CIMObjectPath groupSynchronizedPath = _cimPath.getGroupSynchronized(volumeGroupPath, snapshotGroupPath);
        CIMInstance syncInstance = _helper.checkExists(storage, groupSynchronizedPath, false, false);
        if (syncInstance == null) {
            // get all snapshots belonging to a Replication Group. There may be multiple snapshots available for a Volume
            List<BlockSnapshot> snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
            List<CIMObjectPath> elementSynchronizations = new ArrayList<CIMObjectPath>();
            for (BlockSnapshot snapshotObject : snapshots) {
                Volume volume = _dbClient.queryObject(Volume.class, snapshotObject.getParent());
                elementSynchronizations.add(_cimPath.getStorageSynchronized(storage, volume, storage, snapshotObject));
            }
            _log.info("Creating Group synchronization between volume group and snapshot group");
            CIMArgument[] inArgs = _helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(volumeGroupPath, snapshotGroupPath, elementSynchronizations, relationshipName);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.invokeMethod(storage, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
        // No Job returned
        } else {
            _log.info("Link already established..");
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        String msg = String.format("Failed to establish group relation between volume group and snapshot group. Volume: %s, Snapshot: %s", sourceVolume, snapshot);
        _log.error(msg, e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) CIMInstance(javax.cim.CIMInstance) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) Volume(com.emc.storageos.db.client.model.Volume) CIMArgument(javax.cim.CIMArgument)

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