Search in sources :

Example 66 with StackV4Request

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

the class SdxService method getStackRequest.

private StackV4Request getStackRequest(SdxClusterShape shape, boolean razEnabled, StackV4Request internalStackV4Request, CloudPlatform cloudPlatform, String runtimeVersion, ImageSettingsV4Request imageSettingsV4Request) {
    if (internalStackV4Request == null) {
        StackV4Request stackRequest = cdpConfigService.getConfigForKey(new CDPConfigKey(cloudPlatform, shape, runtimeVersion));
        if (stackRequest == null) {
            LOGGER.error("Can't find template for cloudplatform: {}, shape {}, cdp version: {}", cloudPlatform, shape, runtimeVersion);
            throw new BadRequestException("Can't find template for cloudplatform: " + cloudPlatform + ", shape: " + shape + ", runtime version: " + runtimeVersion);
        }
        stackRequest.getCluster().setRangerRazEnabled(razEnabled);
        if (imageSettingsV4Request != null) {
            stackRequest.setImage(imageSettingsV4Request);
        }
        return stackRequest;
    } else {
        // We have provided a --ranger-raz-enabled flag in the CLI, but it will
        // get overwritten if you use a custom json (using --cli-json). To avoid
        // this, we will set the raz enablement here as well. See CB-7474 for more details
        internalStackV4Request.getCluster().setRangerRazEnabled(razEnabled);
        return internalStackV4Request;
    }
}
Also used : StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException)

Example 67 with StackV4Request

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

the class SdxService method updateAwsSpotParameters.

private void updateAwsSpotParameters(StackV4Request stackRequest, SdxAwsSpotParameters sdxSpotParameters) {
    stackRequest.getInstanceGroups().stream().map(InstanceGroupV4Request::getTemplate).peek(template -> {
        if (template.getAws() == null) {
            template.setAws(new AwsInstanceTemplateV4Parameters());
        }
    }).map(InstanceTemplateV4Base::getAws).peek(aws -> {
        if (aws.getSpot() == null) {
            aws.setSpot(new AwsInstanceTemplateV4SpotParameters());
        }
    }).map(AwsInstanceTemplateV4Parameters::getSpot).forEach(spot -> {
        spot.setPercentage(sdxSpotParameters.getPercentage());
        spot.setMaxPrice(sdxSpotParameters.getMaxPrice());
    });
}
Also used : AwsInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters) AwsInstanceTemplateV4SpotParameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4SpotParameters)

Example 68 with StackV4Request

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

the class StackRequestManifester method setupInstanceVolumeEncryptionForGcp.

@VisibleForTesting
void setupInstanceVolumeEncryptionForGcp(StackV4Request stackRequest, DetailedEnvironmentResponse environmentResponse) {
    String encryptionKey = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getGcp).map(GcpEnvironmentParameters::getGcpResourceEncryptionParameters).map(GcpResourceEncryptionParameters::getEncryptionKey).orElse(null);
    if (encryptionKey != null) {
        stackRequest.getInstanceGroups().forEach(ig -> {
            GcpInstanceTemplateV4Parameters gcp = ig.getTemplate().createGcp();
            GcpEncryptionV4Parameters encryption = gcp.getEncryption();
            if (encryption == null) {
                encryption = new GcpEncryptionV4Parameters();
                gcp.setEncryption(encryption);
            }
            gcp.getEncryption().setType(EncryptionType.CUSTOM);
            gcp.getEncryption().setKey(encryptionKey);
            gcp.getEncryption().setKeyEncryptionMethod(KeyEncryptionMethod.KMS);
        });
    }
}
Also used : GcpEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.gcp.GcpEnvironmentParameters) GcpInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpInstanceTemplateV4Parameters) GcpEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpEncryptionV4Parameters) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 69 with StackV4Request

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

the class StackRequestManifester method setupInstanceVolumeEncryptionForAzure.

@VisibleForTesting
void setupInstanceVolumeEncryptionForAzure(StackV4Request stackRequest, DetailedEnvironmentResponse environmentResponse) {
    Optional<String> encryptionKeyUrl = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getAzure).map(AzureEnvironmentParameters::getResourceEncryptionParameters).map(AzureResourceEncryptionParameters::getEncryptionKeyUrl);
    Optional<String> diskEncryptionSetId = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getAzure).map(AzureEnvironmentParameters::getResourceEncryptionParameters).map(AzureResourceEncryptionParameters::getDiskEncryptionSetId);
    stackRequest.getInstanceGroups().forEach(ig -> {
        AzureInstanceTemplateV4Parameters azure = ig.getTemplate().createAzure();
        AzureEncryptionV4Parameters encryption = azure.getEncryption();
        if (encryption == null) {
            encryption = new AzureEncryptionV4Parameters();
            azure.setEncryption(encryption);
        }
        if (encryptionKeyUrl.isPresent() && diskEncryptionSetId.isPresent()) {
            azure.getEncryption().setKey(encryptionKeyUrl.get());
            azure.getEncryption().setType(EncryptionType.CUSTOM);
            azure.getEncryption().setDiskEncryptionSetId(diskEncryptionSetId.get());
        }
        if (entitlementService.isAzureEncryptionAtHostEnabled(environmentResponse.getAccountId())) {
            azure.getEncryption().setEncryptionAtHostEnabled(Boolean.TRUE);
        }
    });
}
Also used : AzureInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureInstanceTemplateV4Parameters) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) AzureEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AzureEncryptionV4Parameters) AzureResourceEncryptionParameters(com.sequenceiq.environment.api.v1.environment.model.request.azure.AzureResourceEncryptionParameters) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 70 with StackV4Request

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

the class StackRequestManifester method setupInstanceVolumeEncryptionForAws.

@VisibleForTesting
void setupInstanceVolumeEncryptionForAws(StackV4Request stackRequest, DetailedEnvironmentResponse environmentResponse) {
    String encryptionKeyArn = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getAws).map(AwsEnvironmentParameters::getAwsDiskEncryptionParameters).map(AwsDiskEncryptionParameters::getEncryptionKeyArn).orElse(null);
    stackRequest.getInstanceGroups().forEach(ig -> {
        AwsInstanceTemplateV4Parameters aws = ig.getTemplate().createAws();
        AwsEncryptionV4Parameters encryption = aws.getEncryption();
        if (encryption == null) {
            encryption = new AwsEncryptionV4Parameters();
            aws.setEncryption(encryption);
        }
        if (encryption.getType() == null) {
            aws.getEncryption().setType(EncryptionType.DEFAULT);
        }
        if (encryptionKeyArn != null) {
            aws.getEncryption().setType(EncryptionType.CUSTOM);
            aws.getEncryption().setKey(encryptionKeyArn);
        }
    });
}
Also used : AwsInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters) AwsEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters) AwsEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsEncryptionV4Parameters) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

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