use of com.sequenceiq.cloudbreak.cloud.model.PlatformDisks in project cloudbreak by hortonworks.
the class CloudResourceAdvisor method createForBlueprint.
public PlatformRecommendation createForBlueprint(String blueprintName, Long blueprintId, PlatformResourceRequest resourceRequest, IdentityUser cbUser) {
String cloudPlatform = resourceRequest.getCloudPlatform();
String region = resourceRequest.getRegion();
String availabilityZone = resourceRequest.getAvailabilityZone();
Map<String, VmType> vmTypesByHostGroup = new HashMap<>();
Map<String, Boolean> hostGroupContainsMasterComp = new HashMap<>();
LOGGER.info("Advising resources for blueprintId: {}, blueprintName: {}, provider: {} and region: {}.", blueprintId, blueprintName, cloudPlatform, region);
String blueprintText = getBlueprint(blueprintName, blueprintId, cbUser).getBlueprintText();
Map<String, Set<String>> componentsByHostGroup = blueprintProcessorFactory.get(blueprintText).getComponentsByHostGroup();
componentsByHostGroup.forEach((hGName, components) -> hostGroupContainsMasterComp.put(hGName, isThereMasterComponents(components)));
CloudVmTypes vmTypes = cloudParameterService.getVmTypesV2(resourceRequest.getCredential(), resourceRequest.getRegion(), resourceRequest.getPlatformVariant(), resourceRequest.getFilters());
VmType defaultVmType = getDefaultVmType(availabilityZone, vmTypes);
if (defaultVmType != null) {
componentsByHostGroup.keySet().forEach(comp -> vmTypesByHostGroup.put(comp, defaultVmType));
}
VmRecommendations recommendations = cloudParameterService.getRecommendation(cloudPlatform);
Set<VmType> availableVmTypes = vmTypes.getCloudVmResponses().get(availabilityZone);
if (availableVmTypes == null) {
availableVmTypes = Collections.emptySet();
}
if (recommendations != null) {
Map<String, VmType> masterVmTypes = getVmTypesForComponentType(true, recommendations.getMaster(), hostGroupContainsMasterComp, availableVmTypes);
vmTypesByHostGroup.putAll(masterVmTypes);
Map<String, VmType> workerVmTypes = getVmTypesForComponentType(false, recommendations.getWorker(), hostGroupContainsMasterComp, availableVmTypes);
vmTypesByHostGroup.putAll(workerVmTypes);
}
PlatformDisks platformDisks = cloudParameterService.getDiskTypes();
Platform platform = platform(cloudPlatform);
DiskTypes diskTypes = new DiskTypes(platformDisks.getDiskTypes().get(platform), platformDisks.getDefaultDisks().get(platform), platformDisks.getDiskMappings().get(platform), platformDisks.getDiskDisplayNames().get(platform));
return new PlatformRecommendation(vmTypesByHostGroup, availableVmTypes, diskTypes);
}
use of com.sequenceiq.cloudbreak.cloud.model.PlatformDisks 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