Commit 0bcd4c83 authored by Daniele Venzano's avatar Daniele Venzano

Add option to mount additional volumes

parent 902a2345
...@@ -28,6 +28,14 @@ ...@@ -28,6 +28,14 @@
{% endfor %} {% endfor %}
</ul> </ul>
<p>The following persistent volumes will be available:</p>
<ul>
<li><code>/mnt/workspace</code>: User workspace (RW)</li>
{% for volume in additional_volumes %}
<li><code>/mnt/{{ volume[1] }}</code> (RO)</li>
{% endfor %}
</ul>
<h4>Start-up parameters:</h4> <h4>Start-up parameters:</h4>
<form action="{{ reverse_url("zappshop_start", "") }}{{ zapp.id }}-{{ zapp.manifest_index }}" method="post" id="zapp_start_form"> <form action="{{ reverse_url("zappshop_start", "") }}{{ zapp.id }}-{{ zapp.manifest_index }}" method="post" id="zapp_start_form">
<input type="hidden" name="zapp-id" value="{{ zapp.id }}-{{ zapp.manifest_index }}"> <input type="hidden" name="zapp-id" value="{{ zapp.id }}-{{ zapp.manifest_index }}">
...@@ -73,14 +81,6 @@ ...@@ -73,14 +81,6 @@
$("#submit").text("Start"); $("#submit").text("Start");
} }
} }
function update_range_value(value, id, bytes) {
if (bytes) {
$('#' + id).text(format_bytes_ret(value, 2));
} else {
$('#' + id).text(value);
}
}
</script> </script>
<p><a href="{{ reverse_url("zappshop") }}">Back to the ZApp shop</a></p> <p><a href="{{ reverse_url("zappshop") }}">Back to the ZApp shop</a></p>
......
...@@ -79,7 +79,6 @@ class WebSocketEndpointWeb(tornado.websocket.WebSocketHandler): ...@@ -79,7 +79,6 @@ class WebSocketEndpointWeb(tornado.websocket.WebSocketHandler):
'exec_status': execution.status 'exec_status': execution.status
} }
if execution.status == execution.RUNNING_STATUS: if execution.status == execution.RUNNING_STATUS:
response['ttl'] = ((execution.time_start + datetime.timedelta(hours=get_conf().aml_ttl)) - datetime.datetime.now()).total_seconds()
services_info_, endpoints = self.api_endpoint.execution_endpoints(self.uid, self.role, execution) services_info_, endpoints = self.api_endpoint.execution_endpoints(self.uid, self.role, execution)
response['endpoints'] = endpoints response['endpoints'] = endpoints
elif execution.status == execution.ERROR_STATUS or execution.status == execution.TERMINATED_STATUS: elif execution.status == execution.ERROR_STATUS or execution.status == execution.TERMINATED_STATUS:
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
import logging import logging
from tornado.web import MissingArgumentError
from zoe_api import zapp_shop from zoe_api import zapp_shop
from zoe_api.api_endpoint import APIEndpoint # pylint: disable=unused-import from zoe_api.api_endpoint import APIEndpoint # pylint: disable=unused-import
from zoe_api.web.utils import get_auth, catch_exceptions from zoe_api.web.utils import get_auth, catch_exceptions
...@@ -98,7 +100,8 @@ class ZAppStartWeb(ZoeRequestHandler): ...@@ -98,7 +100,8 @@ class ZAppStartWeb(ZoeRequestHandler):
'zapp': zapp, 'zapp': zapp,
'max_core_limit': get_conf().max_core_limit, 'max_core_limit': get_conf().max_core_limit,
'max_memory_limit': get_conf().max_memory_limit, 'max_memory_limit': get_conf().max_memory_limit,
'resources_are_customizable': role == "admin" or (role != "guest" and (role == "user" and not get_conf().no_user_edit_limits_web)) 'resources_are_customizable': role == "admin" or (role != "guest" and (role == "user" and not get_conf().no_user_edit_limits_web)),
'additional_volumes': get_conf().additional_volumes
} }
self.render('zapp_start.html', **template_vars) self.render('zapp_start.html', **template_vars)
...@@ -118,14 +121,14 @@ class ZAppStartWeb(ZoeRequestHandler): ...@@ -118,14 +121,14 @@ class ZAppStartWeb(ZoeRequestHandler):
app_descr = self._set_parameters(zapp.zoe_description, zapp.parameters, role) app_descr = self._set_parameters(zapp.zoe_description, zapp.parameters, role)
download_json = self.get_argument('download_json') try:
if download_json: self.get_argument('download_json')
self.set_header('Content-Type', 'application/json') self.set_header('Content-Type', 'application/json')
self.set_header('Content-Disposition', 'attachment; filename={}.json'.format(zapp_id)) self.set_header('Content-Disposition', 'attachment; filename={}.json'.format(zapp_id))
self.write(app_descr) self.write(app_descr)
self.finish() self.finish()
return return
else: except MissingArgumentError:
new_id = self.api_endpoint.execution_start(uid, role, exec_name, app_descr) new_id = self.api_endpoint.execution_start(uid, role, exec_name, app_descr)
self.redirect(self.reverse_url('execution_inspect', new_id)) self.redirect(self.reverse_url('execution_inspect', new_id))
......
...@@ -24,6 +24,8 @@ logging.getLogger('requests').setLevel(logging.WARNING) ...@@ -24,6 +24,8 @@ logging.getLogger('requests').setLevel(logging.WARNING)
logging.getLogger('urllib3').setLevel(logging.WARNING) logging.getLogger('urllib3').setLevel(logging.WARNING)
logging.getLogger('docker').setLevel(logging.INFO) logging.getLogger('docker').setLevel(logging.INFO)
log = logging.getLogger(__name__)
_CONFIG_PATHS = [ _CONFIG_PATHS = [
'zoe.conf', 'zoe.conf',
'/etc/zoe/zoe.conf' '/etc/zoe/zoe.conf'
...@@ -119,8 +121,7 @@ def load_configuration(test_conf=None): ...@@ -119,8 +121,7 @@ def load_configuration(test_conf=None):
argparser.add_argument('--max-core-limit', help='Maximum amount of cores users are able to reserve', type=int, default=16) argparser.add_argument('--max-core-limit', help='Maximum amount of cores users are able to reserve', type=int, default=16)
argparser.add_argument('--max-memory-limit', help='Maximum amount of memory services can use (in GiB)', type=int, default=64) argparser.add_argument('--max-memory-limit', help='Maximum amount of memory services can use (in GiB)', type=int, default=64)
argparser.add_argument('--no-user-edit-limits-web', action='store_true', help='Disable editing ZApp resource limits from the web interface (only admins will able to)') argparser.add_argument('--no-user-edit-limits-web', action='store_true', help='Disable editing ZApp resource limits from the web interface (only admins will able to)')
argparser.add_argument('--additional-volumes', help='Additional volumes to mount in services filesystems. (ex: /mnt/data:data,/mnt/data_n:data_n)', default='')
argparser.add_argument('--aml-ttl', help='TimeToLive in hours for AML executions', type=int, default=4)
opts = argparser.parse_args() opts = argparser.parse_args()
if opts.debug: if opts.debug:
...@@ -129,6 +130,15 @@ def load_configuration(test_conf=None): ...@@ -129,6 +130,15 @@ def load_configuration(test_conf=None):
if opts.workspace_deployment_path == '--default--': if opts.workspace_deployment_path == '--default--':
opts.workspace_deployment_path = opts.deployment_name opts.workspace_deployment_path = opts.deployment_name
if len(opts.additional_volumes) > 0:
vols = str(opts.additional_volumes).split(',')
opts.additional_volumes = [v.split(':') for v in vols]
log.info('Additional volumes:')
for path, mountpoint in opts.additional_volumes:
log.info(' - {} -> {}'.format(path, mountpoint))
else:
opts.additional_volumes = []
_CONF = opts _CONF = opts
else: else:
_CONF = test_conf _CONF = test_conf
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
from typing import Dict, List from typing import Dict, List
from zoe_lib.config import get_conf from zoe_lib.config import get_conf
from zoe_lib.state import Service, Execution, VolumeDescription from zoe_lib.state import Service, Execution, VolumeDescription, VolumeDescriptionHostPath
from zoe_master.exceptions import ZoeStartExecutionFatalException from zoe_master.exceptions import ZoeStartExecutionFatalException
from zoe_master.workspace.filesystem import ZoeFSWorkspace from zoe_master.workspace.filesystem import ZoeFSWorkspace
...@@ -57,6 +57,9 @@ def gen_volumes(service: Service, execution: Execution) -> List[VolumeDescriptio ...@@ -57,6 +57,9 @@ def gen_volumes(service: Service, execution: Execution) -> List[VolumeDescriptio
vol_list.append(wk_vol) vol_list.append(wk_vol)
for volume_path, name in get_conf().additional_volumes:
vol_list.append(VolumeDescriptionHostPath(path=volume_path, name=name, readonly=True))
return vol_list return vol_list
......
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