Search in sources :

Example 16 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.

the class FreeIpaCreationHandler method createInstanceGroupRequests.

private List<InstanceGroupRequest> createInstanceGroupRequests(CreateFreeIpaRequest createFreeIpaRequest, SecurityGroupRequest securityGroupRequest, EnvironmentDto environment, boolean multiAzRequired) {
    List<InstanceGroupRequest> instanceGroupRequests = new LinkedList<>();
    FreeIpaCreationDto freeIpaCreation = environment.getFreeIpaCreation();
    InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
    instanceGroupRequest.setName(MASTER_GROUP_NAME);
    instanceGroupRequest.setNodeCount(freeIpaCreation.getInstanceCountByGroup());
    instanceGroupRequest.setType(InstanceGroupType.MASTER);
    instanceGroupRequest.setSecurityGroup(securityGroupRequest);
    instanceGroupRequest.setInstanceTemplateRequest(createInstanceTemplate(freeIpaCreation));
    if (multiAzRequired && multiAzValidator.suportedMultiAzForEnvironment(environment.getCloudPlatform())) {
        FreeIpaNetworkProvider freeIpaNetworkProvider = freeIpaNetworkProviderMapByCloudPlatform.get(CloudPlatform.valueOf(environment.getCloudPlatform()));
        if (freeIpaNetworkProvider != null) {
            InstanceGroupNetworkRequest instanceGroupNetworkRequest = freeIpaNetworkProvider.networkByGroup(environment);
            instanceGroupRequest.setNetwork(instanceGroupNetworkRequest);
            createFreeIpaRequest.getPlacement().setAvailabilityZone(freeIpaNetworkProvider.availabilityZone(instanceGroupNetworkRequest, environment));
        }
    }
    instanceGroupRequests.add(instanceGroupRequest);
    return instanceGroupRequests;
}
Also used : InstanceGroupNetworkRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupNetworkRequest) InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) FreeIpaCreationDto(com.sequenceiq.environment.environment.dto.FreeIpaCreationDto) LinkedList(java.util.LinkedList)

Example 17 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestToStackConverter method convert.

public Stack convert(CreateFreeIpaRequest source, DetailedEnvironmentResponse environment, String accountId, Future<String> ownerFuture, String userCrn, String cloudPlatform) {
    Stack stack = new Stack();
    stack.setEnvironmentCrn(source.getEnvironmentCrn());
    stack.setAccountId(accountId);
    stack.setName(source.getName());
    stack.setCreated(System.currentTimeMillis());
    stack.setResourceCrn(crnService.createCrn(accountId, CrnResourceDescriptor.FREEIPA));
    MDCBuilder.addResourceCrn(stack.getResourceCrn());
    stack.setGatewayport(source.getGatewayPort() == null ? nginxPort : source.getGatewayPort());
    stack.setStackStatus(new StackStatus(stack, "Stack provision requested.", DetailedStackStatus.PROVISION_REQUESTED));
    stack.setAvailabilityZone(Optional.ofNullable(source.getPlacement()).map(PlacementBase::getAvailabilityZone).orElse(null));
    updateCloudPlatformAndRelatedFields(source, stack, cloudPlatform);
    stack.setStackAuthentication(stackAuthenticationConverter.convert(source.getAuthentication()));
    if (source.getNetwork() != null) {
        source.getNetwork().setCloudPlatform(CloudPlatform.valueOf(cloudPlatform));
        stack.setNetwork(networkConverter.convert(source.getNetwork()));
    }
    stack.setInstanceGroups(convertInstanceGroups(source, stack, environment, accountId));
    stack.setTelemetry(telemetryConverter.convert(source.getTelemetry()));
    if (source.getBackup() != null && isNotEmpty(source.getBackup().getStorageLocation())) {
        stack.setBackup(backupConverter.convert(source.getBackup()));
    } else {
        stack.setBackup(backupConverter.convert(source.getTelemetry()));
    }
    stack.setCdpNodeStatusMonitorUser(UUID.randomUUID().toString());
    stack.setCdpNodeStatusMonitorPassword(PasswordUtil.generatePassword());
    decorateStackWithTunnelAndCcm(stack, source);
    updateOwnerRelatedFields(source, accountId, ownerFuture, userCrn, stack);
    extendGatewaySecurityGroupWithDefaultGatewayCidrs(stack);
    return stack;
}
Also used : DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) PlacementBase(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.region.PlacementBase) Stack(com.sequenceiq.freeipa.entity.Stack)

Example 18 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestValidatorTest method validateShouldContainErrorsWhenThereAreZeroNodes.

@Test
void validateShouldContainErrorsWhenThereAreZeroNodes() {
    CreateFreeIpaRequest request = new CreateFreeIpaRequest();
    InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
    instanceGroupRequest.setNodeCount(0);
    request.setInstanceGroups(List.of(instanceGroupRequest));
    ValidationResult result = underTest.validate(request);
    assertThat(result.hasError()).isTrue();
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 19 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestValidatorTest method validateShouldNotContainErrors.

@Test
void validateShouldNotContainErrors() {
    CreateFreeIpaRequest request = new CreateFreeIpaRequest();
    InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
    instanceGroupRequest.setNodeCount(1);
    request.setInstanceGroups(List.of(instanceGroupRequest));
    ValidationResult result = underTest.validate(request);
    assertThat(result.hasError()).isFalse();
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 20 with CreateFreeIpaRequest

use of com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest in project cloudbreak by hortonworks.

the class CreateFreeIpaRequestValidatorTest method validateShouldNotContainErrorsForHA.

@Test
void validateShouldNotContainErrorsForHA() {
    CreateFreeIpaRequest request = new CreateFreeIpaRequest();
    InstanceGroupRequest instanceGroupRequest = new InstanceGroupRequest();
    instanceGroupRequest.setNodeCount(2);
    request.setInstanceGroups(List.of(instanceGroupRequest));
    ValidationResult result = underTest.validate(request);
    assertThat(result.hasError()).isFalse();
}
Also used : InstanceGroupRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest) CreateFreeIpaRequest(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

CreateFreeIpaRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.create.CreateFreeIpaRequest)23 Test (org.junit.jupiter.api.Test)18 InstanceGroupRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceGroupRequest)10 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)6 Stack (com.sequenceiq.freeipa.entity.Stack)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)5 ExtendedPollingResult (com.sequenceiq.cloudbreak.polling.ExtendedPollingResult)5 Telemetry (com.sequenceiq.common.api.telemetry.model.Telemetry)5 Credential (com.sequenceiq.environment.credential.domain.Credential)5 Environment (com.sequenceiq.environment.environment.domain.Environment)5 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)4 Backup (com.sequenceiq.freeipa.api.model.Backup)4 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 TelemetryRequest (com.sequenceiq.common.api.telemetry.request.TelemetryRequest)3 FreeIpaServerRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.FreeIpaServerRequest)3 ImageSettingsRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.image.ImageSettingsRequest)3 InstanceTemplateRequest (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceTemplateRequest)3