use of com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method enterMaintenanceMode.
@POST
@Path("{jobId}/enter-maintanence-mode")
public void enterMaintenanceMode(@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<HostMaintenanceModeResponse> hostMaintenanceModeCompletableFuture = vcenterService.requestHostMaintenanceModeEnable(job.getVcenterCredentials(), hostname);
hostMaintenanceModeCompletableFuture.thenAccept(hostMaintenanceModeResponse -> {
LOG.info("Host Maintenance Mode Response: [{}]", hostMaintenanceModeResponse);
if (HostMaintenanceModeResponseMessage.Status.SUCCESS.value().equals(hostMaintenanceModeResponse.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(hostMaintenanceModeResponse.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.rest.representation.JobRepresentation in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method captureCoprHD.
@POST
@Consumes("application/vnd.dellemc.coprhd.endpoint+json")
@Path("{jobId}/{step}")
public Response captureCoprHD(@PathParam("jobId") String jobId, @PathParam("step") String step, @Context UriInfo uriInfo, EndpointCredentials coprhdCredentials) {
final String thisStep = findStepFromPath(uriInfo);
final Job job = workflowService.findJob(UUID.fromString(jobId));
final JobRepresentation jobRepresentation = new JobRepresentation(job);
final URL url;
try {
url = new URL(coprhdCredentials.getEndpointUrl());
} catch (MalformedURLException e) {
jobRepresentation.addLink(createRetryStepLink(uriInfo, job, thisStep));
return Response.status(Response.Status.BAD_REQUEST).entity(jobRepresentation).build();
}
job.addCoprhdCredentials(coprhdCredentials);
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()));
}
return Response.ok(jobRepresentation).build();
}
use of com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method setupSymphony.
@POST
@Path("{jobId}/setup-symphony")
public void setupSymphony(@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.rest.representation.JobRepresentation in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method waitForRackHDDiscovery.
@POST
@Path("{jobId}/wait-for-rackhd-discovery")
public void waitForRackHDDiscovery(@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.rest.representation.JobRepresentation in project fru-paqx-parent by dellemc-symphony.
the class WorkflowResource method startWorkflow.
/**
* TODO: Currently a mock interface
*
* @param startWorkflowRequest
* @param uriInfo
* @return
*/
@POST
public Response startWorkflow(StartWorkflowRequest startWorkflowRequest, @Context UriInfo uriInfo) {
final Job job = workflowService.createWorkflow(startWorkflowRequest.getWorkflow());
final JobRepresentation jobRepresentation = new JobRepresentation(job);
final NextStep nextStep = workflowService.findNextStep(job.getWorkflow(), job.getCurrentStep());
jobRepresentation.addLink(createNextStepLink(uriInfo, job, nextStep.getNextStep()));
return Response.created(uriInfo.getBaseUriBuilder().path("workflow").path(job.getId().toString()).build()).entity(jobRepresentation).build();
}
Aggregations