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);
}
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());
}
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);
}
}
Aggregations