use of com.dell.cpsd.paqx.fru.valueobject.NextStep in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method discoverScaleIO.
@POST
@Path("{jobId}/start-scaleio-data-collection")
public void discoverScaleIO(@Suspended final AsyncResponse asyncResponse, @PathParam("jobId") String jobId, @Context UriInfo uriInfo) {
asyncResponse.setTimeoutHandler(asyncResponse1 -> asyncResponse1.resume(Response.status(Response.Status.SERVICE_UNAVAILABLE).entity("{\"status\":\"timeout\"}").build()));
asyncResponse.setTimeout(10, TimeUnit.SECONDS);
//
final String thisStep = findStepFromPath(uriInfo);
final Job job = workflowService.findJob(UUID.fromString(jobId));
final JobRepresentation jobRepresentation = new JobRepresentation(job);
jobRepresentation.addLink(createRetryStepLink(uriInfo, job, thisStep));
//
final CompletableFuture<ScaleIOSystemDataRestRep> systemRestCompletableFuture = scaleIOService.listStorage(job.getScaleIOCredentials());
systemRestCompletableFuture.thenAccept(scaleIOSystemDataRestRep -> {
dataService.saveScaleioData(UUID.fromString(jobId), scaleIOSystemDataRestRep);
final NextStep nextStep = workflowService.findNextStep(job.getWorkflow(), thisStep);
if (nextStep != null) {
workflowService.advanceToNextStep(job, thisStep);
jobRepresentation.addLink(createNextStepLink(uriInfo, job, nextStep.getNextStep()), findMethodFromStep(nextStep.getNextStep()));
}
LOG.info("Completing response");
asyncResponse.resume(Response.ok(jobRepresentation).build());
LOG.debug("Completed response");
});
}
use of com.dell.cpsd.paqx.fru.valueobject.NextStep in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method waitForRackHDHostDiscovery.
@POST
@Path("{jobId}/wait-for-rackhd-host-discovery")
public void waitForRackHDHostDiscovery(@Suspended final AsyncResponse asyncResponse, @PathParam("jobId") String jobId, @Context UriInfo uriInfo) {
asyncResponse.setTimeoutHandler(asyncResponse1 -> asyncResponse1.resume(Response.status(Response.Status.SERVICE_UNAVAILABLE).entity("{\"status\":\"timeout\"}").build()));
asyncResponse.setTimeout(10, TimeUnit.SECONDS);
//
final String thisStep = findStepFromPath(uriInfo);
final Job job = workflowService.findJob(UUID.fromString(jobId));
final JobRepresentation jobRepresentation = new JobRepresentation(job);
final NextStep nextStep = workflowService.findNextStep(job.getWorkflow(), thisStep);
if (nextStep != null) {
workflowService.advanceToNextStep(job, thisStep);
jobRepresentation.addLink(createNextStepLink(uriInfo, job, nextStep.getNextStep()), findMethodFromStep(nextStep.getNextStep()));
}
LOG.info("Completing response");
asyncResponse.resume(Response.ok(jobRepresentation).build());
LOG.debug("Completed response");
}
use of com.dell.cpsd.paqx.fru.valueobject.NextStep in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method powerOffEsxiHostForRemoval.
@POST
@Path("{jobId}/power-off-esxi-host-for-removal")
public void powerOffEsxiHostForRemoval(@Suspended final AsyncResponse asyncResponse, @PathParam("jobId") String jobId, @Context UriInfo uriInfo) {
asyncResponse.setTimeoutHandler(asyncResponse1 -> asyncResponse1.resume(Response.status(Response.Status.SERVICE_UNAVAILABLE).entity("{\"status\":\"timeout\"}").build()));
asyncResponse.setTimeout(10, TimeUnit.SECONDS);
final String thisStep = findStepFromPath(uriInfo);
final Job job = workflowService.findJob(UUID.fromString(jobId));
final JobRepresentation jobRepresentation = new JobRepresentation(job);
//TODO find out where to get the hostname from
final String hostname = "";
final CompletableFuture<VCenterHostPowerOperationStatus> vCenterHostPowerOperationStatusCompletableFuture = vcenterService.requestHostPowerOff(job.getVcenterCredentials(), hostname);
vCenterHostPowerOperationStatusCompletableFuture.thenAccept(hostPowerOperationStatus -> {
LOG.info("Host Power Off Response: [{}]", hostPowerOperationStatus);
if (HostPowerOperationResponseMessage.Status.SUCCESS.value().equals(hostPowerOperationStatus.getStatus())) {
final NextStep nextStep = workflowService.findNextStep(job.getWorkflow(), thisStep);
if (nextStep != null) {
workflowService.advanceToNextStep(job, thisStep);
jobRepresentation.addLink(createNextStepLink(uriInfo, job, nextStep.getNextStep()), findMethodFromStep(nextStep.getNextStep()));
}
asyncResponse.resume(Response.ok(jobRepresentation).build());
} else {
jobRepresentation.addLink(createRetryStepLink(uriInfo, job, thisStep));
jobRepresentation.setLastResponse(hostPowerOperationStatus.getStatus());
asyncResponse.resume(Response.status(Response.Status.BAD_REQUEST).build());
}
LOG.info("Completing response");
asyncResponse.resume(Response.ok(jobRepresentation).build());
LOG.debug("Completed response");
});
}
Aggregations