use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE in project cloudbreak by hortonworks.
the class LoadBalancerConfigService method setupKnoxTargetGroup.
private Optional<TargetGroup> setupKnoxTargetGroup(Stack stack, boolean dryRun) {
TargetGroup knoxTargetGroup = null;
Set<String> knoxGatewayGroupNames = getKnoxGatewayGroups(stack);
Set<InstanceGroup> knoxGatewayInstanceGroups = stack.getInstanceGroups().stream().filter(ig -> knoxGatewayGroupNames.contains(ig.getGroupName())).collect(Collectors.toSet());
if (AZURE.equalsIgnoreCase(stack.getCloudPlatform()) && knoxGatewayInstanceGroups.size() > 1) {
throw new CloudbreakServiceException("For Azure load balancers, Knox must be defined in a single instance group.");
} else if (!knoxGatewayInstanceGroups.isEmpty()) {
LOGGER.info("Knox gateway instance found; enabling Knox load balancer configuration.");
knoxTargetGroup = new TargetGroup();
knoxTargetGroup.setType(TargetGroupType.KNOX);
knoxTargetGroup.setInstanceGroups(knoxGatewayInstanceGroups);
if (!dryRun) {
LOGGER.debug("Adding target group to Knox gateway instances groups.");
TargetGroup finalKnoxTargetGroup = knoxTargetGroup;
knoxGatewayInstanceGroups.forEach(ig -> ig.addTargetGroup(finalKnoxTargetGroup));
} else {
LOGGER.debug("Dry run, skipping instance group/target group linkage.");
}
}
return Optional.ofNullable(knoxTargetGroup);
}
use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE in project cloudbreak by hortonworks.
the class EnvironmentCreationService method validateEncryptionKey.
private ValidationResult validateEncryptionKey(EnvironmentCreationDto creationDto) {
ValidationResultBuilder resultBuilder = ValidationResult.builder();
String cloudPlatform = creationDto.getCloudPlatform().toLowerCase(Locale.ROOT);
switch(cloudPlatform) {
case "azure":
String encryptionKeyUrl = Optional.ofNullable(creationDto.getParameters()).map(paramsDto -> paramsDto.getAzureParametersDto()).map(azureParamsDto -> azureParamsDto.getAzureResourceEncryptionParametersDto()).map(azureREParamsDto -> azureREParamsDto.getEncryptionKeyUrl()).orElse(null);
if (encryptionKeyUrl != null) {
resultBuilder.merge(validatorService.validateEncryptionKeyUrl(encryptionKeyUrl, creationDto.getAccountId()));
}
break;
case "gcp":
String encryptionKey = Optional.ofNullable(creationDto.getParameters()).map(parametersDto -> parametersDto.getGcpParametersDto()).map(gcpParametersDto -> gcpParametersDto.getGcpResourceEncryptionParametersDto()).map(gcpREParamsDto -> gcpREParamsDto.getEncryptionKey()).orElse(null);
if (encryptionKey != null) {
resultBuilder.merge(validatorService.validateEncryptionKey(encryptionKey, creationDto.getAccountId()));
}
break;
case "aws":
String encryptionKeyArn = Optional.ofNullable(creationDto.getParameters()).map(paramsDto -> paramsDto.getAwsParametersDto()).map(awsParamsDto -> awsParamsDto.getAwsDiskEncryptionParametersDto()).map(awsREparamsDto -> awsREparamsDto.getEncryptionKeyArn()).orElse(null);
if (encryptionKeyArn != null) {
resultBuilder.merge(validatorService.validateEncryptionKeyArn(encryptionKeyArn, creationDto.getAccountId()));
}
break;
default:
break;
}
return resultBuilder.build();
}
Aggregations