Search in sources :

Example 6 with Platform

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

the class AbstractResourceConnector method launch.

@Override
public List<CloudResourceStatus> launch(AuthenticatedContext auth, CloudStack stack, PersistenceNotifier notifier, AdjustmentType adjustmentType, Long threshold) throws Exception {
    CloudContext cloudContext = auth.getCloudContext();
    Platform platform = cloudContext.getPlatform();
    // context
    ResourceBuilderContext context = contextBuilders.get(platform).contextInit(cloudContext, auth, stack.getNetwork(), null, true);
    // network
    List<CloudResourceStatus> cloudResourceStatuses = networkResourceService.buildResources(context, auth, stack.getNetwork(), stack.getCloudSecurity());
    context.addNetworkResources(getCloudResources(cloudResourceStatuses));
    // group
    List<CloudResourceStatus> groupStatuses = groupResourceService.buildResources(context, auth, stack.getGroups(), stack.getNetwork(), stack.getCloudSecurity());
    cloudResourceStatuses.addAll(groupStatuses);
    // compute
    List<CloudResourceStatus> computeStatuses = computeResourceService.buildResourcesForLaunch(context, auth, stack.getGroups(), stack.getImage(), stack.getTags(), adjustmentType, threshold);
    cloudResourceStatuses.addAll(computeStatuses);
    return cloudResourceStatuses;
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) CloudContext(com.sequenceiq.cloudbreak.cloud.context.CloudContext) ResourceBuilderContext(com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext)

Example 7 with Platform

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

the class TemplateDecorator method decorate.

public Template decorate(Credential credential, Template subject, String region, String availabilityZone, String variant) {
    PlatformDisks platformDisks = cloudParameterService.getDiskTypes();
    CloudVmTypes vmTypesV2 = cloudParameterService.getVmTypesV2(credential, region, variant, new HashMap<>());
    String locationString = locationService.location(region, availabilityZone);
    VolumeParameterConfig config;
    try {
        Platform platform = Platform.platform(subject.cloudPlatform());
        VmType vmType = vmTypesV2.getCloudVmResponses().getOrDefault(locationString, Collections.emptySet()).stream().filter(curr -> curr.value().equals(subject.getInstanceType())).findFirst().get();
        Map<String, VolumeParameterType> map = platformDisks.getDiskMappings().get(platform);
        VolumeParameterType volumeParameterType = map.get(subject.getVolumeType());
        config = vmType.getVolumeParameterbyVolumeParameterType(volumeParameterType);
    } catch (NoSuchElementException ignored) {
        LOGGER.info("No VolumeParameterConfig found, which might be normal for platforms like OpenStack");
        config = VolumeParameterConfig.EMPTY;
    }
    if (config.volumeParameterType() != null) {
        if (subject.getVolumeCount() == null) {
            subject.setVolumeCount(config.maximumNumber());
        }
        if (subject.getVolumeSize() == null) {
            subject.setVolumeSize(config.maximumSize());
        }
    }
    return subject;
}
Also used : CloudVmTypes(com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes) Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) VmType(com.sequenceiq.cloudbreak.cloud.model.VmType) VolumeParameterType(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterType) PlatformDisks(com.sequenceiq.cloudbreak.cloud.model.PlatformDisks) VolumeParameterConfig(com.sequenceiq.cloudbreak.cloud.model.VolumeParameterConfig) NoSuchElementException(java.util.NoSuchElementException)

Example 8 with Platform

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

the class PlatformParameterV1Controller method getPlatforms.

