use of com.emc.storageos.cinder.model.ConsistencyGroupSnapshotDetail in project coprhd-controller by CoprHD.
the class ConsistencyGroupSnapshotService method getConsistencyGroupSnapshotDetail.
// internal function
private ConsistencyGroupSnapshotDetail getConsistencyGroupSnapshotDetail(BlockSnapshot blockSnapshot) {
ConsistencyGroupSnapshotDetail response = new ConsistencyGroupSnapshotDetail();
if (null != blockSnapshot) {
response.id = CinderApiUtils.splitString(blockSnapshot.getId().toString(), ":", 3);
response.name = blockSnapshot.getLabel();
response.created_at = CinderApiUtils.timeFormat(blockSnapshot.getCreationTime());
response.status = blockSnapshot.getExtensions().get("status");
response.consistencygroup_id = CinderApiUtils.splitString(blockSnapshot.getConsistencyGroup().toString(), ":", 3);
}
return response;
}
use of com.emc.storageos.cinder.model.ConsistencyGroupSnapshotDetail in project coprhd-controller by CoprHD.
the class ConsistencyGroupSnapshotService method getConsistencyGroupSnapshotDetail.
/**
* Get Consistency Group Snapshot info
*
* @param openstackTenantId
* openstack tenant Id
* @param consistencyGroupSnapshotId
* Consistency Group Snapshot Id
* @param isV1Call
* Cinder V1 api
* @param header
* HTTP Header
* @brief
* Get Consistency Group Snapshot info
* @return Response
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{consistencyGroupSnapshot_id}")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public Response getConsistencyGroupSnapshotDetail(@PathParam("tenant_id") String openstackTenantId, @PathParam("consistencyGroupSnapshot_id") String consistencyGroupSnapshotId, @HeaderParam("X-Cinder-V1-Call") String isV1Call, @Context HttpHeaders header) {
Project project = getCinderHelper().getProject(openstackTenantId, getUserFromContext());
if (project == null) {
String message = "Bad Request: Project with the OpenStack Tenant Id : " + openstackTenantId + " does not exist";
_log.error(message);
return CinderApiUtils.createErrorResponse(400, message);
}
final BlockSnapshot snapshot = findSnapshot(consistencyGroupSnapshotId, openstackTenantId);
if (null == snapshot) {
_log.error("Bad Request : Invalid Snapshot Id {}", consistencyGroupSnapshotId);
return CinderApiUtils.createErrorResponse(400, "Bad Request: No such snapshot id exist");
} else if (!consistencyGroupSnapshotId.equals(CinderApiUtils.splitString(snapshot.getId().toString(), ":", 3))) {
_log.error("Bad Request : Invalid Snapshot Id {} : Please enter valid or full Id", consistencyGroupSnapshotId);
return CinderApiUtils.createErrorResponse(400, "Bad Request: No such snapshot id exist, Please enter valid or full Id");
}
ConsistencyGroupSnapshotDetail cgSnapshotDetail = new ConsistencyGroupSnapshotDetail();
cgSnapshotDetail.id = consistencyGroupSnapshotId;
cgSnapshotDetail.name = snapshot.getLabel();
cgSnapshotDetail.created_at = CinderApiUtils.timeFormat(snapshot.getCreationTime());
cgSnapshotDetail.consistencygroup_id = CinderApiUtils.splitString(snapshot.getConsistencyGroup().toString(), ":", 3);
StringMap extensions = snapshot.getExtensions();
String description = null;
if (extensions != null) {
description = extensions.get("display_description");
_log.debug("Retreiving the tasks for snapshot id {}", snapshot.getId());
List<Task> taskLst = TaskUtils.findResourceTasks(_dbClient, snapshot.getId());
_log.debug("Retreived the tasks for snapshot id {}", snapshot.getId());
String taskInProgressId = null;
if (snapshot.getExtensions().containsKey("taskid")) {
taskInProgressId = snapshot.getExtensions().get("taskid");
Task acttask = TaskUtils.findTaskForRequestId(_dbClient, snapshot.getId(), taskInProgressId);
for (Task tsk : taskLst) {
if (tsk.getId().toString().equals(taskInProgressId)) {
if (tsk.getStatus().equals("ready")) {
cgSnapshotDetail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
snapshot.getExtensions().put("status", CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase());
snapshot.getExtensions().remove("taskid");
} else if (tsk.getStatus().equals("pending")) {
if (tsk.getDescription().equals(ResourceOperationTypeEnum.CREATE_VOLUME_SNAPSHOT.getDescription())) {
cgSnapshotDetail.status = CinderConstants.ComponentStatus.CREATING.getStatus().toLowerCase();
} else if (tsk.getDescription().equals(ResourceOperationTypeEnum.DELETE_VOLUME_SNAPSHOT.getDescription())) {
cgSnapshotDetail.status = CinderConstants.ComponentStatus.DELETING.getStatus().toLowerCase();
}
} else if (tsk.getStatus().equals("error")) {
cgSnapshotDetail.status = CinderConstants.ComponentStatus.ERROR.getStatus().toLowerCase();
snapshot.getExtensions().put("status", CinderConstants.ComponentStatus.ERROR.getStatus().toLowerCase());
snapshot.getExtensions().remove("taskid");
}
_dbClient.updateObject(snapshot);
break;
}
}
} else if (snapshot.getExtensions().containsKey("status") && !snapshot.getExtensions().get("status").toString().toLowerCase().equals("")) {
cgSnapshotDetail.status = snapshot.getExtensions().get("status").toString().toLowerCase();
} else {
// status is available
cgSnapshotDetail.status = CinderConstants.ComponentStatus.AVAILABLE.getStatus().toLowerCase();
}
}
cgSnapshotDetail.description = (description == null) ? "" : description;
return CinderApiUtils.getCinderResponse(cgSnapshotDetail, header, true, CinderConstants.STATUS_OK);
}
Aggregations