Commit 3dfcd7b2 authored by qhoangxuan's avatar qhoangxuan

fixed multi exposed ports

parent 5107e0be
......@@ -62,17 +62,18 @@ class ApacheProxy(zoe_api.proxy.base.BaseProxy):
ip, p = None, None
portList = s_info['ports']
for s in portList.values():
if s != None:
ip = s[0]
p = s[1]
base_path = '/zoe/' + uid + '/' + str(id) + '/' + srv.name
original_path = str(ip) + ':' + str(p) + base_path
for k,v in portList.items():
exposedPort = k.split('/tcp')[0]
if v != None:
ip = v[0]
p = v[1]
base_path = '/zoe/' + uid + '/' + str(id) + '/' + srv.name + '/' + exposedPort
original_path = str(ip) + ':' + str(p) + base_path
if ip is not None and p is not None:
log.info('Proxifying %s', srv.name)
self.dispatch_to_docker(base_path, original_path)
if ip is not None and p is not None:
log.info('Proxifying %s', srv.name + ' port ' + exposedPort)
self.dispatch_to_docker(base_path, original_path)
except Exception as ex:
log.error(ex)
......
......@@ -39,7 +39,7 @@
{% if s['backend_status'] == 'started' %}
{% for p in s['description']['ports'] %}
{% if s['proxy_address'] is not none %}
<li><a href="{{ p['protocol'] }}://{{ s['proxy_address'] }}">{{ p['name'] }}</a></li>
<li><a href="{{ p['protocol'] }}://{{ s['proxy_address'] }}/{{ p['port_number'] }}">{{ p['name'] }}</a></li>
{% else %}
<li><a> {{ p['name'] }} IP: {{ s['ip_address'] }}</a></li>
{% endif %}
......
......@@ -18,7 +18,7 @@
from typing import Dict
from zoe_lib.state import Service, Execution
from zoe_master.backends.proxy import gen_proxypath, JUPYTER_NOTEBOOK, MONGO_EXPRESS
from zoe_master.backends.proxy import gen_proxypath, JUPYTER_NOTEBOOK, MONGO_EXPRESS, JUPYTER_PORT, MONGO_PORT
from zoe_master.exceptions import ZoeStartExecutionFatalException
def gen_environment(execution: Execution, service: Service, env_subst_dict: Dict):
......@@ -36,8 +36,14 @@ def gen_environment(execution: Execution, service: Service, env_subst_dict: Dict
env_list.append((env_name, env_value))
#if 'jupyter' in service.image_name:
env_list.append((JUPYTER_NOTEBOOK, gen_proxypath(execution, service)))
env_list.append((JUPYTER_NOTEBOOK, gen_proxypath(execution, service) + '/' + JUPYTER_PORT))
#elif 'mongo-express' in service.image_name:
env_list.append((MONGO_EXPRESS, gen_proxypath(execution, service)))
env_list.append((MONGO_EXPRESS, gen_proxypath(execution, service) + '/' + MONGO_PORT))
env_list.append('EXECUTION_ID', str(execution.id))
env_list.append('DEPLOY_NAME', get_conf().deployment_name)
env_list.append('UID', execution.user_id)
env_list.append('SERVICE_NAME', service.name)
env_list.append('PROXY_PATH', get_conf().proxy_path)
return env_list
......@@ -23,6 +23,9 @@ from zoe_master.exceptions import ZoeStartExecutionFatalException
JUPYTER_NOTEBOOK='BASE_URL'
MONGO_EXPRESS='ME_CONFIG_SITE_BASEURL'
JUPYTER_PORT='8888'
MONGO_PORT='27017'
def gen_proxypath(execution: Execution, service: Service):
proxy_path_value = '/zoe/' + execution.user_id + '/' + str(execution.id) + '/' + service.name
return proxy_path_value
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