Search in sources :

Example 16 with BlockSnapshotSession

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

the class RPBlockSnapshotSessionApiImpl method prepareSnapshotSessionFromSource.

/**
 * {@inheritDoc}
 */
@Override
public BlockSnapshotSession prepareSnapshotSessionFromSource(BlockObject sourceObj, String snapSessionLabel, String instanceLabel, String taskId, boolean inApplication) {
    BlockSnapshotSessionApi snapSessionImpl = getImplementationForBackendSystem(sourceObj.getStorageController());
    BlockSnapshotSession snapSession = snapSessionImpl.prepareSnapshotSessionFromSource(sourceObj, snapSessionLabel, instanceLabel, taskId, inApplication);
    return snapSession;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession)

Example 17 with BlockSnapshotSession

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

the class VMAX3BlockSnapshotSessionApiImpl method verifyNewTargetCount.

/**
 * {@inheritDoc}
 */
@Override
protected void verifyNewTargetCount(BlockObject sourceObj, int newTargetsCount, boolean zeroIsValid) {
    // Call super first.
    super.verifyNewTargetCount(sourceObj, newTargetsCount, zeroIsValid);
    // Now make sure max is not exceeded.
    if (newTargetsCount > 0) {
        // The total number of linked targets for all sessions for a given
        // source can't exceed 1024. So, get all sessions for the source
        // and add all linked targets for these sessions. That value plus
        // the number of new targets cannot exceed the max.
        int totalLinkedTargets = newTargetsCount;
        List<BlockSnapshotSession> snapSessions = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(sourceObj.getId()));
        for (BlockSnapshotSession snapSession : snapSessions) {
            StringSet linkedTargetIds = snapSession.getLinkedTargets();
            if (linkedTargetIds != null) {
                totalLinkedTargets += linkedTargetIds.size();
            }
        }
        if (totalLinkedTargets > MAX_LINKED_TARGETS_PER_SOURCE) {
            throw APIException.badRequests.invalidNewLinkedTargetsCount(newTargetsCount, sourceObj.getLabel(), MAX_LINKED_TARGETS_PER_SOURCE - totalLinkedTargets);
        }
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) StringSet(com.emc.storageos.db.client.model.StringSet) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 18 with BlockSnapshotSession

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

the class VMAX3BlockSnapshotSessionApiImpl method deleteSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void deleteSnapshotSession(BlockSnapshotSession snapSession, BlockObject snapSessionSourceObj, String taskId, String deleteType) {
    if (VolumeDeleteTypeEnum.VIPR_ONLY.name().equals(deleteType)) {
        // Update the task status for the session.
        // Note that we must get the session form the database to get the latest status map.
        BlockSnapshotSession updatedSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSession.getId());
        Operation op = updatedSession.getOpStatus().get(taskId);
        op.ready("Snapshot session succesfully deleted from ViPR");
        updatedSession.getOpStatus().updateTaskStatus(taskId, op);
        _dbClient.updateObject(updatedSession);
        // Mark the snapshot session for deletion.
        _dbClient.markForDeletion(updatedSession);
    } else {
        // Invoke the BlockDeviceController to delete the snapshot session.
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, snapSessionSourceObj.getStorageController());
        BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
        controller.deleteSnapshotSession(storageSystem.getId(), snapSession.getId(), taskId);
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) BlockController(com.emc.storageos.volumecontroller.BlockController) Operation(com.emc.storageos.db.client.model.Operation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with BlockSnapshotSession

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

the class BlockServiceUtils method checkForDuplicateArraySnapshotName.

/**
 * Checks if there are any native array snapshots with the requested name.
 *
 * @param requestedName A name requested for a new native array snapshot.
 * @param sourceURI The URI of the snapshot source.
 * @param dbClient A reference to a database client.
 */
public static void checkForDuplicateArraySnapshotName(String requestedName, URI sourceURI, DbClient dbClient) {
    // First ensure the requested snapshot name is no more than 63 characters in length.
    // If we remove special characters and truncate to 63 characters, this could lead
    // to invalid duplicate name exceptions (COP-14512). By restricting to 63 characters in total, this
    // won't happen.
    ArgValidator.checkFieldLengthMaximum(requestedName, SmisConstants.MAX_SNAPSHOT_NAME_LENGTH, "snapshotName");
    // We need to check the BlockSnapshotSession instances created using
    // the new Create Snapshot Session service as it creates a native
    // array snapshot.
    String modifiedRequestedName = ResourceOnlyNameGenerator.removeSpecialCharsForName(requestedName, SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
    List<BlockSnapshotSession> snapSessions = null;
    Volume sourceVolume = null;
    if (URIUtil.isType(sourceURI, Volume.class)) {
        sourceVolume = dbClient.queryObject(Volume.class, sourceURI);
    }
    if (sourceVolume != null && NullColumnValueGetter.isNotNullValue(sourceVolume.getReplicationGroupInstance())) {
        snapSessions = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getBlockSnapshotSessionByConsistencyGroup(sourceVolume.getConsistencyGroup()));
    } else {
        snapSessions = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(sourceURI));
    }
    for (BlockSnapshotSession snapSession : snapSessions) {
        if (modifiedRequestedName.equals(snapSession.getSessionLabel())) {
            throw APIException.badRequests.duplicateLabel(requestedName);
        }
    }
    // We also need to check BlockSnapshot instances created on the source
    // using the existing Create Snapshot service.
    List<BlockSnapshot> sourceSnapshots = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, BlockSnapshot.class, ContainmentConstraint.Factory.getVolumeSnapshotConstraint(sourceURI));
    for (BlockSnapshot snapshot : sourceSnapshots) {
        if (modifiedRequestedName.equals(snapshot.getSnapsetLabel())) {
            throw APIException.badRequests.duplicateLabel(requestedName);
        }
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot)

Example 20 with BlockSnapshotSession

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

the class BlockServiceUtils method getNumNativeSnapshots.

/**
 * Gets the number of native array snapshots created for the source with
 * the passed URI.
 *
 * @param sourceURI The URI of the source.
 * @param dbClient A reference to a database client.
 *
 * @return The number of native array snapshots for the source.
 */
public static int getNumNativeSnapshots(URI sourceURI, DbClient dbClient) {
    // The number of native array snapshots is determined by the
    // number of BlockSnapshotSession instances created for the
    // source using new Create Snapshot Session service.
    List<BlockSnapshotSession> snapSessions = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(sourceURI));
    int numSnapshots = snapSessions.size();
    // Also, we must account for the native array snapshots associated
    // with the BlockSnapshot instances created using the existing Create
    // Block Snapshot service. These will be the BlockSnapshot instances
    // that are not a linked target for a BlockSnapshotSession instance.
    List<BlockSnapshot> sourceSnapshots = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, BlockSnapshot.class, ContainmentConstraint.Factory.getVolumeSnapshotConstraint(sourceURI));
    for (BlockSnapshot snapshot : sourceSnapshots) {
        URIQueryResultList queryResults = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getLinkedTargetSnapshotSessionConstraint(snapshot.getId()), queryResults);
        Iterator<URI> queryResultsIter = queryResults.iterator();
        if ((!queryResultsIter.hasNext()) && (TechnologyType.NATIVE.toString().equalsIgnoreCase(snapshot.getTechnologyType()))) {
            numSnapshots++;
        }
    }
    return numSnapshots;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

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