Search in sources :

Example 56 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeipaServiceTest method testCheckFreeipaRunningWhenFreeIpaStoppedThenReturnsFalse.

@ParameterizedTest
@EnumSource(value = Status.class)
void testCheckFreeipaRunningWhenFreeIpaStoppedThenReturnsFalse(Status status) {
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setStatus(status);
    freeipa.setAvailabilityStatus(AvailabilityStatus.UNAVAILABLE);
    when(freeipaClientService.getByEnvironmentCrn(ENV_CRN)).thenReturn(freeipa);
    boolean freeipaRunning = underTest.checkFreeipaRunning(ENV_CRN);
    assertFalse(freeipaRunning);
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 57 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeipaServiceTest method testCheckFreeipaRunningWhenFreeIpaAvailableThenPass.

@ParameterizedTest
@EnumSource(value = Status.class)
void testCheckFreeipaRunningWhenFreeIpaAvailableThenPass(Status status) {
    DescribeFreeIpaResponse freeipa = new DescribeFreeIpaResponse();
    freeipa.setStatus(status);
    freeipa.setAvailabilityStatus(AvailabilityStatus.AVAILABLE);
    when(freeipaClientService.getByEnvironmentCrn(ENV_CRN)).thenReturn(freeipa);
    Assertions.assertDoesNotThrow(() -> underTest.checkFreeipaRunning(ENV_CRN));
}
Also used : DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 58 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class SdxRepairTests method testSDXRepairMasterAndIDBRokerWithStoppedEC2Instance.

@Test(dataProvider = TEST_CONTEXT)
@Description(given = "there is a running Cloudbreak, and an SDX cluster in available state", when = "recovery called on the MASTER and then the IDBROKER host group, where the EC2 instance had been stopped", then = "SDX recovery should be successful, the cluster should be up and running")
public void testSDXRepairMasterAndIDBRokerWithStoppedEC2Instance(TestContext testContext) {
    String sdx = resourcePropertyProvider().getName();
    DescribeFreeIpaResponse describeFreeIpaResponse = testContext.given(FreeIpaTestDto.class).when(freeIpaTestClient.describe()).getResponse();
    SdxTestDto sdxTestDto = testContext.given(sdx, SdxTestDto.class).withCloudStorage(getCloudStorageRequest(testContext)).when(sdxTestClient.create(), key(sdx)).await(SdxClusterStatusResponse.RUNNING, key(sdx)).awaitForHealthyInstances();
    repair(sdxTestDto, sdx, MASTER.getName(), Set.of(SdxClusterStatusResponse.CLUSTER_UNREACHABLE));
    repair(sdxTestDto, sdx, IDBROKER.getName(), Set.of(SdxClusterStatusResponse.NODE_FAILURE));
    sdxTestDto.then((tc, testDto, client) -> {
        getCloudFunctionality(tc).cloudStorageListContainerDataLake(getBaseLocation(testDto), testDto.getResponse().getName(), testDto.getResponse().getStackCrn());
        return testDto;
    }).then((tc, testDto, client) -> {
        getCloudFunctionality(tc).cloudStorageListContainerFreeIpa(getBaseLocation(testDto), describeFreeIpaResponse.getName(), describeFreeIpaResponse.getCrn());
        return testDto;
    }).validate();
}
Also used : SdxClusterShape(com.sequenceiq.sdx.api.model.SdxClusterShape) FreeIpaTestDto(com.sequenceiq.it.cloudbreak.dto.freeipa.FreeIpaTestDto) RunningParameter.key(com.sequenceiq.it.cloudbreak.context.RunningParameter.key) Test(org.testng.annotations.Test) ArrayList(java.util.ArrayList) Description(com.sequenceiq.it.cloudbreak.context.Description) HashSet(java.util.HashSet) Inject(javax.inject.Inject) SdxUtil(com.sequenceiq.it.cloudbreak.util.SdxUtil) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) TestContext(com.sequenceiq.it.cloudbreak.context.TestContext) MASTER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.MASTER) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) IDBROKER(com.sequenceiq.it.cloudbreak.cloud.HostGroupType.IDBROKER) SdxTestClient(com.sequenceiq.it.cloudbreak.client.SdxTestClient) UseSpotInstances(com.sequenceiq.it.cloudbreak.util.spot.UseSpotInstances) StackTestClient(com.sequenceiq.it.cloudbreak.client.StackTestClient) FreeIpaTestClient(com.sequenceiq.it.cloudbreak.client.FreeIpaTestClient) List(java.util.List) EnvironmentTestDto(com.sequenceiq.it.cloudbreak.dto.environment.EnvironmentTestDto) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) SdxClusterStatusResponse(com.sequenceiq.sdx.api.model.SdxClusterStatusResponse) VolumeUtils(com.sequenceiq.it.cloudbreak.util.VolumeUtils) RecipeTestClient(com.sequenceiq.it.cloudbreak.client.RecipeTestClient) SdxTestDto(com.sequenceiq.it.cloudbreak.dto.sdx.SdxTestDto) DescribeFreeIpaResponse(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse) Description(com.sequenceiq.it.cloudbreak.context.Description) Test(org.testng.annotations.Test)

