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

Merge branch 'feature/container_protocol_support' into develop

parents b5af6d5f 1de1105b
No related branches found
No related tags found
No related merge requests found
# Generated by Django 2.2.1 on 2021-01-11 20:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core_app', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='container',
name='protocol',
field=models.CharField(blank=True, default='http', max_length=36, null=True, verbose_name='Container protocol'),
),
]
...@@ -82,6 +82,7 @@ class Container(models.Model): ...@@ -82,6 +82,7 @@ class Container(models.Model):
type = models.CharField('Container type', max_length=36, blank=False, null=False) type = models.CharField('Container type', max_length=36, blank=False, null=False)
registry = models.CharField('Container registry', max_length=255, blank=False, null=False) registry = models.CharField('Container registry', max_length=255, blank=False, null=False)
ports = models.CharField('Container ports', max_length=36, blank=True, null=True) ports = models.CharField('Container ports', max_length=36, blank=True, null=True)
protocol = models.CharField('Container protocol', max_length=36, blank=True, null=True, default='http')
# Capabilities # Capabilities
supports_dynamic_ports = models.BooleanField(default=False) supports_dynamic_ports = models.BooleanField(default=False)
......
...@@ -54,6 +54,16 @@ ...@@ -54,6 +54,16 @@
</td> </td>
</tr> </tr>
<tr>
<td><b>Protocol</b></td>
<td>
<select name="container_protocol" id="cars">
<option value="http" selected>http</option>
<option value="https">https</option>
</select>
</td>
</tr>
<tr> <tr>
<td colspan=2><b>Default port(s)</b> <td colspan=2><b>Default port(s)</b>
&nbsp; &nbsp;<input type="text" name="container_ports" value="" placeholder="" size="5" /> &nbsp; &nbsp;<input type="text" name="container_ports" value="" placeholder="" size="5" />
......
...@@ -44,6 +44,11 @@ ...@@ -44,6 +44,11 @@
<td>{{ container.registry }}</td> <td>{{ container.registry }}</td>
</tr> </tr>
<tr>
<td><b>Protocol</b></td>
<td>{{ container.protocol }}</td>
</tr>
<tr> <tr>
<td colspan=2><b>Default port(s)</b> <td colspan=2><b>Default port(s)</b>
&nbsp; &nbsp;{{ container.ports }}</td> &nbsp; &nbsp;{{ container.ports }}</td>
......
...@@ -363,7 +363,7 @@ def tasks(request): ...@@ -363,7 +363,7 @@ def tasks(request):
# Then, redirect to the task through the tunnel # Then, redirect to the task through the tunnel
tunnel_host = get_tunnel_host() tunnel_host = get_tunnel_host()
return redirect('http://{}:{}'.format(tunnel_host,task.tunnel_port)) return redirect('{}://{}:{}'.format(task.container.protocol, tunnel_host, task.tunnel_port))
except Exception as e: except Exception as e:
data['error'] = 'Error in getting the task or performing the required action' data['error'] = 'Error in getting the task or performing the required action'
...@@ -700,6 +700,9 @@ def add_container(request): ...@@ -700,6 +700,9 @@ def add_container(request):
# Container name # Container name
container_name = request.POST.get('container_name', None) container_name = request.POST.get('container_name', None)
# Container protocol
container_protocol = request.POST.get('container_protocol')
# Container service ports. TODO: support multiple ports? # Container service ports. TODO: support multiple ports?
container_ports = request.POST.get('container_ports', None) container_ports = request.POST.get('container_ports', None)
...@@ -709,8 +712,6 @@ def add_container(request): ...@@ -709,8 +712,6 @@ def add_container(request):
int(container_service_port) int(container_service_port)
except: except:
raise ErrorMessage('Invalid container port(s) in "{}"'.format(container_ports)) raise ErrorMessage('Invalid container port(s) in "{}"'.format(container_ports))
# Capabilities # Capabilities
container_supports_dynamic_ports = request.POST.get('container_supports_dynamic_ports', None) container_supports_dynamic_ports = request.POST.get('container_supports_dynamic_ports', None)
if container_supports_dynamic_ports and container_supports_dynamic_ports == 'True': if container_supports_dynamic_ports and container_supports_dynamic_ports == 'True':
...@@ -739,6 +740,7 @@ def add_container(request): ...@@ -739,6 +740,7 @@ def add_container(request):
name = container_name, name = container_name,
type = container_type, type = container_type,
registry = container_registry, registry = container_registry,
protocol = container_protocol,
ports = container_ports, ports = container_ports,
supports_dynamic_ports = container_supports_dynamic_ports, supports_dynamic_ports = container_supports_dynamic_ports,
supports_user_auth = container_supports_user_auth, supports_user_auth = container_supports_user_auth,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment