Search in sources :

Example 6 with RebuildRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.rebuild.RebuildRequest in project cloudbreak by hortonworks.

the class RepairInstancesService method rebuild.

public DescribeFreeIpaResponse rebuild(String accountId, RebuildRequest rebuildRequest) {
    if (!entitlementService.isFreeIpaRebuildEnabled(accountId)) {
        throw new BadRequestException("The FreeIPA rebuild capability is disabled.");
    }
    Stack stack = stackService.getByCrnAndAccountIdEvenIfTerminated(rebuildRequest.getEnvironmentCrn(), accountId, rebuildRequest.getSourceCrn());
    Optional<Stack> nonTerminatedStack = stackService.findByEnvironmentCrnAndAccountId(rebuildRequest.getEnvironmentCrn(), accountId);
    if (nonTerminatedStack.isPresent()) {
        String error = "There is a stack which hasn't been terminated.";
        LOGGER.error(error);
        throw new BadRequestException(error);
    }
    renameStackIfNeeded(stack);
    CreateFreeIpaRequest createFreeIpaRequest = stackToCreateFreeIpaRequestConverter.convert(stack);
    return freeIpaCreationService.launchFreeIpa(createFreeIpaRequest, accountId);
}
Also used : CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Stack(com.sequenceiq.freeipa.entity.Stack)

Aggregations

RebuildRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.rebuild.RebuildRequest)5 Test (org.junit.jupiter.api.Test)4 Stack (com.sequenceiq.freeipa.entity.Stack)3 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)1