Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go dispatcher support for supervisord topo gen #2303

Merged
merged 2 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/topology/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
DEFAULT_CERTIFICATE_SERVER = "go"
DEFAULT_SCIOND = "go"
DEFAULT_PATH_SERVER = "go"
DEFAULT_DISPATCHER = "c"

GENERATE_BIND_ADDRESS = False

Expand All @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions python/topology/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
DEFAULT_PATH_POLICY_FILE,
DEFAULT_PATH_SERVER,
DEFAULT_SCIOND,
DEFAULT_DISPATCHER,
DEFAULT_TOPOLOGY_FILE,
GENERATE_BIND_ADDRESS,
)
Expand Down Expand Up @@ -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',
Expand Down
24 changes: 23 additions & 1 deletion python/topology/supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Stdlib
import configparser
import os
import toml
from io import StringIO
from string import Template

Expand Down Expand Up @@ -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 = {
Expand Down