use of com.sequenceiq.cloudbreak.cloud.model.VmRecommendations in project cloudbreak by hortonworks.
the class AwsPlatformParameters method initVmRecommendations.
private VmRecommendations initVmRecommendations() {
VmRecommendations result = null;
String vmRecommendation = resourceDefinition("vm-recommendation");
try {
result = JsonUtil.readValue(vmRecommendation, VmRecommendations.class);
} catch (IOException e) {
LOGGER.error("Cannot initialize Virtual machine recommendations for AWS", e);
}
return result;
}
use of com.sequenceiq.cloudbreak.cloud.model.VmRecommendations in project cloudbreak by hortonworks.
the class GcpPlatformParameters method initVmRecommendations.
private VmRecommendations initVmRecommendations() {
VmRecommendations result = null;
String vmRecommendation = resourceDefinition("vm-recommendation");
try {
result = JsonUtil.readValue(vmRecommendation, VmRecommendations.class);
} catch (IOException e) {
LOGGER.error("Cannot initialize Virtual machine recommendations for GCP", e);
}
return result;
}
use of com.sequenceiq.cloudbreak.cloud.model.VmRecommendations in project cloudbreak by hortonworks.
the class GetVirtualMachineRecommendationsHandler method accept.
@Override
public void accept(Event<GetVirtualMachineRecommendtaionRequest> gVMRRE) {
LOGGER.info("Received GetVirtualMachineRecommendtaionRequest event: {}", gVMRRE);
GetVirtualMachineRecommendtaionRequest request = gVMRRE.getData();
String cloudPlatform = request.getCloudPlatform();
try {
CloudConnector connector = cloudPlatformConnectors.getDefault(Platform.platform(cloudPlatform));
VmRecommendations recommendations = connector.parameters().recommendedVms();
GetVirtualMachineRecommendationResponse gVMRResponse = new GetVirtualMachineRecommendationResponse(request, recommendations);
request.getResult().onNext(gVMRResponse);
LOGGER.info("Query platform machine recommendations finished.");
} catch (RuntimeException e) {
LOGGER.warn("Could not get virtual machine recommendations for platform: " + cloudPlatform, e);
request.getResult().onNext(new GetVirtualMachineRecommendationResponse(e.getMessage(), e, request));
}
}
use of com.sequenceiq.cloudbreak.cloud.model.VmRecommendations 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.VmRecommendations in project cloudbreak by hortonworks.
the class AzurePlatformParameters method initVmRecommendations.
private VmRecommendations initVmRecommendations() {
VmRecommendations result = null;
String vmRecommendation = resourceDefinition("vm-recommendation");
try {
result = JsonUtil.readValue(vmRecommendation, VmRecommendations.class);
} catch (IOException e) {
LOGGER.error("Cannot initialize Virtual machine recommendations for Azure", e);
}
return result;
}
Aggregations