use of com.sequenceiq.cloudbreak.cloud.openstack.view.OpenStackGroupView in project cloudbreak by hortonworks.
the class HeatTemplateBuilder method build.
public String build(ModelContext modelContext) {
try {
List<NovaInstanceView> novaInstances = new OpenStackGroupView(modelContext.stackName, modelContext.groups, modelContext.tags).getFlatNovaView();
Map<String, Object> model = new HashMap<>();
model.put("cb_stack_name", openStackUtil.adjustStackNameLength(modelContext.stackName));
model.put("agents", novaInstances);
model.put("core_user_data", formatUserData(modelContext.instanceUserData.getUserDataByType(InstanceGroupType.CORE)));
model.put("gateway_user_data", formatUserData(modelContext.instanceUserData.getUserDataByType(InstanceGroupType.GATEWAY)));
model.put("groups", modelContext.groups);
model.put("existingNetwork", modelContext.existingNetwork);
model.put("existingSubnet", modelContext.existingSubnet);
model.put("network", modelContext.neutronNetworkView);
model.putAll(defaultCostTaggingService.prepareAllTagsForTemplate());
AvailabilityZone az = modelContext.location.getAvailabilityZone();
if (az != null && az.value() != null) {
model.put("availability_zone", az.value());
}
Template template = new Template(openStackHeatTemplatePath, modelContext.templateString, freemarkerConfiguration);
String generatedTemplate = processTemplateIntoString(template, model);
LOGGER.debug("Generated Heat template: {}", generatedTemplate);
return generatedTemplate;
} catch (IOException | TemplateException e) {
throw new CloudConnectorException("Failed to process the OpenStack HeatTemplateBuilder", e);
}
}
Aggregations