Search in sources :

Example 1 with CertificatesRotationV4Response

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

the class CertRotationServiceTest method testStartCertRotation.

@Test
public void testStartCertRotation() {
    CertificatesRotationV4Request request = new CertificatesRotationV4Request();
    SdxCluster sdxCluster = new SdxCluster();
    sdxCluster.setClusterName("testclustername");
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    when(sdxService.getById(1L)).thenReturn(sdxCluster);
    CertificatesRotationV4Response response = new CertificatesRotationV4Response();
    FlowIdentifier flowIdentifier = new FlowIdentifier(FlowType.FLOW, "pollid");
    response.setFlowIdentifier(flowIdentifier);
    when(stackV4Endpoint.rotateAutoTlsCertificates(0L, sdxCluster.getClusterName(), TEST_USER_CRN, request)).thenReturn(response);
    ThreadBasedUserCrnProvider.doAs(TEST_USER_CRN, () -> underTest.startCertRotation(1L, request));
    verify(cloudbreakFlowService).saveLastCloudbreakFlowChainId(sdxCluster, flowIdentifier);
    verify(sdxStatusService).setStatusForDatalakeAndNotify(DatalakeStatusEnum.CERT_ROTATION_IN_PROGRESS, "Datalake cert rotation in progress", sdxCluster);
}
Also used : CertificatesRotationV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) CertificatesRotationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CertificatesRotationV4Response) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) Test(org.junit.jupiter.api.Test)

Example 2 with CertificatesRotationV4Response

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

the class CertRotationService method startCertRotation.

public void startCertRotation(Long id, CertificatesRotationV4Request request) {
    SdxCluster sdxCluster = sdxService.getById(id);
    String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
    try {
        CertificatesRotationV4Response response = ThreadBasedUserCrnProvider.doAsInternalActor(regionAwareInternalCrnGeneratorFactory.iam().getInternalCrnForServiceAsString(), () -> stackV4Endpoint.rotateAutoTlsCertificates(0L, sdxCluster.getClusterName(), initiatorUserCrn, request));
        cloudbreakFlowService.saveLastCloudbreakFlowChainId(sdxCluster, response.getFlowIdentifier());
        updateCertExpirationState(sdxCluster);
        sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.CERT_ROTATION_IN_PROGRESS, "Datalake cert rotation in progress", sdxCluster);
    } catch (WebApplicationException e) {
        String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(e);
        LOGGER.error("Couldn't start certiificate rotation in CB: {}", errorMessage, e);
        throw new RuntimeException(errorMessage, e);
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) CertificatesRotationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CertificatesRotationV4Response)

Example 3 with CertificatesRotationV4Response

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

the class ClusterCommonService method rotateAutoTlsCertificates.

public CertificatesRotationV4Response rotateAutoTlsCertificates(NameOrCrn nameOrCrn, Long workspaceId, CertificatesRotationV4Request certificatesRotationV4Request) {
    Stack stack = stackService.getByNameOrCrnInWorkspace(nameOrCrn, workspaceId);
    MDCBuilder.buildMdcContext(stack);
    validateOperationOnStack(stack, "Certificates rotation");
    return new CertificatesRotationV4Response(clusterOperationService.rotateAutoTlsCertificates(stack, certificatesRotationV4Request));
}
Also used : CertificatesRotationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CertificatesRotationV4Response) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

CertificatesRotationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.CertificatesRotationV4Response)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 CertificatesRotationV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Test (org.junit.jupiter.api.Test)1