use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform in project cloudbreak by hortonworks.
the class DistroXEncryptedVolumeTest method verifyVolumeEncryptionKey.
private void verifyVolumeEncryptionKey(CloudPlatform cloudPlatform, String resourceName, List<String> instanceIds, CloudFunctionality cloudFunctionality, String environmentName, String resourceGroupName) {
if (CloudPlatform.AWS.equals(cloudPlatform)) {
String kmsKeyArn = awsCloudProvider.getEncryptionKeyArn(true);
List<String> volumeKmsKeyIds = new ArrayList<>(cloudFunctionality.listVolumeEncryptionKeyIds(resourceName, null, instanceIds));
if (volumeKmsKeyIds.stream().noneMatch(keyId -> keyId.equalsIgnoreCase(kmsKeyArn))) {
LOGGER.error(format("Volume has not been encrypted with '%s' KMS key!", kmsKeyArn));
throw new TestFailException(format("Volume has not been encrypted with '%s' KMS key!", kmsKeyArn));
} else {
LOGGER.info(format("Volume has been encrypted with '%s' KMS key.", kmsKeyArn));
Log.then(LOGGER, format(" Volume has been encrypted with '%s' KMS key. ", kmsKeyArn));
}
} else if (CloudPlatform.AZURE.equals(cloudPlatform)) {
String desKeyUrl = azureCloudProvider.getEncryptionKeyUrl();
List<String> volumesDesId = new ArrayList<>(cloudFunctionality.listVolumeEncryptionKeyIds(resourceName, resourceGroupName, instanceIds));
volumesDesId.forEach(desId -> {
if (desId.contains("diskEncryptionSets/" + environmentName)) {
LOGGER.info(format("Volume has been encrypted with '%s' DES key.", desId));
Log.then(LOGGER, format(" Volume has been encrypted with '%s' DES key. ", desId));
} else {
LOGGER.error(format("Volume has not been encrypted with '%s' key!", desKeyUrl));
throw new TestFailException(format("Volume has not been encrypted with '%s' key!", desKeyUrl));
}
});
} else {
LOGGER.warn(format("Disk encryption feature is not available at '%s' currently!", cloudPlatform));
}
}
use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform in project cloudbreak by hortonworks.
the class ExternalDatabaseService method getDatabaseRequest.
private AllocateDatabaseServerV4Request getDatabaseRequest(DetailedEnvironmentResponse environment, DatabaseAvailabilityType externalDatabase, Cluster cluster) {
AllocateDatabaseServerV4Request req = new AllocateDatabaseServerV4Request();
req.setEnvironmentCrn(environment.getCrn());
CloudPlatform cloudPlatform = CloudPlatform.valueOf(environment.getCloudPlatform().toUpperCase(Locale.US));
String databaseEngineVersion = Optional.ofNullable(cluster).map(Cluster::getStack).map(Stack::getExternalDatabaseEngineVersion).orElse(null);
req.setDatabaseServer(getDatabaseServerStackRequest(cloudPlatform, externalDatabase, databaseEngineVersion));
if (cluster.getStack() != null) {
req.setClusterCrn(cluster.getStack().getResourceCrn());
req.setTags(getUserDefinedTags(cluster.getStack()));
}
return req;
}
use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform in project cloudbreak by hortonworks.
the class SharedServiceValidator method checkCloudPlatform.
private void checkCloudPlatform(StackV4Request request, Long workspaceId, ValidationResultBuilder resultBuilder) {
Optional<StackView> datalakeStack = stackViewService.findByName(request.getSharedService().getDatalakeName(), workspaceId);
if (datalakeStack.isEmpty()) {
resultBuilder.error("Datalake stack with the requested name (in sharedService/sharedClusterName field) was not found.");
} else {
CloudPlatform requestedCloudPlatform = request.getCloudPlatform();
String datalakeCloudPlatform = datalakeStack.get().cloudPlatform();
if (!datalakeCloudPlatform.equals(requestedCloudPlatform.name())) {
resultBuilder.error(String.format("Requested cloud platform [%s] does not match with the datalake" + " cluser's cloud platform [%s].", requestedCloudPlatform, datalakeCloudPlatform));
}
}
}
use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform in project cloudbreak by hortonworks.
the class StackToCreateFreeIpaRequestConverter method getNetworkRequest.
private NetworkRequest getNetworkRequest(Network network) {
NetworkRequest request = null;
if (network != null) {
request = new NetworkRequest();
Optional<CloudPlatform> cloudPlatform = Optional.ofNullable(network.cloudPlatform()).or(() -> Optional.ofNullable(network.getAttributes().getValue(NetworkConstants.CLOUD_PLATFORM))).map(CloudPlatform::valueOf);
request.setNetworkCidrs(network.getNetworkCidrs());
request.setOutboundInternetTraffic(network.getOutboundInternetTraffic());
if (cloudPlatform.isPresent()) {
LOGGER.debug("Network request has cloud platform {}", cloudPlatform.get());
request.setCloudPlatform(cloudPlatform.get());
switch(cloudPlatform.get()) {
case AWS:
request.createAws().parse(network.getAttributes().getMap());
break;
case AZURE:
request.createAzure().parse(network.getAttributes().getMap());
break;
case GCP:
request.createGcp().parse(network.getAttributes().getMap());
break;
case MOCK:
request.createMock().parse(network.getAttributes().getMap());
break;
case YARN:
request.createYarn().parse(network.getAttributes().getMap());
break;
default:
break;
}
}
}
LOGGER.debug("Created network request {} from network {}", request, network);
return request;
}
use of com.sequenceiq.cloudbreak.common.mappable.CloudPlatform in project cloudbreak by hortonworks.
the class CreateFreeIpaRequestToStackConverter method getRegion.
private String getRegion(CreateFreeIpaRequest source, String cloudPlatform) {
if (source.getPlacement() == null) {
return null;
}
if (isEmpty(source.getPlacement().getRegion())) {
Map<Platform, Region> regions = Maps.newHashMap();
if (isNotEmpty(defaultRegions)) {
for (String entry : defaultRegions.split(",")) {
String[] keyValue = entry.split(":");
regions.put(platform(keyValue[0]), Region.region(keyValue[1]));
}
Region platformRegion = regions.get(platform(cloudPlatform));
if (platformRegion == null || isEmpty(platformRegion.value())) {
throw new BadRequestException(String.format("No default region specified for: %s. Region cannot be empty.", cloudPlatform));
}
return platformRegion.value();
} else {
throw new BadRequestException("No default region is specified. Region cannot be empty.");
}
}
return source.getPlacement().getRegion();
}
Aggregations