Search in sources :

Example 1 with VmRecommendations

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;
}
Also used : VmRecommendations(com.sequenceiq.cloudbreak.cloud.model.VmRecommendations) IOException(java.io.IOException)

Example 2 with VmRecommendations

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;
}
Also used : VmRecommendations(com.sequenceiq.cloudbreak.cloud.model.VmRecommendations) IOException(java.io.IOException)

Example 3 with VmRecommendations

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));
    }
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) GetVirtualMachineRecommendtaionRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendtaionRequest) VmRecommendations(com.sequenceiq.cloudbreak.cloud.model.VmRecommendations) GetVirtualMachineRecommendationResponse(com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendationResponse)

Example 4 with VmRecommendations

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);
}
Also used : Set(java.util.Set) Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) HashMap(java.util.HashMap) PlatformDisks(com.sequenceiq.cloudbreak.cloud.model.PlatformDisks) CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) VmRecommendations(com.sequenceiq.cloudbreak.cloud.model.VmRecommendations) DiskTypes(com.sequenceiq.cloudbreak.cloud.model.DiskTypes) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) PlatformRecommendation(com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation)

Example 5 with VmRecommendations

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;
}
Also used : VmRecommendations(com.sequenceiq.cloudbreak.cloud.model.VmRecommendations) IOException(java.io.IOException)

Aggregations

VmRecommendations (com.sequenceiq.cloudbreak.cloud.model.VmRecommendations)5 IOException (java.io.IOException)3 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 GetVirtualMachineRecommendationResponse (com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendationResponse)1 GetVirtualMachineRecommendtaionRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetVirtualMachineRecommendtaionRequest)1 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)1 DiskTypes (com.sequenceiq.cloudbreak.cloud.model.DiskTypes)1 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)1 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)1 PlatformRecommendation (com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation)1 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 HashMap (java.util.HashMap)1 Set (java.util.Set)1