Search in sources :

Example 1 with DiskTypes

use of com.sequenceiq.cloudbreak.cloud.model.DiskTypes in project cloudbreak by hortonworks.

the class PlatformParametersTest method getRegionByNameIfValueNotConfigured.

@Test
public void getRegionByNameIfValueNotConfigured() {
    DiskTypes diskTypes = underTest.diskTypes();
    Assert.assertEquals(1, diskTypes.displayNames().entrySet().size());
    Assert.assertEquals(1, diskTypes.diskMapping().entrySet().size());
    Assert.assertEquals("testDiskType", diskTypes.defaultType().value());
}
Also used : DiskTypes(com.sequenceiq.cloudbreak.cloud.model.DiskTypes) Test(org.junit.Test)

Example 2 with DiskTypes

use of com.sequenceiq.cloudbreak.cloud.model.DiskTypes 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 3 with DiskTypes

use of com.sequenceiq.cloudbreak.cloud.model.DiskTypes 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));
    }
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) PlatformDisks(com.sequenceiq.cloudbreak.cloud.model.PlatformDisks) DiskType(com.sequenceiq.cloudbreak.cloud.model.DiskType) GetDiskTypesRequest(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesRequest) GetDiskTypesResult(com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesResult) DiskTypes(com.sequenceiq.cloudbreak.cloud.model.DiskTypes) Collection(java.util.Collection) Map(java.util.Map)

Aggregations

DiskTypes (com.sequenceiq.cloudbreak.cloud.model.DiskTypes)3 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)2 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)2 GetDiskTypesRequest (com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesRequest)1 GetDiskTypesResult (com.sequenceiq.cloudbreak.cloud.event.platform.GetDiskTypesResult)1 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)1 DiskType (com.sequenceiq.cloudbreak.cloud.model.DiskType)1 PlatformRecommendation (com.sequenceiq.cloudbreak.cloud.model.PlatformRecommendation)1 VmRecommendations (com.sequenceiq.cloudbreak.cloud.model.VmRecommendations)1 VmType (com.sequenceiq.cloudbreak.cloud.model.VmType)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 Test (org.junit.Test)1