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));
}
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());
}
}
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());
}
}
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());
}
}
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());
}
}
Aggregations