use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class BlockSnapshotSessionService method queryResource.
/**
* {@inheritDoc}
*/
@Override
protected BlockSnapshotSession queryResource(URI id) {
ArgValidator.checkUri(id);
BlockSnapshotSession blockSnapshotSession = _permissionsHelper.getObjectById(id, BlockSnapshotSession.class);
ArgValidator.checkEntityNotNull(blockSnapshotSession, id, isIdEmbeddedInURL(id));
return blockSnapshotSession;
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class VolumeGroupService method checkForApplicationPendingTasks.
/**
* Check if the application and its CGs/volumes/snapshots/snapshotSessions have any pending tasks
*
* @param volumeGroup The volume group
* @param dbClient
* @param preventAnyPendingTask If throw error when there is any pending task
*/
private void checkForApplicationPendingTasks(VolumeGroup volumeGroup, DbClient dbClient, boolean preventAnyPendingTask) {
checkForPendingTask(volumeGroup.getId(), dbClient, preventAnyPendingTask);
Set<URI> cgs = new HashSet<URI>();
List<Volume> allVolumes = ControllerUtils.getVolumeGroupVolumes(dbClient, volumeGroup);
for (Volume vol : allVolumes) {
checkForPendingTask(vol.getId(), dbClient, preventAnyPendingTask);
URI cg = vol.getConsistencyGroup();
if (!NullColumnValueGetter.isNullURI(cg)) {
cgs.add(vol.getConsistencyGroup());
}
}
for (URI cg : cgs) {
checkForPendingTask(cg, dbClient, preventAnyPendingTask);
}
// it has a corresponding task in CG. so the above checking on CG should cover the case for clone.
for (Volume volume : allVolumes) {
Volume theVol = volume;
if (volume.isVPlexVolume(dbClient)) {
theVol = VPlexUtil.getVPLEXBackendVolume(volume, true, dbClient);
if (theVol == null || theVol.getInactive()) {
log.warn("Cannot find backend volume for VPLEX volume {}", volume.getLabel());
continue;
}
}
URIQueryResultList snapshotURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumeSnapshotConstraint(theVol.getId()), snapshotURIs);
Iterator<URI> it = snapshotURIs.iterator();
while (it.hasNext()) {
URI snapURI = it.next();
checkForPendingTask(snapURI, dbClient, preventAnyPendingTask);
}
}
// Get snapshotSessions
List<BlockSnapshotSession> sessions = getVolumeGroupSnapshotSessions(volumeGroup);
for (BlockSnapshotSession session : sessions) {
checkForPendingTask(session.getId(), dbClient, preventAnyPendingTask);
}
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class VolumeGroupService method getVolumeGroupSnapshotSessionsByCopySet.
/**
* List snapshot sessions in a session set for a volume group.
*
* @param volumeGroupId The URI of the volume group
* @param param the VolumeGroupCopySetParam containing set name
* @return BlockSnapshotSessionList
* @brief List snapshot sessions in session set for a volume group
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions/copy-sets")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BlockSnapshotSessionList getVolumeGroupSnapshotSessionsByCopySet(@PathParam("id") final URI volumeGroupId, final VolumeGroupCopySetParam param) {
ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
// query volume group
final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
// validate snap session set name
String sessionsetName = param.getCopySetName();
ArgValidator.checkFieldNotNull(sessionsetName, COPY_SET_NAME_FIELD);
// get the snapshot sessions for the given set name in the volume group
BlockSnapshotSessionList snapshotSessionList = new BlockSnapshotSessionList();
// validate that the provided set name actually belongs to this Application
VolumeGroupCopySetList copySetList = getVolumeGroupSnapsetSessionSets(volumeGroup);
if (copySetList.getCopySets().contains(sessionsetName)) {
// get the snapshot sessions for the volume group
List<BlockSnapshotSession> volumeGroupSessions = getVolumeGroupSnapshotSessions(volumeGroup);
for (BlockSnapshotSession session : volumeGroupSessions) {
if (sessionsetName.equals(session.getSessionSetName())) {
snapshotSessionList.getSnapSessionRelatedResourceList().add(toNamedRelatedResource(session));
}
}
}
return snapshotSessionList;
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class VolumeGroupService method getVolumeGroupSnapshotSession.
/**
* Get the specified volume group snapshot session.
*
* @param volumeGroupId The URI of the volume group.
* @param snapshotIsnapshotSessionIdd The URI of the snapshot session.
* @brief Get the specified volume group snapshot session.
* @return BlockSnapshotSessionRestRep.
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions/{sid}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BlockSnapshotSessionRestRep getVolumeGroupSnapshotSession(@PathParam("id") final URI volumeGroupId, @PathParam("sid") final URI snapshotSessionId) {
ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
// query Volume Group
final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
// validate replica operation for volume group
validateCopyOperationForVolumeGroup(volumeGroup, ReplicaTypeEnum.SNAPSHOT);
// get snapshot session
BlockSnapshotSession snapSession = BlockSnapshotSessionUtils.querySnapshotSession(snapshotSessionId, uriInfo, _dbClient, true);
// validate that the provided snapshot session is part of the volume group
validateSnapSessionBelongsToApplication(snapSession, volumeGroup);
return map(_dbClient, snapSession);
}
use of com.emc.storageos.db.client.model.BlockSnapshotSession in project coprhd-controller by CoprHD.
the class VolumeGroupService method validateSnapSessionBelongsToApplication.
/**
* Validates that the snap session belongs to the given application.
*
* @param session the snapshot session
* @param volumeGroup the volume group
*/
private void validateSnapSessionBelongsToApplication(BlockSnapshotSession session, VolumeGroup volumeGroup) {
List<BlockSnapshotSession> volumeGroupSessions = getVolumeGroupSnapshotSessions(volumeGroup);
Set<URI> sessionURIs = new HashSet<URI>();
for (BlockSnapshotSession snapSession : volumeGroupSessions) {
sessionURIs.add(snapSession.getId());
}
if (!sessionURIs.contains(session.getId())) {
throw APIException.badRequests.replicaOperationNotAllowedSourceNotInVolumeGroup(ReplicaTypeEnum.SNAPSHOT_SESSION.toString(), session.getLabel());
}
}
Aggregations