Skip to content
Snippets Groups Projects
Commit af6a3b7d authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Improved handling tunnel creation and removed the "connect" button for...

Improved handling tunnel creation and removed the "connect" button for non-http(s) interface protocol containers.
parent 53ae2ea4
Branches
No related tags found
No related merge requests found
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
...@@ -180,6 +180,10 @@ class InternalStandaloneComputingManager(StandaloneComputingManager): ...@@ -180,6 +180,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):
# Delete the Docker container # Delete the Docker container
...@@ -382,6 +386,10 @@ class SSHStandaloneComputingManager(StandaloneComputingManager, SSHComputingMana ...@@ -382,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):
...@@ -585,6 +593,9 @@ class SlurmSSHClusterComputingManager(ClusterComputingManager, SSHComputingManag ...@@ -585,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):
......
...@@ -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.container.interface_protocol == 'http' or task.container.interface_protocol == 'https' %}
{% 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.container.interface_protocol == 'http' or task.container.interface_protocol == 'https' %}
{% 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" %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment