@Override
protected void addChildren() throws OpsException {
PostgresqlTemplateVariables template = injected(PostgresqlTemplateVariables.class);
InstanceBuilder instance = InstanceBuilder.build(model.dnsName, this, model.getTags());
// TODO: Memory _really_ needs to be configurable here!
instance.publicPorts.add(5432);
instance.minimumMemoryMb = 2048;
addChild(instance);
instance.addChild(PackageDependency.build("postgresql"));
instance.addChild(PackageDependency.build("postgresql-client"));
String postgresVersion = template.getPostgresVersion();
if (postgresVersion.equals("8.4")) {
instance.addChild(TemplatedFile.build(template, new File("/etc/postgresql/8.4/main/pg_hba.conf"),
"8_4_pg_hba.conf"));
instance.addChild(TemplatedFile.build(template, new File("/etc/postgresql/8.4/main/postgresql.conf"),
"8_4_postgresql.conf"));
} else if (postgresVersion.equals("9.1")) {
instance.addChild(TemplatedFile.build(template, new File("/etc/postgresql/9.1/main/pg_hba.conf"),
"9_1_pg_hba.conf"));
instance.addChild(TemplatedFile.build(template, new File("/etc/postgresql/9.1/main/postgresql.conf"),
"9_1_postgresql.conf"));
} else {
throw new OpsException("Unsupported postgres version: " + postgresVersion);
}
instance.addChild(PostgresqlServerBootstrap.build());
instance.addChild(MetricsInstance.class);
{
PublicEndpoint endpoint = injected(PublicEndpoint.class);
// endpoint.network = null;
endpoint.publicPort = 5432;
endpoint.backendPort = 5432;
endpoint.dnsName = model.dnsName;
endpoint.tagItem = model.getKey();
endpoint.parentItem = model.getKey();
instance.addChild(endpoint);
}
instance.addChild(ManagedService.build("postgresql"));
instance.addChild(injected(PostgresqlServerBackup.class));
}