use of com.dell.cpsd.paqx.fru.valueobject.NextStep in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method destroyScaleIOVM.
@POST
@Path("{jobId}/destroy-scaleio-vm")
public void destroyScaleIOVM(@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 uuid from
//TODO Update ScaleIO Host status
final String uuid = "";
final CompletableFuture<DestroyVmResponse> vmDeletionResponse = vcenterService.requestVmDeletion(job.getVcenterCredentials(), uuid);
vmDeletionResponse.thenAccept(destroyVmResponse -> {
LOG.info("Destroy VM Response Message Status {}", destroyVmResponse);
if (DestroyVMResponseMessage.Status.SUCCESS.value().equals(destroyVmResponse.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(destroyVmResponse.getStatus());
asyncResponse.resume(Response.status(Response.Status.BAD_REQUEST).build());
}
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 WorkflowServiceImplTest method walkExpectedSteps.
@Test
public void walkExpectedSteps() {
Job initialJob = workflowServiceUnderTest.createWorkflow("quanta-d51b-fru");
NextStep nextStep = workflowServiceUnderTest.findNextStep("quanta-d51b-fru", initialJob.getCurrentStep());
assertNotNull(nextStep);
}
use of com.dell.cpsd.paqx.fru.valueobject.NextStep in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method capturevCenter.
@POST
@Consumes("application/vnd.dellemc.vcenter.endpoint+json")
@Path("{jobId}/{step}")
public void capturevCenter(@Suspended final AsyncResponse asyncResponse, @PathParam("jobId") String jobId, @PathParam("step") String step, @Context UriInfo uriInfo, EndpointCredentials vCenterCredentials) {
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);
try {
new URL(vCenterCredentials.getEndpointUrl());
} catch (MalformedURLException e) {
LOG.warn("Invalid URL found {}", vCenterCredentials.getEndpointUrl());
jobRepresentation.addLink(createRetryStepLink(uriInfo, job, thisStep));
jobRepresentation.setLastResponse(e.getLocalizedMessage());
Response.status(Response.Status.BAD_REQUEST).entity(jobRepresentation).build();
return;
}
final CompletableFuture<ConsulRegistryResult> consulRegistryResultCompletableFuture = vcenterService.requestConsulRegistration(vCenterCredentials);
consulRegistryResultCompletableFuture.thenAccept(consulRegistryResult -> {
if (consulRegistryResult.isSuccess()) {
LOG.info("Consul registration successfully completed");
job.addVcenterCredentials(vCenterCredentials);
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 {
LOG.info("Consul registration failed {}", consulRegistryResult.getDescription());
jobRepresentation.addLink(createRetryStepLink(uriInfo, job, thisStep));
jobRepresentation.setLastResponse(consulRegistryResult.getDescription());
asyncResponse.resume(Response.status(Response.Status.BAD_REQUEST).entity(jobRepresentation).build());
}
});
}
use of com.dell.cpsd.paqx.fru.valueobject.NextStep in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method presentSystemListForAddition.
@POST
@Path("{jobId}/present-system-list-add")
public void presentSystemListForAddition(@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 waitForScaleIOWorkflow.
@POST
@Path("{jobId}/wait-for-scaleio-workflow")
public void waitForScaleIOWorkflow(@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");
}
Aggregations