Search in sources :

Example 1 with PlatformParameters

use of com.sequenceiq.cloudbreak.cloud.PlatformParameters in project cloudbreak by hortonworks.

the class TemplateValidator method validateCustomInstanceType.

private void validateCustomInstanceType(Template template) {
    Map<String, Object> params = template.getAttributes().getMap();
    Platform platform = Platform.platform(template.cloudPlatform());
    PlatformParameters pps = platformParameters.get().get(platform);
    if (pps != null) {
        Boolean customInstanceType = pps.specialParameters().getSpecialParameters().get(PlatformParametersConsts.CUSTOM_INSTANCETYPE);
        if (BooleanUtils.isTrue(customInstanceType)) {
            if (params.get(PlatformParametersConsts.CUSTOM_INSTANCETYPE_CPUS) == null || params.get(PlatformParametersConsts.CUSTOM_INSTANCETYPE_MEMORY) == null) {
                throw new BadRequestException(String.format("Missing 'cpus' or 'memory' param for custom instancetype on %s platform", template.cloudPlatform()));
            }
        } else {
            throw new BadRequestException(String.format("Custom instancetype is not supported on %s platform", template.cloudPlatform()));
        }
    }
}
Also used : Platform(com.sequenceiq.cloudbreak.cloud.model.Platform) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException)

Example 2 with PlatformParameters

use of com.sequenceiq.cloudbreak.cloud.PlatformParameters in project cloudbreak by hortonworks.

the class StackDecorator method decorate.

public Stack decorate(Stack subject, StackRequest request, IdentityUser user) {
    prepareCredential(subject, request, user);
    prepareDomainIfDefined(subject, request, user);
    Long credentialId = request.getCredentialId();
    String credentialName = request.getCredentialName();
    if (credentialId != null || subject.getCredential() != null || credentialName != null) {
        subject.setCloudPlatform(subject.getCredential().cloudPlatform());
        if (subject.getInstanceGroups() == null) {
            throw new BadRequestException("Instance groups must be specified!");
        }
        PlatformParameters pps = cloudParameterCache.getPlatformParameters().get(Platform.platform(subject.cloudPlatform()));
        Boolean mandatoryNetwork = pps.specialParameters().getSpecialParameters().get(PlatformParametersConsts.NETWORK_IS_MANDATORY);
        if (BooleanUtils.isTrue(mandatoryNetwork) && request.getNetworkId() == null && subject.getNetwork() == null) {
            throw new BadRequestException("Network must be specified!");
        }
        prepareNetwork(subject, request.getNetworkId());
        prepareOrchestratorIfNotExist(subject, subject.getCredential());
        if (subject.getFailurePolicy() != null) {
            validatFailurePolicy(subject, subject.getFailurePolicy());
        }
        prepareInstanceGroups(subject, request, subject.getCredential(), user);
        prepareFlexSubscription(subject, request.getFlexId());
        validate(subject);
    }
    return subject;
}
Also used : PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException)

Example 3 with PlatformParameters

use of com.sequenceiq.cloudbreak.cloud.PlatformParameters 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 4 with PlatformParameters

use of com.sequenceiq.cloudbreak.cloud.PlatformParameters 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 5 with PlatformParameters

use of com.sequenceiq.cloudbreak.cloud.PlatformParameters in project cloudbreak by hortonworks.

the class PlatformParameterHandler method accept.

@Override
public void accept(Event<PlatformParameterRequest> platformParameterRequestEvent) {
    LOGGER.info("Received event: {}", platformParameterRequestEvent);
    PlatformParameterRequest request = platformParameterRequestEvent.getData();
    try {
        CloudConnector connector = cloudPlatformConnectors.get(request.getCloudContext().getPlatformVariant());
        PlatformParameters platformParameters = connector.parameters();
        PlatformParameterResult platformParameterResult = new PlatformParameterResult(request, platformParameters);
        request.getResult().onNext(platformParameterResult);
        LOGGER.info("Query platform parameters finished.");
    } catch (RuntimeException e) {
        request.getResult().onNext(new PlatformParameterResult(e.getMessage(), e, request));
    }
}
Also used : CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) PlatformParameterRequest(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterRequest) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) PlatformParameterResult(com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterResult)

Aggregations

PlatformParameters (com.sequenceiq.cloudbreak.cloud.PlatformParameters)6 Platform (com.sequenceiq.cloudbreak.cloud.model.Platform)4 HashMap (java.util.HashMap)3 SpecialParameters (com.sequenceiq.cloudbreak.api.model.SpecialParameters)2 SpecialParametersJson (com.sequenceiq.cloudbreak.api.model.SpecialParametersJson)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 Map (java.util.Map)2 PlatformDisksJson (com.sequenceiq.cloudbreak.api.model.PlatformDisksJson)1 PlatformOrchestratorsJson (com.sequenceiq.cloudbreak.api.model.PlatformOrchestratorsJson)1 PlatformRegionsJson (com.sequenceiq.cloudbreak.api.model.PlatformRegionsJson)1 PlatformVariantsJson (com.sequenceiq.cloudbreak.api.model.PlatformVariantsJson)1 PlatformVirtualMachinesJson (com.sequenceiq.cloudbreak.api.model.PlatformVirtualMachinesJson)1 TagSpecificationsJson (com.sequenceiq.cloudbreak.api.model.TagSpecificationsJson)1 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)1 PlatformParameterRequest (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterRequest)1 PlatformParameterResult (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParameterResult)1 PlatformParametersRequest (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParametersRequest)1 PlatformParametersResult (com.sequenceiq.cloudbreak.cloud.event.platform.PlatformParametersResult)1 PlatformDisks (com.sequenceiq.cloudbreak.cloud.model.PlatformDisks)1 PlatformOrchestrators (com.sequenceiq.cloudbreak.cloud.model.PlatformOrchestrators)1