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()));
}
}
}
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;
}
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;
}
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;
}
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));
}
}
Aggregations