use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class EnvironmentValidatorService method validateSecurityAccessModification.
public ValidationResult validateSecurityAccessModification(SecurityAccessDto securityAccessDto, Environment environment) {
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
resultBuilder.ifError(() -> isNotEmpty(securityAccessDto.getCidr()), "The CIDR could not be updated in the environment");
resultBuilder.ifError(() -> isNotEmpty(environment.getCidr()) && isAnySecurityGroupMissing(securityAccessDto), "The CIDR can be replaced with the default and knox security groups, please add to the request");
resultBuilder.ifError(() -> isAllSecurityGroupMissing(securityAccessDto), "Please add the default or knox security groups, we cannot edit with empty value.");
return resultBuilder.build();
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class EnvironmentValidatorService method validateAuthenticationModification.
public ValidationResult validateAuthenticationModification(EnvironmentEditDto editDto, Environment environment) {
ValidationResultBuilder validationResultBuilder = ValidationResult.builder();
AuthenticationDto authenticationDto = editDto.getAuthentication();
String publicKeyId = authenticationDto.getPublicKeyId();
Optional<PublicKeyConnector> publicKeyConnector = environmentResourceService.getPublicKeyConnector(environment.getCloudPlatform());
if (publicKeyConnector.isEmpty() && isNotEmpty(publicKeyId)) {
validationResultBuilder.error("The change of publicKeyId is not supported on " + environment.getCloudPlatform());
} else {
String publicKey = authenticationDto.getPublicKey();
if (isNotEmpty(publicKeyId) && isNotEmpty(publicKey)) {
validationResultBuilder.error("You should define either publicKey or publicKeyId only, but not both.");
}
if (StringUtils.isEmpty(publicKeyId) && StringUtils.isEmpty(publicKey)) {
validationResultBuilder.error("You should define either the publicKey or the publicKeyId.");
}
if (isNotEmpty(publicKeyId) && !environmentResourceService.isPublicKeyIdExists(environment, publicKeyId)) {
validationResultBuilder.error(String.format("The publicKeyId with name of '%s' does not exist on the provider.", publicKeyId));
}
if (isNotEmpty(publicKey)) {
ValidationResult validationResult = publicKeyValidator.validatePublicKey(publicKey);
validationResultBuilder.merge(validationResult);
}
}
return validationResultBuilder.build();
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class EnvironmentLogStorageLocationValidator method validateTelemetryLoggingStorageLocation.
/**
* Validate telemetry related logging storage location.
* Currently, filter out cloudwatch (or any other cloud logging service) related validations
*/
public ValidationResult validateTelemetryLoggingStorageLocation(Environment environment) {
ValidationResultBuilder resultBuilder = new ValidationResultBuilder();
Optional.ofNullable(environment.getTelemetry()).map(EnvironmentTelemetry::getLogging).filter(logging -> isCloudStorageEnabled(logging) && logging.getCloudwatch() == null).map(EnvironmentLogging::getStorageLocation).ifPresent(location -> cloudStorageLocationValidator.validate(location, environment, resultBuilder));
return resultBuilder.build();
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class EnvironmentNetworkProviderValidator method validate.
public ValidationResult validate(EnvironmentValidationDto environmentValidationDto) {
EnvironmentDto environmentDto = environmentValidationDto.getEnvironmentDto();
NetworkDto network = environmentDto.getNetwork();
String cloudPlatform = environmentDto.getCloudPlatform();
ValidationResultBuilder resultBuilder = ValidationResult.builder();
validateNetworkHasTheSamePropertyFilledAsTheDesiredCloudPlatform(network, cloudPlatform, resultBuilder);
validateNetwork(network, cloudPlatform, resultBuilder, environmentValidationDto);
validateSecurityGroup(environmentValidationDto, cloudPlatform, resultBuilder);
return resultBuilder.build();
}
use of com.sequenceiq.cloudbreak.validation.ValidationResult.ValidationResultBuilder in project cloudbreak by hortonworks.
the class EnvironmentRegionValidator method validateLocation.
public ValidationResultBuilder validateLocation(String requestedLocation, Set<String> requestedRegions, CloudRegions cloudRegions, String cloudPlatform) {
ValidationResultBuilder resultBuilder = ValidationResult.builder();
Set<String> requestedRegionNames = new HashSet<>(requestedRegions);
if (!requestedRegionNames.isEmpty() && !requestedRegionNames.contains(requestedLocation) && cloudRegions.areRegionsSupported()) {
if (!CloudPlatform.MOCK.equalsIgnoreCase(cloudPlatform)) {
resultBuilder.error(String.format("Location [%s] is not one of the regions: [%s].", requestedLocation, String.join(", ", requestedRegionNames)));
}
}
return resultBuilder;
}
Aggregations