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;
}
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);
}
}
}
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);
}
}
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);
}
}
}
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;
}
Aggregations