Commit 37d8473c authored by Marco Mariani's avatar Marco Mariani

abilian: separate instance parameter for pg uri

parent 557a018c
from slapos.recipe.librecipe import GenericBaseRecipe
import json import json
import os import os
class Recipe(object): class Recipe(GenericBaseRecipe):
def __init__(self, buildout, name, options):
def install(self):
parameter_dict = { parameter_dict = {
key: value key: value
for key, value in options.items() for key, value in self.options.items()
if key not in ['json-output', 'recipe'] if key not in ['json-output', 'recipe']
} }
self._json_output = options['json-output'] with os.fdopen(os.open(self.options['json-output'], os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as fout:
with os.fdopen(os.open(self._json_output, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as fout:
fout.write(json.dumps(parameter_dict, indent=2, sort_keys=True)) fout.write(json.dumps(parameter_dict, indent=2, sort_keys=True))
fout.close()
def install(self): return [self.options['json-output']]
return [self._json_output]
update = install update = install
...@@ -171,7 +171,7 @@ class JsonDump(Recipe): ...@@ -171,7 +171,7 @@ class JsonDump(Recipe):
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
parameter_dict = self.fetch_parameter_dict(options) parameter_dict = self.fetch_parameter_dict(options)
self._json_output = options['json-output'] self._json_output = options['json-output']
with os.fdopen(os.open(self._json_output, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0600), 'w') as fout: with os.fdopen(os.open(self._json_output, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as fout:
fout.write(json.dumps(parameter_dict, indent=2, sort_keys=True)) fout.write(json.dumps(parameter_dict, indent=2, sort_keys=True))
def install(self): def install(self):
......
...@@ -23,6 +23,13 @@ def load_config(): ...@@ -23,6 +23,13 @@ def load_config():
if key in ['SECRET_KEY']: if key in ['SECRET_KEY']:
globals()[key] = str(value) globals()[key] = str(value)
# interpolate password if needed
try:
globals()['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI % {'password': SQLALCHEMY_DATABASE_PASSWORD}
except NameError:
pass
load_config() load_config()
del load_config del load_config
......
...@@ -54,7 +54,8 @@ template-pg-hba-conf = ...@@ -54,7 +54,8 @@ template-pg-hba-conf =
# TYPE DATABASE USER ADDRESS METHOD # TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only (check unix_socket_permissions!) # "local" is for Unix domain socket connections only (check unix_socket_permissions!)
local all all trust local all all trust
host all all 127.0.0.1/32 md5 #do not conflict with other postgres instances on the same node
#host all all 127.0.0.1/32 md5
{ipv4_auth} {ipv4_auth}
template-hba-ipv4 = template-hba-ipv4 =
......
...@@ -236,7 +236,7 @@ mode = 0644 ...@@ -236,7 +236,7 @@ mode = 0644
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-postgres.cfg.in url = ${:_profile_base_location_}/instance-postgres.cfg.in
output = ${buildout:directory}/instance-postgres.cfg output = ${buildout:directory}/instance-postgres.cfg
md5sum = 118f5eacb47909aa4fefbd3391cb2077 md5sum = 5fc618f929c9d34cdaca57b17864c611
mode = 0644 mode = 0644
[instance-redis] [instance-redis]
...@@ -265,7 +265,7 @@ mode = 0644 ...@@ -265,7 +265,7 @@ mode = 0644
[abilian-config] [abilian-config]
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/abilian-config.py url = ${:_profile_base_location_}/abilian-config.py
md5sum = e30bc5063632a1882ad8686147d2b0df md5sum = e89ecb0293a49ab382337bdb1f676fb0
location = ${buildout:parts-directory}/${:_buildout_section_name_} location = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = abilian-config.py filename = abilian-config.py
download-only = true download-only = true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment