diff options
author | Jorik Schellekens <joriks@matrix.org> | 2019-08-23 10:47:23 +0100 |
---|---|---|
committer | Jorik Schellekens <joriks@matrix.org> | 2019-08-28 15:59:54 +0100 |
commit | b78ae32b4ece0d690ad5cd471d742735533fc9f6 (patch) | |
tree | e5708e0397ee8fdbe21752a5ee403129ff920dd0 | |
parent | Remove unused api endpoints. (diff) | |
download | synapse-b78ae32b4ece0d690ad5cd471d742735533fc9f6.tar.xz |
Fix config generation
-rw-r--r-- | synapse_topology/model/__init__.py | 5 | ||||
-rw-r--r-- | synapse_topology/model/config.py | 42 | ||||
-rw-r--r-- | synapse_topology/server/schemas.py | 2 |
3 files changed, 11 insertions, 38 deletions
diff --git a/synapse_topology/model/__init__.py b/synapse_topology/model/__init__.py index 67b5bea97a..c0dfde83ce 100644 --- a/synapse_topology/model/__init__.py +++ b/synapse_topology/model/__init__.py @@ -47,8 +47,8 @@ def set_config(config): if config_in_use(): raise BasConfigInUseError() - for conf_name, conf in create_config(config).items(): - with open(abspath(join(get_config_dir, conf_name)), "w") as f: + for conf_name, conf in create_config(config_dir, data_dir, config).items(): + with open(abspath(join(get_config_dir(), conf_name)), "w") as f: f.write(conf) @@ -69,7 +69,6 @@ def generate_base_config(server_name, report_stats): if config_in_use(): raise BasConfigInUseError() - print(config_dir) conf = HomeServerConfig().generate_config( config_dir, join(config_dir, DATA_SUBDIR), diff --git a/synapse_topology/model/config.py b/synapse_topology/model/config.py index 169250a9ab..99db6584a3 100644 --- a/synapse_topology/model/config.py +++ b/synapse_topology/model/config.py @@ -3,15 +3,14 @@ from synapse.config.server import ServerConfig from synapse.config.tls import TlsConfig from synapse.config.logger import LoggingConfig from synapse.config.homeserver import HomeServerConfig -from model import get_config_dir, get_data_dir, set_config_dir -def create_config(conf): +def create_config(config_dir_path, data_dir_path, conf): server_name = conf["server_name"] del conf["server_name"] - config_dir_path = get_config_dir() - data_dir_path = get_data_dir() + server_config_in_use = conf["server_config_in_use"] + del conf["server_config_in_use"] base_configs = [ServerConfig, DatabaseConfig, TlsConfig] @@ -37,34 +36,9 @@ def create_config(conf): rest_of_config = Configs().generate_config(**config_args) - return {"homeserver.yaml": base_config, "the_rest.yaml": rest_of_config} - - -set_config_dir("/exampledir/") -confs = 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", - }, - ], - "tls_certificate_path": "asdfasfdasdfadf", - "tls_private_key_path": "asdfasfdha;kdfjhafd", - "acme_domain": "asdfaklhsadfkj", - "report_stats": True, + return { + "homeserver.yaml": base_config + + "\n\nserver_config_in_use: {}".format(server_config_in_use), + "the_rest.yaml": rest_of_config, } -) -for conf_name, conf in confs.items(): - with open(conf_name, "w") as f: - f.write(conf) + diff --git a/synapse_topology/server/schemas.py b/synapse_topology/server/schemas.py index 898883f14d..90cc7a0969 100644 --- a/synapse_topology/server/schemas.py +++ b/synapse_topology/server/schemas.py @@ -18,7 +18,7 @@ BASE_CONFIG_SCHEMA = { "pid_file": {"type": "string", "minlength": 1}, "listeners": {"type": "array"}, "acme": {"type": "object"}, - "database": {"type": "object"}, + "database": {"type": "string", "minlength": 1}, "tls_certificate_path": {"type": "string", "minlength": 1}, "tls_private_key_path": {"type": "string", "minlength": 1}, "server_config_in_use": {"type": "boolean"}, |