use of com.sequenceiq.cloudbreak.cloud.model.DiskType in project cloudbreak by hortonworks.
the class PlatformRecommendationToPlatformRecommendationResponseConverter method convert.
@Override
public RecommendationResponse convert(PlatformRecommendation source) {
Map<String, VmTypeJson> result = new HashMap<>();
source.getRecommendations().forEach((hostGroupName, vm) -> result.put(hostGroupName, getConversionService().convert(vm, VmTypeJson.class)));
Set<VmTypeJson> vmTypes = source.getVirtualMachines().stream().map(vmType -> getConversionService().convert(vmType, VmTypeJson.class)).collect(Collectors.toSet());
Set<DiskResponse> diskResponses = new HashSet<>();
for (Entry<DiskType, DisplayName> diskTypeDisplayName : source.getDiskTypes().displayNames().entrySet()) {
for (Entry<String, VolumeParameterType> volumeParameterType : source.getDiskTypes().diskMapping().entrySet()) {
if (diskTypeDisplayName.getKey().value().equals(volumeParameterType.getKey())) {
DiskResponse diskResponse = new DiskResponse(diskTypeDisplayName.getKey().value(), volumeParameterType.getValue().name(), diskTypeDisplayName.getValue().value());
diskResponses.add(diskResponse);
}
}
}
return new RecommendationResponse(result, vmTypes, diskResponses);
}
use of com.sequenceiq.cloudbreak.cloud.model.DiskType in project cloudbreak by hortonworks.
the class TemplateValidator method validateVolumeType.
private void validateVolumeType(Template value, Platform platform) {
DiskType diskType = DiskType.diskType(value.getVolumeType());
Map<Platform, Collection<DiskType>> diskTypes = cloudParameterService.getDiskTypes().getDiskTypes();
if (diskTypes.containsKey(platform) && !diskTypes.get(platform).isEmpty()) {
if (!diskTypes.get(platform).contains(diskType)) {
throw new BadRequestException(String.format("The '%s' platform does not support '%s' volume type", platform.value(), diskType.value()));
}
}
}
use of com.sequenceiq.cloudbreak.cloud.model.DiskType in project cloudbreak by hortonworks.
the class GetDiskTypesHandler method accept.
@Override
public void accept(Event<GetDiskTypesRequest> getDiskTypesRequestEvent) {
LOGGER.info("Received event: {}", getDiskTypesRequestEvent);
GetDiskTypesRequest request = getDiskTypesRequestEvent.getData();
try {
Map<Platform, Collection<DiskType>> platformDiskTypes = Maps.newHashMap();
Map<Platform, DiskType> defaultDiskTypes = Maps.newHashMap();
Map<Platform, Map<String, VolumeParameterType>> diskMappings = Maps.newHashMap();
Map<Platform, Map<DiskType, DisplayName>> diskDisplayNames = Maps.newHashMap();
for (Entry<Platform, Collection<Variant>> connector : cloudPlatformConnectors.getPlatformVariants().getPlatformToVariants().entrySet()) {
DiskTypes diskTypes = cloudPlatformConnectors.getDefault(connector.getKey()).parameters().diskTypes();
defaultDiskTypes.put(connector.getKey(), diskTypes.defaultType());
platformDiskTypes.put(connector.getKey(), diskTypes.types());
diskMappings.put(connector.getKey(), diskTypes.diskMapping());
diskDisplayNames.put(connector.getKey(), diskTypes.displayNames());
}
GetDiskTypesResult getDiskTypesResult = new GetDiskTypesResult(request, new PlatformDisks(platformDiskTypes, defaultDiskTypes, diskMappings, diskDisplayNames));
request.getResult().onNext(getDiskTypesResult);
LOGGER.info("Query platform disk types finished.");
} catch (RuntimeException e) {
request.getResult().onNext(new GetDiskTypesResult(e.getMessage(), e, request));
}
}
Aggregations