Commit 66c1b321 authored by Kento HASEGAWA's avatar Kento HASEGAWA

Make it possible to re-configure roles

parent 2fb0703d
......@@ -26,6 +26,9 @@ def load_config(path):
def set_role(role_name, config_data):
global role
if role is not None:
del role
if role_name == 'host':
role = Host(config_data)
elif role_name == 'solver':
......@@ -34,14 +37,17 @@ def set_role(role_name, config_data):
def call_api(method, cmd, params):
print(f'I: API Received: {cmd}')
if role is not None:
return role.call_api(method, cmd, params)
else:
if cmd == 'role':
if method == 'POST':
set_role(params['role'], params)
return {'role': role.type}
else:
if cmd == 'role':
if method == 'POST':
set_role(params['role'], params)
return {'role': role.type}
else:
if role is None:
return {'role': 'Undefined'}
else:
return {'role': self.type}
else:
if role is not None:
return role.call_api(method, cmd, params)
else:
return None
......@@ -16,6 +16,9 @@ class Solver(object):
self.name = config['name']
self.solver = importlib.import_module(f"solvers.{config['solver']}")
self.thread = None
def __del__(self):
self.stop_solver()
def __repr__(self):
return "Solver"
......
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