diff options
author | Jorik Schellekens <joriks@matrix.org> | 2019-08-21 16:11:54 +0100 |
---|---|---|
committer | Jorik Schellekens <joriks@matrix.org> | 2019-08-28 15:59:54 +0100 |
commit | 22fcbbfe5e9fa82a3c0334ff3ba0c174e7fcd987 (patch) | |
tree | 9a2748296072b6d194dc8d676d1eeba5759d9582 | |
parent | How was this even remotely working? (diff) | |
download | synapse-22fcbbfe5e9fa82a3c0334ff3ba0c174e7fcd987.tar.xz |
Started templating the output
-rw-r--r-- | synapse_topology/model/__init__.py | 6 | ||||
-rw-r--r-- | synapse_topology/model/config.py | 38 |
2 files changed, 44 insertions, 0 deletions
diff --git a/synapse_topology/model/__init__.py b/synapse_topology/model/__init__.py index 7fae2caa78..f8f2353a96 100644 --- a/synapse_topology/model/__init__.py +++ b/synapse_topology/model/__init__.py @@ -18,7 +18,9 @@ import subprocess def set_config_dir(conf_dir): global config_dir + global data_dir config_dir = path.abspath(conf_dir) + data_dir = path.abspath(path.join(config_dir, "./data")) def get_config(sub_config=BASE_CONFIG): @@ -37,6 +39,10 @@ def get_config_dir(): return config_dir +def get_data_dir(): + return data_dir + + def set_config(config, sub_config=BASE_CONFIG): if sub_config == BASE_CONFIG and config_in_use(): raise BasConfigInUseError() diff --git a/synapse_topology/model/config.py b/synapse_topology/model/config.py new file mode 100644 index 0000000000..fcc5b48e41 --- /dev/null +++ b/synapse_topology/model/config.py @@ -0,0 +1,38 @@ +from synapse.config.database import DatabaseConfig +from synapse.config.server import ServerConfig +from model import get_config_dir, get_data_dir, set_config_dir + + +def create_config(conf): + server = ServerConfig().generate_config_section( + conf["server_name"], get_data_dir(), False, conf["listeners"] + ) + database = DatabaseConfig().generate_config_section(get_data_dir(), **conf) + + return "\n\n".join([server, database]) + + +set_config_dir("/exampledir/") +print( + create_config( + { + "server_name": "banterserver", + "database": "sqlcrap", + "listeners": [ + { + "port": 8448, + "resources": [{"names": ["federation"]}], + "tls": True, + "type": "http", + }, + { + "port": 443, + "resources": [{"names": ["client"]}], + "tls": False, + "type": "http", + }, + ], + } + ) +) + |