Search in sources :

Example 1 with EncryptionType

use of com.sequenceiq.common.api.type.EncryptionType in project cloudbreak by hortonworks.

the class InstanceTemplateParameterConverter method convert.

private AwsEncryptionV4Parameters convert(AwsEncryptionV1Parameters source, DetailedEnvironmentResponse environment) {
    AwsEncryptionV4Parameters response = new AwsEncryptionV4Parameters();
    String dataHubEncryptionKey = source.getKey();
    EncryptionType dataHubEncryptionKeyType = source.getType();
    if (EncryptionType.CUSTOM.equals(dataHubEncryptionKeyType)) {
        response.setKey(dataHubEncryptionKey);
        response.setType(dataHubEncryptionKeyType);
    } else {
        String environmentEncryptionKeyArn = Optional.ofNullable(environment).map(DetailedEnvironmentResponse::getAws).map(AwsEnvironmentParameters::getAwsDiskEncryptionParameters).map(AwsDiskEncryptionParameters::getEncryptionKeyArn).orElse(null);
        if (environmentEncryptionKeyArn != null && !environmentEncryptionKeyArn.isEmpty()) {
            response.setKey(environmentEncryptionKeyArn);
            response.setType(EncryptionType.CUSTOM);
        } else {
            response.setType(EncryptionType.DEFAULT);
        }
    }
    return response;
}
Also used : EncryptionType(com.sequenceiq.common.api.type.EncryptionType) AwsEncryptionV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsEncryptionV4Parameters) AwsEnvironmentParameters(com.sequenceiq.environment.api.v1.environment.model.request.aws.AwsEnvironmentParameters)

Example 2 with EncryptionType

use of com.sequenceiq.common.api.type.EncryptionType in project cloudbreak by hortonworks.

the class StackValidator method validateEncryptionKey.

private void validateEncryptionKey(Stack stack, ValidationResultBuilder validationBuilder) {
    if (StringUtils.isEmpty(stack.getEnvironmentCrn())) {
        validationBuilder.error("Environment CRN cannot be null or empty.");
        return;
    }
    DetailedEnvironmentResponse environment = environmentClientService.getByCrn(stack.getEnvironmentCrn());
    stack.getInstanceGroups().stream().filter(request -> isEncryptionTypeSetUp(request.getTemplate())).filter(request -> {
        EncryptionType valueForTypeKey = getEncryptionType(request.getTemplate());
        return EncryptionType.CUSTOM.equals(valueForTypeKey);
    }).forEach(request -> {
        checkEncryptionKeyValidityForInstanceGroupWhenKeysAreListable(request, environment.getCrn(), stack.getRegion(), validationBuilder);
    });
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) GcpInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpInstanceTemplateV4Parameters) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) AwsInstanceTemplateV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters) Inject(javax.inject.Inject) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) CDP_CB_AWS_NATIVE_DATALAKE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AWS_NATIVE_DATALAKE) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) CloudEncryptionKey(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey) DATALAKE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.DATALAKE) PlatformResourceClientService(com.sequenceiq.cloudbreak.service.environment.PlatformResourceClientService) InstanceTemplateValidator(com.sequenceiq.cloudbreak.controller.validation.template.InstanceTemplateValidator) CloudEncryptionKeys(com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys) AWS_NATIVE_VARIANT(com.sequenceiq.cloudbreak.cloud.aws.common.AwsConstants.AwsVariant.AWS_NATIVE_VARIANT) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) CDP_CB_AWS_NATIVE(com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AWS_NATIVE) Crn(com.sequenceiq.cloudbreak.auth.crn.Crn) Template(com.sequenceiq.cloudbreak.domain.Template) WORKLOAD(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.WORKLOAD) Component(org.springframework.stereotype.Component) EncryptionType(com.sequenceiq.common.api.type.EncryptionType) CollectionUtils(org.springframework.util.CollectionUtils) LEGACY(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.LEGACY) Optional(java.util.Optional) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) StringUtils(org.springframework.util.StringUtils) EncryptionType(com.sequenceiq.common.api.type.EncryptionType) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)

Example 3 with EncryptionType

use of com.sequenceiq.common.api.type.EncryptionType in project cloudbreak by hortonworks.

the class AwsInstanceTemplateV4Parameters method asMap.

@Override
public Map<String, Object> asMap() {
    Map<String, Object> map = super.asMap();
    doIfNotNull(spot, sp -> {
        putIfValueNotNull(map, AwsInstanceTemplate.EC2_SPOT_PERCENTAGE, sp.getPercentage());
        putIfValueNotNull(map, AwsInstanceTemplate.EC2_SPOT_MAX_PRICE, sp.getMaxPrice());
    });
    if (encryption != null) {
        EncryptionType encryptionType = encryption.getType();
        putIfValueNotNull(map, InstanceTemplate.VOLUME_ENCRYPTION_KEY_TYPE, encryptionType);
        putIfValueNotNull(map, AwsInstanceTemplate.EBS_ENCRYPTION_ENABLED, encryptionType != null && encryptionType != EncryptionType.NONE);
    }
    putIfValueNotNull(map, AwsInstanceTemplate.PLACEMENT_GROUP_STRATEGY, Optional.ofNullable(placementGroup).map(AwsPlacementGroupV4Parameters::getStrategy).orElse(AwsPlacementGroupStrategy.NONE).name());
    return map;
}
Also used : EncryptionType(com.sequenceiq.common.api.type.EncryptionType)

Aggregations

EncryptionType (com.sequenceiq.common.api.type.EncryptionType)3 DATALAKE (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.DATALAKE)1 LEGACY (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.LEGACY)1 WORKLOAD (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType.WORKLOAD)1 AwsEncryptionV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsEncryptionV4Parameters)1 AwsInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.AwsInstanceTemplateV4Parameters)1 GcpInstanceTemplateV4Parameters (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.template.GcpInstanceTemplateV4Parameters)1 EntitlementService (com.sequenceiq.cloudbreak.auth.altus.EntitlementService)1 CDP_CB_AWS_NATIVE (com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AWS_NATIVE)1 CDP_CB_AWS_NATIVE_DATALAKE (com.sequenceiq.cloudbreak.auth.altus.model.Entitlement.CDP_CB_AWS_NATIVE_DATALAKE)1 Crn (com.sequenceiq.cloudbreak.auth.crn.Crn)1 AWS_NATIVE_VARIANT (com.sequenceiq.cloudbreak.cloud.aws.common.AwsConstants.AwsVariant.AWS_NATIVE_VARIANT)1 CloudEncryptionKey (com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKey)1 CloudEncryptionKeys (com.sequenceiq.cloudbreak.cloud.model.CloudEncryptionKeys)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 InstanceTemplateValidator (com.sequenceiq.cloudbreak.controller.validation.template.InstanceTemplateValidator)1 Template (com.sequenceiq.cloudbreak.domain.Template)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)1 EnvironmentClientService (com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService)1