Example 59 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse in project cloudbreak by hortonworks.

the class FreeIpaCreationService method launchFreeIpa.

public DescribeFreeIpaResponse launchFreeIpa(CreateFreeIpaRequest request, String accountId) {
    String userCrn = crnService.getUserCrn();
    Future<String> ownerFuture = initiateOwnerFetching(userCrn);
    Credential credential = credentialService.getCredentialByEnvCrn(request.getEnvironmentCrn());
    DetailedEnvironmentResponse environment = measure(() -> cachedEnvironmentClientService.getByCrn(request.getEnvironmentCrn()), LOGGER, "Environment properties were queried under {} ms for environment {}", request.getEnvironmentCrn());
    Stack stack = stackConverter.convert(request, environment, accountId, ownerFuture, userCrn, credential.getCloudPlatform());
    stack.setAppVersion(appVersion);
    GetPlatformTemplateRequest getPlatformTemplateRequest = templateService.triggerGetTemplate(stack, credential);
    Telemetry telemetry = stack.getTelemetry();
    if (telemetry != null) {
        telemetry.setRules(accountTelemetryService.getAnonymizationRules(accountId));
    }
    cloudStorageFolderResolverService.updateStorageLocation(telemetry, FluentClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
    stack.setTelemetry(telemetry);
    Backup backup = stack.getBackup();
    backup = cloudBackupFolderResolverService.updateStorageLocation(backup, BackupClusterType.FREEIPA.value(), stack.getName(), stack.getResourceCrn());
    stack.setBackup(backup);
    fillInstanceMetadata(stack, environment);
    String template = templateService.waitGetTemplate(getPlatformTemplateRequest);
    stack.setTemplate(template);
    SecurityConfig securityConfig = tlsSecurityService.generateSecurityKeys(accountId);
    multiAzValidator.validateMultiAzForStack(stack.getPlatformvariant(), stack.getInstanceGroups());
    freeIpaRecommendationService.validateCustomInstanceType(stack, credential);
    try {
        Triple<Stack, ImageEntity, FreeIpa> stackImageFreeIpaTuple = transactionService.required(() -> {
            SecurityConfig savedSecurityConfig = securityConfigService.save(securityConfig);
            stack.setSecurityConfig(savedSecurityConfig);
            Stack savedStack = stackService.save(stack);
            ImageSettingsRequest imageSettingsRequest = request.getImage();
            ImageEntity image = imageService.create(savedStack, Objects.nonNull(imageSettingsRequest) ? imageSettingsRequest : new ImageSettingsRequest());
            FreeIpa freeIpa = freeIpaService.create(savedStack, request.getFreeIpa());
            return Triple.of(savedStack, image, freeIpa);
        });
        flowManager.notify(FlowChainTriggers.PROVISION_TRIGGER_EVENT, new StackEvent(FlowChainTriggers.PROVISION_TRIGGER_EVENT, stackImageFreeIpaTuple.getLeft().getId()));
        InMemoryStateStore.putStack(stack.getId(), PollGroup.POLLABLE);
        return stackToDescribeFreeIpaResponseConverter.convert(stackImageFreeIpaTuple.getLeft(), stackImageFreeIpaTuple.getMiddle(), stackImageFreeIpaTuple.getRight(), Optional.empty(), false);
    } catch (TransactionService.TransactionExecutionException e) {
        LOGGER.error("Creation of FreeIPA failed", e);
        throw new BadRequestException("Creation of FreeIPA failed: " + e.getCause().getMessage(), e);
    }
}
Also used : Credential(com.sequenceiq.freeipa.dto.Credential) ImageSettingsRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) ImageEntity(com.sequenceiq.freeipa.entity.ImageEntity) Backup(com.sequenceiq.freeipa.api.model.Backup) Telemetry(com.sequenceiq.common.api.telemetry.model.Telemetry) Stack(com.sequenceiq.freeipa.entity.Stack) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) StackEvent(com.sequenceiq.freeipa.flow.stack.StackEvent) SecurityConfig(com.sequenceiq.freeipa.entity.SecurityConfig) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) GetPlatformTemplateRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetPlatformTemplateRequest)

Example 60 with DescribeFreeIpaResponse

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse 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

DescribeFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.describe.DescribeFreeIpaResponse)60 Test (org.junit.jupiter.api.Test)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)17 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)8 EnumSource (org.junit.jupiter.params.provider.EnumSource)8 DistroXV1Request (com.sequenceiq.distrox.api.v1.distrox.model.DistroXV1Request)7 InstanceGroupResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupResponse)7 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)6 AttemptResults (com.dyngr.core.AttemptResults)5 Stack (com.sequenceiq.freeipa.entity.Stack)5 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)4 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)3 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)3 FreeIpaOperationFailedException (com.sequenceiq.environment.exception.FreeIpaOperationFailedException)3 BaseNamedFlowEvent (com.sequenceiq.flow.reactor.api.event.BaseNamedFlowEvent)3 InstanceMetaDataResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceMetaDataResponse)3 CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)3 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)3 ImageEntity (com.sequenceiq.freeipa.entity.ImageEntity)3 Environment (com.sequenceiq.environment.environment.domain.Environment)2