Search in sources :

Example 26 with JobRepresentation

use of com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation in project fru-paqx-parent by dellemc-symphony.

the class WorkflowResource method rebootHostForDiscovery.

@POST
@Path("{jobId}/reboot-host-for-discovery")
public void rebootHostForDiscovery(@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");
}
Also used : JobRepresentation(com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation) Job(com.dell.cpsd.paqx.fru.rest.domain.Job) NextStep(com.dell.cpsd.paqx.fru.valueobject.NextStep)

Example 27 with JobRepresentation

use of com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation in project fru-paqx-parent by dellemc-symphony.

the class WorkflowResource method exitMaintenanceMode.

@POST
@Path("{jobId}/exit-vcenter-maintenance-mode")
public void exitMaintenanceMode(@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");
}
Also used : JobRepresentation(com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation) Job(com.dell.cpsd.paqx.fru.rest.domain.Job) NextStep(com.dell.cpsd.paqx.fru.valueobject.NextStep)

Example 28 with JobRepresentation

use of com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation in project fru-paqx-parent by dellemc-symphony.

the class WorkflowResource method addHostTovCenter.

@POST
@Path("{jobId}/add-host-to-vcenter")
public void addHostTovCenter(@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 = "";
    //TODO find out where to get the cluster id from
    final String clusterId = "";
    final String hostUsername = "";
    final String hostPassword = "";
    final CompletableFuture<ClusterOperationResponse> clusterOperationResponseCompletableFuture = vcenterService.requestHostAddition(job.getVcenterCredentials(), hostname, clusterId, hostUsername, hostPassword);
    clusterOperationResponseCompletableFuture.thenAccept(clusterOperationResponse -> {
        LOG.info("Host Addition to the VCenter Cluster Response: [{}]", clusterOperationResponse);
        if (ClusterOperationResponseMessage.Status.SUCCESS.value().equals(clusterOperationResponse.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(clusterOperationResponse.getStatus());
            asyncResponse.resume(Response.status(Response.Status.BAD_REQUEST).build());
        }
        LOG.info("Completing response");
        asyncResponse.resume(Response.ok(jobRepresentation).build());
        LOG.debug("Completed response");
    });
}
Also used : JobRepresentation(com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation) Job(com.dell.cpsd.paqx.fru.rest.domain.Job) ClusterOperationResponse(com.dell.cpsd.paqx.fru.rest.dto.vcenter.ClusterOperationResponse) NextStep(com.dell.cpsd.paqx.fru.valueobject.NextStep)

Example 29 with JobRepresentation

use of com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation in project fru-paqx-parent by dellemc-symphony.

the class WorkflowResource method waitForSVMDeploy.

@POST
@Path("{jobId}/wait-for-svm-deploy")
public void waitForSVMDeploy(@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");
}
Also used : JobRepresentation(com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation) Job(com.dell.cpsd.paqx.fru.rest.domain.Job) NextStep(com.dell.cpsd.paqx.fru.valueobject.NextStep)

Example 30 with JobRepresentation

use of com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation 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");
    });
}
Also used : JobRepresentation(com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation) ScaleIOSystemDataRestRep(com.dell.cpsd.storage.capabilities.api.ScaleIOSystemDataRestRep) Job(com.dell.cpsd.paqx.fru.rest.domain.Job) NextStep(com.dell.cpsd.paqx.fru.valueobject.NextStep)

Aggregations

Job (com.dell.cpsd.paqx.fru.rest.domain.Job)32 JobRepresentation (com.dell.cpsd.paqx.fru.rest.representation.JobRepresentation)32 NextStep (com.dell.cpsd.paqx.fru.valueobject.NextStep)31 MalformedURLException (java.net.MalformedURLException)4 URL (java.net.URL)4 ClusterOperationResponse (com.dell.cpsd.paqx.fru.rest.dto.vcenter.ClusterOperationResponse)2 ConsulRegistryResult (com.dell.cpsd.paqx.fru.dto.ConsulRegistryResult)1 VCenterHostPowerOperationStatus (com.dell.cpsd.paqx.fru.rest.dto.VCenterHostPowerOperationStatus)1 com.dell.cpsd.paqx.fru.rest.dto.vCenterSystemProperties (com.dell.cpsd.paqx.fru.rest.dto.vCenterSystemProperties)1 DestroyVmResponse (com.dell.cpsd.paqx.fru.rest.dto.vcenter.DestroyVmResponse)1 HostMaintenanceModeResponse (com.dell.cpsd.paqx.fru.rest.dto.vcenter.HostMaintenanceModeResponse)1 ScaleIOSystemDataRestRep (com.dell.cpsd.storage.capabilities.api.ScaleIOSystemDataRestRep)1