Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • exact/Rosetta
1 result
Show changes
Commits on Source (2)
import os
from .models import TaskStatuses, KeyPair, Task, Storage
from .utils import os_shell, get_ssh_access_mode_credentials, sanitize_container_env_vars, booleanize
from .utils import os_shell, get_ssh_access_mode_credentials, sanitize_container_env_vars, booleanize, setup_tunnel_and_proxy
from .exceptions import ErrorMessage, ConsistencyException
from django.conf import settings
......@@ -131,8 +131,30 @@ class InternalStandaloneComputingManager(StandaloneComputingManager):
# User data volume
#run_command += ' -v {}/user-{}:/data'.format(settings.LOCAL_USER_DATA_DIR, task.user.id)
# Handle storages (binds)
binds = ''
storages = Storage.objects.filter(computing=self.computing)
for storage in storages:
if storage.type == 'generic_posix' and storage.bind_path:
# Expand the base path
expanded_base_path = storage.base_path
if '$USER' in expanded_base_path:
expanded_base_path = expanded_base_path.replace('$USER', task.user.username)
# Expand the bind_path
expanded_bind_path = storage.bind_path
if '$USER' in expanded_bind_path:
expanded_bind_path = expanded_bind_path.replace('$USER', task.user.username)
# Add the bind
if not binds:
binds = '-v{}:{}'.format(expanded_base_path, expanded_bind_path)
else:
binds += ' -v{}:{}'.format(expanded_base_path, expanded_bind_path)
# Host name, image entry command
run_command += ' -h task-{} --name task-{} -d -t {}/{}:{}'.format(task.short_uuid, task.short_uuid, task.container.registry, task.container.image_name, task.container.image_tag)
run_command += ' {} -h task-{} --name task-{} -d -t {}/{}:{}'.format(binds, task.short_uuid, task.short_uuid, task.container.registry, task.container.image_name, task.container.image_tag)
# Debug
logger.debug('Running new task with command="{}"'.format(run_command))
......@@ -157,6 +179,10 @@ class InternalStandaloneComputingManager(StandaloneComputingManager):
# Save
task.save()
# Setup the tunnel if using a custom protocol (otherwise it will get set up via the "connect" button)
if task.container.interface_protocol not in ['http', 'https']:
setup_tunnel_and_proxy(task)
def _stop_task(self, task):
......@@ -166,6 +192,10 @@ class InternalStandaloneComputingManager(StandaloneComputingManager):
out = os_shell(stop_command, capture=True)
if out.exit_code != 0:
if 'No such container' in out.stderr:
# No container was found
pass
elif 'requires at least 1 argument' in out.stderr:
# No container was found
pass
else:
raise Exception(out.stderr)
......@@ -356,6 +386,10 @@ class SSHStandaloneComputingManager(StandaloneComputingManager, SSHComputingMana
# Save
task.save()
# Setup the tunnel if using a custom protocol (otherwise it will get set up via the "connect" button)
if task.container.interface_protocol not in ['http', 'https']:
setup_tunnel_and_proxy(task)
def _stop_task(self, task, **kwargs):
......@@ -559,6 +593,9 @@ class SlurmSSHClusterComputingManager(ClusterComputingManager, SSHComputingManag
# Save
task.save()
# Setup the tunnel if using a custom protocol (otherwise it will get set up via the "connect" button)
if task.container.interface_protocol not in ['http', 'https']:
setup_tunnel_and_proxy(task)
def _stop_task(self, task, **kwargs):
......
......@@ -398,7 +398,11 @@ class Storage(models.Model):
# Include as browsable in the file manager?
browsable = models.BooleanField('Browsable in the file manager?', default=True)
def save(self, *args, **kwargs):
if self.access_mode == 'internal' and self.browsable:
raise ValueError('A storage with "internal" access mode cannot be marked as browsable since it is not yet supported by the file manager')
super(Storage, self).save(*args, **kwargs)
class Meta:
ordering = ['name']
......
......@@ -46,6 +46,12 @@
<div style="margin-top:2px">
{% if task.status == "running" %}
<b>Status:</b> <font color="green">running</font>
{% if task.interface_protocol == 'http' or task.interface_protocol == 'http' %}
{% else %}
@ port {{ task.tcp_tunnel_port }}
{% endif %}
{% else %}
<b>Status:</b> {{ task.status }}
{% endif %}
......@@ -63,12 +69,14 @@
<!-- Connect -->
{% if task.interface_port %}
{% if task.interface_protocol == 'http' or task.interface_protocol == 'http' %}
{% if task.status == "running" %}
<a href="/task_connect/?uuid={{task.uuid}}" class="btn btn-connect">Connect</a>
{% else %}
<a href="" class="btn btn-disabled">Connect</a>
{% endif %}
{% endif %}
{% endif %}
<!-- View log -->
{% if task.status == "running" %}
......