Search in sources :

Example 66 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class GatewayTopologyJsonToExposedServicesConverterTest method testWithSingleExposedService.

@Test
public void testWithSingleExposedService() {
    GatewayTopologyV4Request gatewayTopologyJson = new GatewayTopologyV4Request();
    gatewayTopologyJson.setTopologyName(TOPOLOGY_NAME);
    gatewayTopologyJson.setExposedServices(Collections.singletonList(CLOUDERA_MANAGER_UI));
    when(exposedServiceListValidator.validate(anyList())).thenReturn(new ValidationResultBuilder().build());
    ExposedServices exposedServices = underTest.convert(gatewayTopologyJson);
    assertEquals(1L, exposedServices.getServices().size());
    assertEquals(CLOUDERA_MANAGER_UI, exposedServices.getServices().get(0));
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) GatewayTopologyV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request) ExposedServices(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.ExposedServices) Test(org.junit.Test)

Example 67 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class SdxService method validateShape.

private void validateShape(SdxClusterShape shape, String runtime, DetailedEnvironmentResponse environment) {
    ValidationResultBuilder validationBuilder = new ValidationResultBuilder();
    if (SdxClusterShape.MICRO_DUTY.equals(shape)) {
        if (!entitlementService.microDutySdxEnabled(Crn.safeFromString(environment.getCreator()).getAccountId())) {
            validationBuilder.error(String.format("Provisioning a micro duty data lake cluster is not enabled for %s. " + "Contact Cloudera support to enable CDP_MICRO_DUTY_SDX entitlement for the account.", environment.getCloudPlatform()));
        }
        if (!isShapeVersionSupportedByRuntime(runtime, MICRO_DUTY_REQUIRED_VERSION)) {
            validationBuilder.error("Provisioning a Micro Duty SDX shape is only valid for CM version greater than or equal to " + MICRO_DUTY_REQUIRED_VERSION + " and not " + runtime);
        }
    } else if (SdxClusterShape.MEDIUM_DUTY_HA.equals(shape)) {
        if (!isShapeVersionSupportedByRuntime(runtime, MEDIUM_DUTY_REQUIRED_VERSION)) {
            validationBuilder.error("Provisioning a Medium Duty SDX shape is only valid for CM version greater than or equal to " + MEDIUM_DUTY_REQUIRED_VERSION + " and not " + runtime);
        }
    }
    ValidationResult validationResult = validationBuilder.build();
    if (validationResult.hasError()) {
        throw new BadRequestException(validationResult.getFormattedErrors());
    }
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Example 68 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class SdxService method validateRazEnablement.

private void validateRazEnablement(String runtime, boolean razEnabled, DetailedEnvironmentResponse environment) {
    ValidationResultBuilder validationBuilder = new ValidationResultBuilder();
    if (razEnabled) {
        CloudPlatform cloudPlatform = EnumUtils.getEnumIgnoreCase(CloudPlatform.class, environment.getCloudPlatform());
        if (!(AWS.equals(cloudPlatform) || AZURE.equals(cloudPlatform))) {
            validationBuilder.error("Provisioning Ranger Raz is only valid for Amazon Web Services and Microsoft Azure.");
        }
        if (!isRazSupported(runtime, cloudPlatform)) {
            String errorMsg = AWS.equals(cloudPlatform) ? "Provisioning Ranger Raz on Amazon Web Services is only valid for CM version greater than or equal to 7.2.2 and not " : "Provisioning Ranger Raz on Microsoft Azure is only valid for CM version greater than or equal to 7.2.1 and not ";
            validationBuilder.error(errorMsg + runtime);
        }
    }
    ValidationResult validationResult = validationBuilder.build();
    if (validationResult.hasError()) {
        throw new BadRequestException(validationResult.getFormattedErrors());
    }
}
Also used : CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Example 69 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class SdxService method validateMultiAz.

private void validateMultiAz(boolean enableMultiAz, DetailedEnvironmentResponse environmentResponse) {
    ValidationResultBuilder validationBuilder = new ValidationResultBuilder();
    if (enableMultiAz) {
        if (!environmentResponse.getCloudPlatform().equals(AWS.name())) {
            validationBuilder.error("Provisioning a multi AZ cluster is only enabled for AWS.");
        }
    }
    ValidationResult validationResult = validationBuilder.build();
    if (validationResult.hasError()) {
        throw new BadRequestException(validationResult.getFormattedErrors());
    }
}
Also used : ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Example 70 with ValidationResultBuilder

use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.

the class SdxService method validateRuntimeAndImage.

private void validateRuntimeAndImage(SdxClusterRequest clusterRequest, DetailedEnvironmentResponse environment, ImageSettingsV4Request imageSettingsV4Request, ImageV4Response imageV4Response) {
    ValidationResultBuilder validationBuilder = new ValidationResultBuilder();
    CloudPlatform cloudPlatform = EnumUtils.getEnumIgnoreCase(CloudPlatform.class, environment.getCloudPlatform());
    if (imageV4Response != null) {
        if (clusterRequest.getRuntime() != null) {
            validationBuilder.error("SDX cluster request must not specify both runtime version and image at the same time because image " + "decides runtime version.");
        }
    } else if (imageSettingsV4Request != null && clusterRequest.getRuntime() == null) {
        if (cloudPlatform.equals(CloudPlatform.MOCK)) {
            clusterRequest.setRuntime(MEDIUM_DUTY_REQUIRED_VERSION);
        } else {
            validationBuilder.error("SDX cluster request has null runtime version and null image response. It cannot " + "determine the runtime version.");
        }
    }
    ValidationResult validationResult = validationBuilder.build();
    if (validationResult.hasError()) {
        throw new BadRequestException(validationResult.getFormattedErrors());
    }
}
Also used : CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) ValidationResultBuilder(com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) ValidationResult(com.sequenceiq.cloudbreak.validation.ValidationResult)

Aggregations

ValidationResultBuilder (com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder)169 Test (org.junit.jupiter.api.Test)107 ValidationResult (com.sequenceiq.cloudbreak.validation.ValidationResult)67 NetworkDto (com.sequenceiq.environment.network.dto.NetworkDto)62 EnvironmentValidationDto (com.sequenceiq.environment.environment.dto.EnvironmentValidationDto)35 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)33 AzureParams (com.sequenceiq.environment.network.dto.AzureParams)33 Test (org.junit.Test)20 SpiFileSystem (com.sequenceiq.cloudbreak.cloud.model.SpiFileSystem)16 Environment (com.sequenceiq.environment.environment.domain.Environment)11 ObjectStorageMetadataRequest (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataRequest)10 ObjectStorageMetadataResponse (com.sequenceiq.cloudbreak.cloud.model.objectstorage.ObjectStorageMetadataResponse)10 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)10 Credential (com.sequenceiq.environment.credential.domain.Credential)10 Region (com.sequenceiq.environment.environment.domain.Region)9 PlatformResourceRequest (com.sequenceiq.environment.platformresource.PlatformResourceRequest)9 EnvironmentCreationDto (com.sequenceiq.environment.environment.dto.EnvironmentCreationDto)7 InstanceProfile (com.amazonaws.services.identitymanagement.model.InstanceProfile)6 Role (com.amazonaws.services.identitymanagement.model.Role)6 GatewayTopologyV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.topology.GatewayTopologyV4Request)6