use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class SdxService method getStackRequest.
private StackV4Request getStackRequest(SdxClusterShape shape, boolean razEnabled, StackV4Request internalStackV4Request, CloudPlatform cloudPlatform, String runtimeVersion, ImageSettingsV4Request imageSettingsV4Request) {
if (internalStackV4Request == null) {
StackV4Request stackRequest = cdpConfigService.getConfigForKey(new CDPConfigKey(cloudPlatform, shape, runtimeVersion));
if (stackRequest == null) {
LOGGER.error("Can't find template for cloudplatform: {}, shape {}, cdp version: {}", cloudPlatform, shape, runtimeVersion);
throw new BadRequestException("Can't find template for cloudplatform: " + cloudPlatform + ", shape: " + shape + ", runtime version: " + runtimeVersion);
}
stackRequest.getCluster().setRangerRazEnabled(razEnabled);
if (imageSettingsV4Request != null) {
stackRequest.setImage(imageSettingsV4Request);
}
return stackRequest;
} else {
// We have provided a --ranger-raz-enabled flag in the CLI, but it will
// get overwritten if you use a custom json (using --cli-json). To avoid
// this, we will set the raz enablement here as well. See CB-7474 for more details
internalStackV4Request.getCluster().setRangerRazEnabled(razEnabled);
return internalStackV4Request;
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class SdxService method updateAwsSpotParameters.
private void updateAwsSpotParameters(StackV4Request stackRequest, SdxAwsSpotParameters sdxSpotParameters) {
stackRequest.getInstanceGroups().stream().map(InstanceGroupV4Request::getTemplate).peek(template -> {
if (template.getAws() == null) {
template.setAws(new AwsInstanceTemplateV4Parameters());
}
}).map(InstanceTemplateV4Base::getAws).peek(aws -> {
if (aws.getSpot() == null) {
aws.setSpot(new AwsInstanceTemplateV4SpotParameters());
}
}).map(AwsInstanceTemplateV4Parameters::getSpot).forEach(spot -> {
spot.setPercentage(sdxSpotParameters.getPercentage());
spot.setMaxPrice(sdxSpotParameters.getMaxPrice());
});
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class StackRequestManifester method setupInstanceVolumeEncryptionForGcp.
@VisibleForTesting
void setupInstanceVolumeEncryptionForGcp(StackV4Request stackRequest, DetailedEnvironmentResponse environmentResponse) {
String encryptionKey = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getGcp).map(GcpEnvironmentParameters::getGcpResourceEncryptionParameters).map(GcpResourceEncryptionParameters::getEncryptionKey).orElse(null);
if (encryptionKey != null) {
stackRequest.getInstanceGroups().forEach(ig -> {
GcpInstanceTemplateV4Parameters gcp = ig.getTemplate().createGcp();
GcpEncryptionV4Parameters encryption = gcp.getEncryption();
if (encryption == null) {
encryption = new GcpEncryptionV4Parameters();
gcp.setEncryption(encryption);
}
gcp.getEncryption().setType(EncryptionType.CUSTOM);
gcp.getEncryption().setKey(encryptionKey);
gcp.getEncryption().setKeyEncryptionMethod(KeyEncryptionMethod.KMS);
});
}
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class StackRequestManifester method setupInstanceVolumeEncryptionForAzure.
@VisibleForTesting
void setupInstanceVolumeEncryptionForAzure(StackV4Request stackRequest, DetailedEnvironmentResponse environmentResponse) {
Optional<String> encryptionKeyUrl = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getAzure).map(AzureEnvironmentParameters::getResourceEncryptionParameters).map(AzureResourceEncryptionParameters::getEncryptionKeyUrl);
Optional<String> diskEncryptionSetId = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getAzure).map(AzureEnvironmentParameters::getResourceEncryptionParameters).map(AzureResourceEncryptionParameters::getDiskEncryptionSetId);
stackRequest.getInstanceGroups().forEach(ig -> {
AzureInstanceTemplateV4Parameters azure = ig.getTemplate().createAzure();
AzureEncryptionV4Parameters encryption = azure.getEncryption();
if (encryption == null) {
encryption = new AzureEncryptionV4Parameters();
azure.setEncryption(encryption);
}
if (encryptionKeyUrl.isPresent() && diskEncryptionSetId.isPresent()) {
azure.getEncryption().setKey(encryptionKeyUrl.get());
azure.getEncryption().setType(EncryptionType.CUSTOM);
azure.getEncryption().setDiskEncryptionSetId(diskEncryptionSetId.get());
}
if (entitlementService.isAzureEncryptionAtHostEnabled(environmentResponse.getAccountId())) {
azure.getEncryption().setEncryptionAtHostEnabled(Boolean.TRUE);
}
});
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request in project cloudbreak by hortonworks.
the class StackRequestManifester method setupInstanceVolumeEncryptionForAws.
@VisibleForTesting
void setupInstanceVolumeEncryptionForAws(StackV4Request stackRequest, DetailedEnvironmentResponse environmentResponse) {
String encryptionKeyArn = Optional.of(environmentResponse).map(DetailedEnvironmentResponse::getAws).map(AwsEnvironmentParameters::getAwsDiskEncryptionParameters).map(AwsDiskEncryptionParameters::getEncryptionKeyArn).orElse(null);
stackRequest.getInstanceGroups().forEach(ig -> {
AwsInstanceTemplateV4Parameters aws = ig.getTemplate().createAws();
AwsEncryptionV4Parameters encryption = aws.getEncryption();
if (encryption == null) {
encryption = new AwsEncryptionV4Parameters();
aws.setEncryption(encryption);
}
if (encryption.getType() == null) {
aws.getEncryption().setType(EncryptionType.DEFAULT);
}
if (encryptionKeyArn != null) {
aws.getEncryption().setType(EncryptionType.CUSTOM);
aws.getEncryption().setKey(encryptionKeyArn);
}
});
}
Aggregations