@Override
public Map<String, Object> getPlatforms(Boolean extended) {
    PlatformVariants pv = cloudParameterService.getPlatformVariants();
    PlatformDisks diskTypes = cloudParameterService.getDiskTypes();
    PlatformRegions regions = cloudParameterService.getRegions();
    PlatformVirtualMachines vmtypes = new PlatformVirtualMachines();
    PlatformOrchestrators orchestrators = cloudParameterService.getOrchestrators();
    Map<Platform, PlatformParameters> platformParameters = cloudParameterService.getPlatformParameters();
    SpecialParameters specialParameters = cloudParameterService.getSpecialParameters();
    Map<String, Object> map = new HashMap<>();
    map.put("variants", conversionService.convert(pv, PlatformVariantsJson.class));
    map.put("disks", conversionService.convert(diskTypes, PlatformDisksJson.class));
    map.put("regions", conversionService.convert(regions, PlatformRegionsJson.class));
    map.put("virtualMachines", conversionService.convert(vmtypes, PlatformVirtualMachinesJson.class));
    map.put("orchestrators", conversionService.convert(orchestrators, PlatformOrchestratorsJson.class));
    map.put("tagspecifications", conversionService.convert(platformParameters, TagSpecificationsJson.class));
    Map<String, Boolean> globalParameters = conversionService.convert(specialParameters, Map.class);
    Map<String, Map<String, Boolean>> platformSpecificParameters = conversionService.convert(platformParameters, Map.class);
    SpecialParametersJson specialParametersJson = new SpecialParametersJson();
    specialParametersJson.setSpecialParameters(globalParameters);
    specialParametersJson.setPlatformSpecificSpecialParameters(platformSpecificParameters);
    map.put("specialParameters", specialParametersJson);
    return map;
}
Also used : PlatformRegions(com.sequenceiq.cloudbreak.cloud.model.PlatformRegions) Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) HashMap(java.util.HashMap) PlatformRegionsJson(com.sequenceiq.cloudbreak.api.model.PlatformRegionsJson) PlatformDisks(com.sequenceiq.cloudbreak.cloud.model.PlatformDisks) PlatformVirtualMachines(com.sequenceiq.cloudbreak.cloud.model.PlatformVirtualMachines) PlatformVariantsJson(com.sequenceiq.cloudbreak.api.model.PlatformVariantsJson) SpecialParametersJson(com.sequenceiq.cloudbreak.api.model.SpecialParametersJson) SpecialParameters(com.sequenceiq.cloudbreak.api.model.SpecialParameters) PlatformOrchestratorsJson(com.sequenceiq.cloudbreak.api.model.PlatformOrchestratorsJson) TagSpecificationsJson(com.sequenceiq.cloudbreak.api.model.TagSpecificationsJson) PlatformDisksJson(com.sequenceiq.cloudbreak.api.model.PlatformDisksJson) PlatformVariants(com.sequenceiq.cloudbreak.cloud.model.PlatformVariants) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) PlatformOrchestrators(com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrators) PlatformVirtualMachinesJson(com.sequenceiq.cloudbreak.api.model.PlatformVirtualMachinesJson) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with Platform

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

the class PlatformParameterV1Controller method getSpecialProperties.

@Override
public SpecialParametersJson getSpecialProperties() {
    SpecialParameters specialParameters = cloudParameterService.getSpecialParameters();
    Map<Platform, PlatformParameters> platformParameters = cloudParameterService.getPlatformParameters();
    Map<String, Boolean> globalParameters = conversionService.convert(specialParameters, Map.class);
    Map<String, Map<String, Boolean>> platformSpecificParameters = conversionService.convert(platformParameters, Map.class);
    SpecialParametersJson specialParametersJson = new SpecialParametersJson();
    specialParametersJson.setSpecialParameters(globalParameters);
    specialParametersJson.setPlatformSpecificSpecialParameters(platformSpecificParameters);
    return specialParametersJson;
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) HashMap(java.util.HashMap) Map(java.util.Map) SpecialParametersJson(com.sequenceiq.cloudbreak.api.model.SpecialParametersJson) SpecialParameters(com.sequenceiq.cloudbreak.api.model.SpecialParameters)

Example 10 with Platform

use of com.sequenceiq.cloudbreak.cloud.model.Platform 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()));
        }
    }
}
Also used : DiskType(com.sequenceiq.cloudbreak.cloud.model.DiskType) Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) Collection(java.util.Collection) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException)

Aggregations

Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)26 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)7 ResourceBuilderContext (com.sequenceiq.cloudbreak.cloud.template.context.ResourceBuilderContext)7 Map (java.util.Map)7 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)6 HashMap (java.util.HashMap)6 CloudVmTypes (com.sequenceiq.cloudbreak.cloud.model.CloudVmTypes)5 Collection (java.util.Collection)5 PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)4 CloudResourceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus)4 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)4 Set (java.util.Set)4 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)3 Maps.newHashMap (com.google.common.collect.Maps.newHashMap)2 SpecialParameters (com.sequenceiq.cloudbreak.api.model.SpecialParameters)2 SpecialParametersJson (com.sequenceiq.cloudbreak.api.model.SpecialParametersJson)2 DiskType (com.sequenceiq.cloudbreak.cloud.model.DiskType)2 DiskTypes (com.sequenceiq.cloudbreak.cloud.model.DiskTypes)2 PlatformOrchestrators (com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrators)2 Region (com.sequenceiq.cloudbreak.cloud.model.Region)2