Search in sources :

Example 61 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method setupInstanceVolumeEncryptionTestWhenAzureAndEncryptionAtHostAndNoEncryptionParameters.

@Test
void setupInstanceVolumeEncryptionTestWhenAzureAndEncryptionAtHostAndNoEncryptionParameters() {
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setAccountId(ACCOUNT_ID);
    envResponse.setCloudPlatform(CloudPlatform.AZURE.name());
    when(entitlementService.isAzureEncryptionAtHostEnabled(ACCOUNT_ID)).thenReturn(Boolean.TRUE);
    InstanceGroupV4Request instanceGroupV4Request = createInstanceGroupV4Request();
    InstanceTemplateV4Request instanceTemplateV4Request = instanceGroupV4Request.getTemplate();
    instanceTemplateV4Request.createAzure();
    when(stackV4Request.getInstanceGroups()).thenReturn(List.of(instanceGroupV4Request));
    underTest.setupInstanceVolumeEncryption(stackV4Request, envResponse);
    verifyAzureEncryptionForEncryptionAtHost(instanceGroupV4Request.getTemplate(), Boolean.TRUE);
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 62 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class StackRequestManifesterTest method setupInstanceVolumeEncryptionTestWhenAwsAndNoEncryptionParameters.

@Test
void setupInstanceVolumeEncryptionTestWhenAwsAndNoEncryptionParameters() {
    DetailedEnvironmentResponse envResponse = new DetailedEnvironmentResponse();
    envResponse.setCloudPlatform(CloudPlatform.AWS.name());
    InstanceGroupV4Request instanceGroupV4Request = createInstanceGroupV4Request();
    InstanceTemplateV4Request instanceTemplateV4Request = instanceGroupV4Request.getTemplate();
    instanceTemplateV4Request.createAws();
    when(stackV4Request.getInstanceGroups()).thenReturn(List.of(instanceGroupV4Request));
    underTest.setupInstanceVolumeEncryption(stackV4Request, envResponse);
    verifyAwsEncryption(instanceTemplateV4Request, EncryptionType.DEFAULT);
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 63 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class SdxService method overrideDefaultTemplateValues.

private void overrideDefaultTemplateValues(StackV4Request defaultTemplate, List<SdxInstanceGroupRequest> customInstanceGroups, String accountId) {
    if (isCustomInstanceTypeSelected(customInstanceGroups) && !entitlementService.isDatalakeSelectInstanceTypeEnabled(accountId)) {
        throw new BadRequestException("Datalake instance type selection is not enabled! " + "Contact Cloudera support to enable CDP_DATALAKE_SELECT_INSTANCE_TYPE entitlement for the account.");
    }
    if (CollectionUtils.isNotEmpty(customInstanceGroups)) {
        LOGGER.debug("Override default template with custom instance groups from request.");
        customInstanceGroups.forEach(customInstanceGroup -> {
            InstanceGroupV4Request templateInstanceGroup = defaultTemplate.getInstanceGroups().stream().filter(templateGroup -> templateGroup.getName() != null && templateGroup.getName().equals(customInstanceGroup.getName())).findAny().orElseThrow(() -> new BadRequestException("Custom instance group is missing from default template: " + customInstanceGroup.getName()));
            overrideInstanceType(templateInstanceGroup, customInstanceGroup.getInstanceType());
        });
    }
}
Also used : BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) InstanceGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)

Example 64 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class SdxService method updateAzureLoadBalancerSkuIfPresent.

private void updateAzureLoadBalancerSkuIfPresent(StackV4Request stackRequest, SdxClusterRequest sdxClusterRequest) {
    Optional.ofNullable(sdxClusterRequest.getAzure()).map(SdxAzureBase::getLoadBalancerSku).ifPresent(sku -> {
        AzureStackV4Parameters azureParameters = stackRequest.createAzure();
        azureParameters.setLoadBalancerSku(sku);
        stackRequest.setAzure(azureParameters);
    });
}
Also used : AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters)

Example 65 with StackV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.

the class SdxService method prepareDefaultSecurityConfigs.

protected StackV4Request prepareDefaultSecurityConfigs(StackV4Request internalRequest, StackV4Request stackV4Request, CloudPlatform cloudPlatform) {
    if (internalRequest == null && !List.of("MOCK", "YARN").contains(cloudPlatform.name())) {
        stackV4Request.getInstanceGroups().forEach(instance -> {
            SecurityGroupV4Request groupRequest = new SecurityGroupV4Request();
            if (InstanceGroupType.CORE.equals(instance.getType())) {
                groupRequest.setSecurityRules(rulesWithPorts("22"));
            } else if (InstanceGroupType.GATEWAY.equals(instance.getType())) {
                groupRequest.setSecurityRules(rulesWithPorts("443", "22"));
            } else {
                throw new IllegalStateException("Unknown instance group type " + instance.getType());
            }
            instance.setSecurityGroup(groupRequest);
        });
    }
    return stackV4Request;
}
Also used : SecurityGroupV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.securitygroup.SecurityGroupV4Request)

Aggregations

StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)105 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)66 Test (org.junit.jupiter.api.Test)58 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)52 InstanceGroupV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.InstanceGroupV4Request)36 Test (org.junit.Test)36 LoadBalancer (com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)34 CloudSubnet (com.sequenceiq.cloudbreak.cloud.model.CloudSubnet)33 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)33 SubnetTest (com.sequenceiq.cloudbreak.core.network.SubnetTest)32 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)31 ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)17 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)14 Map (java.util.Map)13 Set (java.util.Set)13 Optional (java.util.Optional)12 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)12 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)11 HashMap (java.util.HashMap)11 List (java.util.List)11