use of org.apache.whirr.InstanceTemplate in project whirr by apache.
the class BootstrapTemplate method build.
public static Template build(final ClusterSpec clusterSpec, ComputeService computeService, StatementBuilder statementBuilder, InstanceTemplate instanceTemplate) {
String name = "bootstrap-" + Joiner.on('_').join(instanceTemplate.getRoles());
LOG.info("Configuring template for {}", name);
statementBuilder.name(name);
ensureUserExistsAndAuthorizeSudo(statementBuilder, clusterSpec.getClusterUser(), clusterSpec.getPublicKey(), clusterSpec.getPrivateKey());
Statement bootstrap = statementBuilder.build(clusterSpec);
if (LOG.isDebugEnabled()) {
LOG.debug("Running script {}:\n{}", name, bootstrap.render(OsFamily.UNIX));
}
TemplateBuilder templateBuilder = computeService.templateBuilder().from(instanceTemplate.getTemplate() != null ? instanceTemplate.getTemplate() : clusterSpec.getTemplate());
Template template = templateBuilder.build();
template.getOptions().runScript(bootstrap);
return setSpotInstancePriceIfSpecified(computeService.getContext(), clusterSpec, template, instanceTemplate);
}
Aggregations