Commit e2a463a1 authored by Daniele Venzano's avatar Daniele Venzano

Add option for setting the path of the web and api http endpoints

parent ee7efa3d
......@@ -30,42 +30,42 @@ from zoe_api.rest_api.statistics import SchedulerStatsAPI
from zoe_api.rest_api.login import LoginAPI
from zoe_api.rest_api.validation import ZAppValidateAPI
import zoe_lib.config
from zoe_lib.version import ZOE_API_VERSION
API_PATH = '/api/' + ZOE_API_VERSION
def api_init(api_endpoint) -> List[tornado.web.URLSpec]:
"""Initialize the API"""
route_args = {
'api_endpoint': api_endpoint
}
api_path = zoe_lib.config.get_conf().reverse_proxy_path + '/api/' + ZOE_API_VERSION
api_routes = [
tornado.web.url(API_PATH + r'/info', InfoAPI, route_args),
tornado.web.url(API_PATH + r'/login', LoginAPI, route_args),
tornado.web.url(API_PATH + r'/zapp_validate', ZAppValidateAPI, route_args),
tornado.web.url(api_path + r'/info', InfoAPI, route_args),
tornado.web.url(api_path + r'/login', LoginAPI, route_args),
tornado.web.url(api_path + r'/zapp_validate', ZAppValidateAPI, route_args),
tornado.web.url(API_PATH + r'/user/([0-9]+)', UserAPI, route_args),
tornado.web.url(API_PATH + r'/user', UserCollectionAPI, route_args),
tornado.web.url(api_path + r'/user/([0-9]+)', UserAPI, route_args),
tornado.web.url(api_path + r'/user', UserCollectionAPI, route_args),
tornado.web.url(API_PATH + r'/role/([0-9]+)', RoleAPI, route_args),
tornado.web.url(API_PATH + r'/role', RoleCollectionAPI, route_args),
tornado.web.url(api_path + r'/role/([0-9]+)', RoleAPI, route_args),
tornado.web.url(api_path + r'/role', RoleCollectionAPI, route_args),
tornado.web.url(API_PATH + r'/quota/([0-9]+)', QuotaAPI, route_args),
tornado.web.url(API_PATH + r'/quota', QuotaCollectionAPI, route_args),
tornado.web.url(api_path + r'/quota/([0-9]+)', QuotaAPI, route_args),
tornado.web.url(api_path + r'/quota', QuotaCollectionAPI, route_args),
tornado.web.url(API_PATH + r'/execution/([0-9]+)', ExecutionAPI, route_args),
tornado.web.url(API_PATH + r'/execution/delete/([0-9]+)', ExecutionDeleteAPI, route_args),
tornado.web.url(API_PATH + r'/execution/endpoints/([0-9]+)', ExecutionEndpointsAPI, route_args),
tornado.web.url(API_PATH + r'/execution', ExecutionCollectionAPI, route_args),
tornado.web.url(api_path + r'/execution/([0-9]+)', ExecutionAPI, route_args),
tornado.web.url(api_path + r'/execution/delete/([0-9]+)', ExecutionDeleteAPI, route_args),
tornado.web.url(api_path + r'/execution/endpoints/([0-9]+)', ExecutionEndpointsAPI, route_args),
tornado.web.url(api_path + r'/execution', ExecutionCollectionAPI, route_args),
tornado.web.url(API_PATH + r'/service/([0-9]+)', ServiceAPI, route_args),
tornado.web.url(API_PATH + r'/service/logs/([0-9]+)', ServiceLogsAPI, route_args),
tornado.web.url(api_path + r'/service/([0-9]+)', ServiceAPI, route_args),
tornado.web.url(api_path + r'/service/logs/([0-9]+)', ServiceLogsAPI, route_args),
tornado.web.url(API_PATH + r'/discovery/by_group/([0-9]+)/([a-z0-9A-Z\-]+)', DiscoveryAPI, route_args),
tornado.web.url(api_path + r'/discovery/by_group/([0-9]+)/([a-z0-9A-Z\-]+)', DiscoveryAPI, route_args),
tornado.web.url(API_PATH + r'/statistics/scheduler', SchedulerStatsAPI, route_args)
tornado.web.url(api_path + r'/statistics/scheduler', SchedulerStatsAPI, route_args)
]
return api_routes
......@@ -25,6 +25,7 @@ import zoe_api.web.executions
import zoe_api.web.zapp_shop
import zoe_api.web.status
import zoe_lib.config
from zoe_lib.version import ZOE_API_VERSION, ZOE_VERSION
......@@ -34,27 +35,28 @@ def web_init(api_endpoint) -> List[tornado.web.URLSpec]:
route_args = {
'api_endpoint': api_endpoint
}
base_path = zoe_lib.config.get_conf().reverse_proxy_path
web_routes = [
tornado.web.url(r'/', zoe_api.web.start.RootWeb, route_args, name='root'),
tornado.web.url(r'/user', zoe_api.web.start.HomeWeb, route_args, name='home_user'),
tornado.web.url(r'/login', zoe_api.web.start.LoginWeb, route_args, name='login'),
tornado.web.url(r'/logout', zoe_api.web.start.LogoutWeb, route_args, name='logout'),
tornado.web.url(base_path + r'/', zoe_api.web.start.RootWeb, route_args, name='root'),
tornado.web.url(base_path + r'/user', zoe_api.web.start.HomeWeb, route_args, name='home_user'),
tornado.web.url(base_path + r'/login', zoe_api.web.start.LoginWeb, route_args, name='login'),
tornado.web.url(base_path + r'/logout', zoe_api.web.start.LogoutWeb, route_args, name='logout'),
tornado.web.url(r'/executions', zoe_api.web.executions.ExecutionListWeb, route_args, name='execution_list'),
tornado.web.url(r'/executions/([0-9]+)', zoe_api.web.executions.ExecutionListWeb, route_args, name='execution_list_page'),
tornado.web.url(r'/executions/start', zoe_api.web.executions.ExecutionStartWeb, route_args, name='execution_start'),
tornado.web.url(r'/executions/restart/([0-9]+)', zoe_api.web.executions.ExecutionRestartWeb, route_args, name='execution_restart'),
tornado.web.url(r'/executions/terminate/([0-9]+)', zoe_api.web.executions.ExecutionTerminateWeb, route_args, name='execution_terminate'),
tornado.web.url(r'/executions/inspect/([0-9]+)', zoe_api.web.executions.ExecutionInspectWeb, route_args, name='execution_inspect'),
tornado.web.url(r'/service/logs/([0-9]+)', zoe_api.web.executions.ServiceLogsWeb, route_args, name='service_logs'),
tornado.web.url(base_path + r'/executions', zoe_api.web.executions.ExecutionListWeb, route_args, name='execution_list'),
tornado.web.url(base_path + r'/executions/([0-9]+)', zoe_api.web.executions.ExecutionListWeb, route_args, name='execution_list_page'),
tornado.web.url(base_path + r'/executions/start', zoe_api.web.executions.ExecutionStartWeb, route_args, name='execution_start'),
tornado.web.url(base_path + r'/executions/restart/([0-9]+)', zoe_api.web.executions.ExecutionRestartWeb, route_args, name='execution_restart'),
tornado.web.url(base_path + r'/executions/terminate/([0-9]+)', zoe_api.web.executions.ExecutionTerminateWeb, route_args, name='execution_terminate'),
tornado.web.url(base_path + r'/executions/inspect/([0-9]+)', zoe_api.web.executions.ExecutionInspectWeb, route_args, name='execution_inspect'),
tornado.web.url(base_path + r'/service/logs/([0-9]+)', zoe_api.web.executions.ServiceLogsWeb, route_args, name='service_logs'),
tornado.web.url(r'/websocket', zoe_api.web.websockets.WebSocketEndpointWeb, route_args, name='websocket'),
tornado.web.url(base_path + r'/websocket', zoe_api.web.websockets.WebSocketEndpointWeb, route_args, name='websocket'),
tornado.web.url(r'/zapp-shop', zoe_api.web.zapp_shop.ZAppShopHomeWeb, route_args, name='zappshop'),
tornado.web.url(r'/zapp-shop/logo/([0-9a-z_\-.]+)', zoe_api.web.zapp_shop.ZAppLogoWeb, route_args, name='zappshop_logo'),
tornado.web.url(r'/zapp-shop/start/([0-9a-z_\-.]+)', zoe_api.web.zapp_shop.ZAppStartWeb, route_args, name='zappshop_start'),
tornado.web.url(base_path + r'/zapp-shop', zoe_api.web.zapp_shop.ZAppShopHomeWeb, route_args, name='zappshop'),
tornado.web.url(base_path + r'/zapp-shop/logo/([0-9a-z_\-.]+)', zoe_api.web.zapp_shop.ZAppLogoWeb, route_args, name='zappshop_logo'),
tornado.web.url(base_path + r'/zapp-shop/start/([0-9a-z_\-.]+)', zoe_api.web.zapp_shop.ZAppStartWeb, route_args, name='zappshop_start'),
tornado.web.url(r'/status', zoe_api.web.status.StatusEndpointWeb, route_args, name='status')
tornado.web.url(base_path + r'/status', zoe_api.web.status.StatusEndpointWeb, route_args, name='status')
]
return web_routes
......
......@@ -128,7 +128,7 @@ class ExecutionInspectWeb(ZoeWebRequestHandler):
}
if get_conf().enable_plots and e.time_start is not None:
grafana_url_template = 'http://cloud-platform.eurecom.fr/grafana/dashboard/db/zoe-executions?orgId=1&from={}&to={}&var-execution_id={}&refresh=1y'
grafana_url_template = 'https://cloud-platform.eurecom.fr/grafana/dashboard/db/zoe-executions?orgId=1&from={}&to={}&var-execution_id={}&refresh=1y'
if e.time_end is None:
e_time_end = int(time.time() * 1000)
else:
......
......@@ -90,6 +90,7 @@ def load_configuration(test_conf=None):
# Proxy options
argparser.add_argument('--proxy-path', help='Proxy base path', default='127.0.0.1')
argparser.add_argument('--reverse-proxy-path', help='Base path in case Zoe is behind a reverse proxy under a path', default='')
# Scheduler
argparser.add_argument('--scheduler-class', help='Scheduler class to use for scheduling ZApps', choices=['ZoeElasticScheduler'], default='ZoeElasticScheduler')
......
......@@ -127,7 +127,7 @@ class UserTable(BaseTable):
)''')
self.cursor.execute('CREATE UNIQUE INDEX users_username_uindex ON "user" (username)')
hashed_default_pw = hash_algo.hash('admin')
query = self.cursor.mogrify('INSERT INTO "user" (id, username, password, fs_uid, email, priority, enabled, auth_source, role_id, quota_id) VALUES (DEFAULT, %s, %s, 0, NULL, DEFAULT, DEFAULT, %s, 1, 1)', ('admin', hashed_default_pw, 'internal'))
query = self.cursor.mogrify('INSERT INTO "user" (id, username, password, fs_uid, email, priority, enabled, auth_source, role_id, quota_id) VALUES (DEFAULT, %s, %s, 999, NULL, DEFAULT, DEFAULT, %s, 1, 1)', ('admin', hashed_default_pw, 'internal'))
self.cursor.execute(query)
self.sql_manager.commit()
......
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