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