Search in sources :

Example 6 with RecoveryValidationV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response in project cloudbreak by hortonworks.

the class ClusterRecoveryService method validateFreeIpaStatus.

private RecoveryValidationV4Response validateFreeIpaStatus(String envCrn) {
    boolean freeIpaAvailable = freeipaService.checkFreeipaRunning(envCrn);
    String reason = "";
    RecoveryStatus status;
    if (!freeIpaAvailable) {
        reason = "Recovery cannot be performed because the FreeIPA isn't available. Please check the FreeIPA state and try again.";
        status = NON_RECOVERABLE;
        LOGGER.info(reason);
    } else {
        status = RECOVERABLE;
        LOGGER.debug("Recovery can be performed because the FreeIPA is available.");
    }
    return new RecoveryValidationV4Response(reason, status);
}
Also used : RecoveryValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response) RecoveryStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryStatus)

Example 7 with RecoveryValidationV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response in project cloudbreak by hortonworks.

the class ClusterRecoveryServiceTest method testIfClusterRecoverable.

@Test
public void testIfClusterRecoverable() {
    NameOrCrn stackNameOrCrn = NameOrCrn.ofName(STACK_NAME);
    when(stackService.getByNameOrCrnInWorkspace(stackNameOrCrn, WORKSPACE_ID)).thenReturn(STACK);
    when(stackStatusService.findAllStackStatusesById(STACK.getId())).thenReturn(stackStatusList);
    when(freeipaService.checkFreeipaRunning(STACK.getEnvironmentCrn())).thenReturn(freeIpaStatus);
    RecoveryValidationV4Response response = underTest.validateRecovery(WORKSPACE_ID, stackNameOrCrn);
    Assertions.assertEquals(expectedRecoveryStatus, response.getStatus());
    Assertions.assertEquals(expectedMessage, response.getReason());
}
Also used : RecoveryValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.Test)

Example 8 with RecoveryValidationV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response in project cloudbreak by hortonworks.

the class SdxUpgradeRecoveryService method validateRecovery.

public SdxRecoverableResponse validateRecovery(SdxCluster sdxCluster) {
    MDCBuilder.buildMdcContext(sdxCluster);
    try {
        String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
        RecoveryValidationV4Response response = ThreadBasedUserCrnProvider.doAsInternalActor(() -> stackV4Endpoint.getClusterRecoverableByNameInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn));
        return new SdxRecoverableResponse(response.getReason(), response.getStatus());
    } catch (WebApplicationException e) {
        String exceptionMessage = exceptionMessageExtractor.getErrorMessage(e);
        String message = String.format("Stack recovery validation failed on cluster: [%s]. Message: [%s]", sdxCluster.getClusterName(), exceptionMessage);
        throw new CloudbreakApiException(message, e);
    }
}
Also used : RecoveryValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response) WebApplicationException(javax.ws.rs.WebApplicationException) SdxRecoverableResponse(com.sequenceiq.sdx.api.model.SdxRecoverableResponse) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException)

Aggregations

RecoveryValidationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response)8 SdxRecoverableResponse (com.sequenceiq.sdx.api.model.SdxRecoverableResponse)5 Test (org.junit.jupiter.api.Test)3 com.cloudera.thunderhead.service.datalakedr.datalakeDRProto (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto)2 RecoveryStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryStatus)2 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)2 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)2 SdxRecoveryResponse (com.sequenceiq.sdx.api.model.SdxRecoveryResponse)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)1 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)1 Test (org.junit.Test)1