diff --git a/python/topology/config.py b/python/topology/config.py index 223dc30751..3c6a9b28b2 100755 --- a/python/topology/config.py +++ b/python/topology/config.py @@ -73,6 +73,7 @@ DEFAULT_CERTIFICATE_SERVER = "go" DEFAULT_SCIOND = "go" DEFAULT_PATH_SERVER = "go" +DEFAULT_DISPATCHER = "c" GENERATE_BIND_ADDRESS = False @@ -96,6 +97,9 @@ def __init__(self, args): if self.args.sig and not self.args.docker: logging.critical("Cannot use sig without docker!") sys.exit(1) + if self.args.dispatcher != DEFAULT_DISPATCHER and self.args.docker: + logging.critical("Cannot use non-C dispatcher with docker!") + sys.exit(1) self.default_mtu = None self._read_defaults(self.args.network) self.port_gen = PortGenerator() diff --git a/python/topology/generator.py b/python/topology/generator.py index eaa23eefa2..19d2e142a4 100755 --- a/python/topology/generator.py +++ b/python/topology/generator.py @@ -32,6 +32,7 @@ DEFAULT_PATH_POLICY_FILE, DEFAULT_PATH_SERVER, DEFAULT_SCIOND, + DEFAULT_DISPATCHER, DEFAULT_TOPOLOGY_FILE, GENERATE_BIND_ADDRESS, ) @@ -62,6 +63,8 @@ def add_arguments(parser): help='SCIOND implementation to use ("go" or "py")') parser.add_argument('-ps', '--path-server', default=DEFAULT_PATH_SERVER, help='Path Server implementation to use ("go or "py")') + parser.add_argument('-disp', '--dispatcher', default=DEFAULT_DISPATCHER, + help='Dispatcher implementation to use ("go or "c")') parser.add_argument('-ds', '--discovery', action='store_true', help='Generate discovery service') parser.add_argument('--random-ifids', action='store_true', diff --git a/python/topology/supervisor.py b/python/topology/supervisor.py index e40f974425..4a930300d8 100755 --- a/python/topology/supervisor.py +++ b/python/topology/supervisor.py @@ -19,6 +19,7 @@ # Stdlib import configparser import os +import toml from io import StringIO from string import Template @@ -165,7 +166,28 @@ def _write_zlog_cfg(self, name, elem, elem_dir): def _write_dispatcher_conf(self): elem = "dispatcher" elem_dir = os.path.join(self.args.output_dir, elem) - self._write_elem_conf(elem, ["bin/dispatcher"], elem_dir) + if self.args.dispatcher == "c": + self._write_elem_conf(elem, ["bin/dispatcher"], elem_dir) + elif self.args.dispatcher == "go": + config_file_path = os.path.join(elem_dir, "dispconfig.toml") + self._write_elem_conf(elem, ["bin/godispatcher", "-config", config_file_path], elem_dir) + conf = { + 'dispatcher': { + 'ID': 'disp', + }, + 'logging': { + 'file': { + 'Path': os.path.join("logs", "dispatcher.log"), + 'Level': 'debug', + }, + 'console': { + 'Level': 'crit', + }, + }, + } + write_file(config_file_path, toml.dumps(conf)) + else: + raise ValueError("unsupported dispatcher implementation", self.args.dispatcher) def _common_entry(self, name, cmd_args, elem_dir=None): entry = {