diff --git a/Dockerfile b/Dockerfile index 3f11de4..9c71a35 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,12 +43,10 @@ ENV TFW_PUBLIC_PORT=8888 \ TFW_LOGIN_APP_PORT=6666 \ TFW_TERMINADO_PORT=7878 \ TFW_SUPERVISOR_HTTP_PORT=9001 \ - TFW_CONTROLLER_PORT=7777 \ - TFW_CRP_LISTENER_PORT=5555 \ TFW_PUBLISHER_PORT=7654 \ TFW_RECEIVER_PORT=8765 -EXPOSE ${TFW_PUBLIC_PORT} ${TFW_CRP_LISTENER_PORT} +EXPOSE ${TFW_PUBLIC_PORT} ENV PYTHONPATH="/usr/local/lib/" \ TFW_SUPERVISOR_HTTP_URI="http://localhost:${TFW_SUPERVISOR_HTTP_PORT}" \ @@ -58,7 +56,6 @@ ENV PYTHONPATH="/usr/local/lib/" \ TFW_NGINX_DEFAULT="/etc/nginx/sites-enabled/default" \ TFW_NGINX_COMPONENTS="/etc/nginx/components" \ TFW_LIB_DIR="/usr/local/lib/" \ - TFW_CONTROLLER_DIR="/srv/controller" \ TFW_TERMINADO_DIR="/tmp/terminado_server" \ TFW_FRONTEND_DIR="/srv/frontend" \ TFW_HISTFILE="/home/${AVATAO_USER}/.bash_history" \ @@ -84,7 +81,6 @@ RUN chown -R ${AVATAO_USER} /var/log/nginx /var/lib/nginx COPY supervisor/supervisord.conf ${TFW_SUPERVISORD_CONF} COPY supervisor/components/ ${TFW_SUPERVISORD_COMPONENTS} COPY lib ${TFW_LIB_DIR} -COPY src/controller ${TFW_CONTROLLER_DIR} RUN mv /data/dist ${TFW_FRONTEND_DIR} && rm -rf /data ### TFW internals ^ ### DEMO v ############################################################### diff --git a/lib/tfw/networking/async_solvable_connector.py b/lib/tfw/networking/async_solvable_connector.py deleted file mode 100644 index be12938..0000000 --- a/lib/tfw/networking/async_solvable_connector.py +++ /dev/null @@ -1,14 +0,0 @@ -from tfw.networking.serialization import deserialize_all -from tfw.networking.solvable_connector import SolvableConnector - - -class AsyncSolvableConnector(SolvableConnector): - def __init__(self, async_zmq_context=None): - if async_zmq_context is None: - from zmq.eventloop.future import Context - async_zmq_context = Context.instance() - super(AsyncSolvableConnector, self).__init__(async_zmq_context) - - async def recv(self): - response = await self._zmq_req_socket.recv_multipart() - return deserialize_all(*response) diff --git a/lib/tfw/networking/server/tfw_server.py b/lib/tfw/networking/server/tfw_server.py index b076f9f..3596863 100644 --- a/lib/tfw/networking/server/tfw_server.py +++ b/lib/tfw/networking/server/tfw_server.py @@ -1,7 +1,6 @@ from tornado.web import Application from collections import defaultdict -from tfw.networking.server.controller_responder import ControllerResponder from tfw.networking.server.zmq_websocket_handler import ZMQWebSocketProxy from tfw.networking.event_handlers.server_connector import ServerUplinkConnector from tfw.message_sender import MessageSender @@ -20,7 +19,7 @@ class TFWServer: [(r'/ws', ZMQWebSocketProxy, {'make_response': self.make_response, 'proxy_filter': self.proxy_filter})] ) - self.controller_responder = ControllerResponder(self.fsm) + #self.controller_responder = ControllerResponder(self.fsm) TODO: add this once controller stuff is resolved @property def fsm(self): diff --git a/lib/tfw/networking/solvable_connector.py b/lib/tfw/networking/solvable_connector.py deleted file mode 100644 index 0225b39..0000000 --- a/lib/tfw/networking/solvable_connector.py +++ /dev/null @@ -1,18 +0,0 @@ -import zmq - -from tfw.config import tfwenv -from tfw.networking.zmq_connector_base import ZMQConnectorBase -from tfw.networking.serialization import serialize_all, deserialize_all - - -class SolvableConnector(ZMQConnectorBase): - def __init__(self, zmq_context=None): - super(SolvableConnector, self).__init__(zmq_context) - self._zmq_req_socket = self._zmq_context.socket(zmq.REQ) - self._zmq_req_socket.bind('tcp://*:{}'.format(tfwenv.CONTROLLER_PORT)) - - def send(self, key, message): - self._zmq_req_socket.send_multipart(serialize_all(key, message)) - - def recv(self): - return deserialize_all(*self._zmq_req_socket.recv_multipart()) diff --git a/src/controller/__init__.py b/src/controller/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/controller/app.py b/src/controller/app.py deleted file mode 100644 index b2a9118..0000000 --- a/src/controller/app.py +++ /dev/null @@ -1,38 +0,0 @@ -import secrets -from tornado.ioloop import IOLoop -from tornado.web import Application - -from tao.config import taoenv -from tfw.config import tfwenv -from handlers import SolutionCheckHandler, TestHandler -from tfw.networking.async_solvable_connector import AsyncSolvableConnector - -from tfw.config.logs import logging - -log = logging.getLogger(__name__) - - -async def setup_token(solvable_connector, token): - solvable_connector.send('token', token) - key, data = await solvable_connector.recv() - if secrets.compare_digest(token, key): - log.debug('Token setup is done.') - else: - log.error('Failed to setup token between controller and solvable.') # TODO: signaling to Avatao platform? - -if __name__ == '__main__': - kwargs = { - 'solvable_connector': AsyncSolvableConnector(), - 'token': secrets.token_hex(32) - } - IOLoop.instance().add_callback(setup_token, **kwargs) - routes = [ - (r'/{secret}/?'.format(secret=taoenv.SECRET), SolutionCheckHandler, kwargs), - (r'/{secret}/test/?'.format(secret=taoenv.SECRET), TestHandler, kwargs) - ] - app = Application( - routes - ) - app.listen(tfwenv.CRP_LISTENER_PORT) - log.debug('Controller listening on {}'.format(tfwenv.CRP_LISTENER_PORT)) - IOLoop.instance().start() diff --git a/src/controller/handlers/__init__.py b/src/controller/handlers/__init__.py deleted file mode 100644 index ac7e0ba..0000000 --- a/src/controller/handlers/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .solution_check_handler import SolutionCheckHandler -from .test_handler import TestHandler diff --git a/src/controller/handlers/solution_check_handler.py b/src/controller/handlers/solution_check_handler.py deleted file mode 100644 index e84dc80..0000000 --- a/src/controller/handlers/solution_check_handler.py +++ /dev/null @@ -1,19 +0,0 @@ -import secrets -from tornado.web import RequestHandler, HTTPError - -from tfw.config.logs import logging -log = logging.getLogger(__name__) - -class SolutionCheckHandler(RequestHandler): - def initialize(self, solvable_connector, token): - self.solvable_connector = solvable_connector - self.token = token - - async def get(self): - log.debug('Sending request to solvable') - self.solvable_connector.send('solution_check', {}) - resp_token, resp_data = await self.solvable_connector.recv() - if not secrets.compare_digest(self.token, resp_token): - raise HTTPError(500, 'Solvable didn\'t provide initial token.') - log.debug('Received answer from solvable') - self.write(resp_data) diff --git a/src/controller/handlers/test_handler.py b/src/controller/handlers/test_handler.py deleted file mode 100644 index 85c675c..0000000 --- a/src/controller/handlers/test_handler.py +++ /dev/null @@ -1,15 +0,0 @@ -import secrets -from tornado.web import RequestHandler, HTTPError - - -class TestHandler(RequestHandler): - def initialize(self, solvable_connector, token): - self.solvable_connector = solvable_connector - self.token = token - - async def get(self): - self.solvable_connector.send('test', {}) - resp_token, resp_data = await self.solvable_connector.recv() - if not secrets.compare_digest(self.token, resp_token): - raise HTTPError(500, 'Solvable didn\'t provide initial token.') - self.write(resp_data) diff --git a/supervisor/components/controller.conf b/supervisor/components/controller.conf deleted file mode 100644 index 1cdb672..0000000 --- a/supervisor/components/controller.conf +++ /dev/null @@ -1,3 +0,0 @@ -[program:controller] -directory=%(ENV_TFW_CONTROLLER_DIR)s -command=env python app.py \ No newline at end of file