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
Select Git revision
  • develop
  • feature/arch_support
  • feature/global_refactoring
  • master
  • v1.0.0
5 results

Target

Select target project
  • exact/Rosetta
1 result
Select Git revision
  • develop
  • feature/arch_support
  • feature/global_refactoring
  • master
  • v1.0.0
5 results
Show changes
Commits on Source (2)
import os import os
from .models import TaskStatuses, KeyPair, Task, Storage 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 .exceptions import ErrorMessage, ConsistencyException
from django.conf import settings from django.conf import settings
...@@ -131,8 +131,30 @@ class InternalStandaloneComputingManager(StandaloneComputingManager): ...@@ -131,8 +131,30 @@ class InternalStandaloneComputingManager(StandaloneComputingManager):
# User data volume # User data volume
#run_command += ' -v {}/user-{}:/data'.format(settings.LOCAL_USER_DATA_DIR, task.user.id) #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 # 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 # Debug
logger.debug('Running new task with command="{}"'.format(run_command)) logger.debug('Running new task with command="{}"'.format(run_command))
...@@ -157,6 +179,10 @@ class InternalStandaloneComputingManager(StandaloneComputingManager): ...@@ -157,6 +179,10 @@ class InternalStandaloneComputingManager(StandaloneComputingManager):
# Save # Save
task.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): def _stop_task(self, task):
...@@ -166,6 +192,10 @@ class InternalStandaloneComputingManager(StandaloneComputingManager): ...@@ -166,6 +192,10 @@ class InternalStandaloneComputingManager(StandaloneComputingManager):
out = os_shell(stop_command, capture=True) out = os_shell(stop_command, capture=True)
if out.exit_code != 0: if out.exit_code != 0:
if 'No such container' in out.stderr: 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 pass
else: else:
raise Exception(out.stderr) raise Exception(out.stderr)
...@@ -356,6 +386,10 @@ class SSHStandaloneComputingManager(StandaloneComputingManager, SSHComputingMana ...@@ -356,6 +386,10 @@ class SSHStandaloneComputingManager(StandaloneComputingManager, SSHComputingMana
# Save # Save
task.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): def _stop_task(self, task, **kwargs):
...@@ -559,6 +593,9 @@ class SlurmSSHClusterComputingManager(ClusterComputingManager, SSHComputingManag ...@@ -559,6 +593,9 @@ class SlurmSSHClusterComputingManager(ClusterComputingManager, SSHComputingManag
# Save # Save
task.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): def _stop_task(self, task, **kwargs):
......
...@@ -398,7 +398,11 @@ class Storage(models.Model): ...@@ -398,7 +398,11 @@ class Storage(models.Model):
# Include as browsable in the file manager? # Include as browsable in the file manager?
browsable = models.BooleanField('Browsable in the file manager?', default=True) 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: class Meta:
ordering = ['name'] ordering = ['name']
......
...@@ -46,6 +46,12 @@ ...@@ -46,6 +46,12 @@
<div style="margin-top:2px"> <div style="margin-top:2px">
{% if task.status == "running" %} {% if task.status == "running" %}
<b>Status:</b> <font color="green">running</font> <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 %} {% else %}
<b>Status:</b> {{ task.status }} <b>Status:</b> {{ task.status }}
{% endif %} {% endif %}
...@@ -63,12 +69,14 @@ ...@@ -63,12 +69,14 @@
<!-- Connect --> <!-- Connect -->
{% if task.interface_port %} {% if task.interface_port %}
{% if task.interface_protocol == 'http' or task.interface_protocol == 'http' %}
{% if task.status == "running" %} {% if task.status == "running" %}
<a href="/task_connect/?uuid={{task.uuid}}" class="btn btn-connect">Connect</a> <a href="/task_connect/?uuid={{task.uuid}}" class="btn btn-connect">Connect</a>
{% else %} {% else %}
<a href="" class="btn btn-disabled">Connect</a> <a href="" class="btn btn-disabled">Connect</a>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %}
<!-- View log --> <!-- View log -->
{% if task.status == "running" %} {% if task.status == "running" %}
......