Commit 9a58a90e by Bence Dányi

webui: show ipv4/6 addresses

parent 23e46445
......@@ -146,20 +146,51 @@
<table>
<tr>
<th>{% trans "Protocol" %}</th>
<th>{% trans "Public port" %}</th>
{% if i.template.network.nat %}<th colspan="2">{% trans "Private port" %}</th>{%endif%}
<th colspan="2">{% trans "Access" %}</th>
</tr>
{% for port in ports %}
<tr>
<td>{{port.proto}}</td>
<td>{{port.public}}</td>
{% if i.template.network.nat %}<td>{{port.private}}</td>{%endif%}
<td>{{port.private}}/{{port.proto}}</td>
<td style="white-space: nowrap;">
{% if port.private == 80 or port.private == 8080 or port.private == 8000 %}
<a href="http://{{port.ipv4.host}}:{{port.ipv4.port}}">
{{port.ipv4.host}}:{{port.ipv4.port}}
</a>
{% elif port.private == 443 %}
<a href="https://{{port.ipv4.host}}:{{port.ipv4.port}}">{{port.ipv4.host}}:{{port.ipv4.port}}</a>
{% else %}
{{port.ipv4.host}}:{{port.ipv4.port}}
{% endif %}
</td>
<td>
<a href="{% url one.views.vm_port_del i.id port.proto port.public %}">{% trans "Delete" %}</a>
</td>
</tr>
<tr>
<td>{{port.private}}/{{port.proto}}6</td>
<td style="white-space: nowrap;">
{% if port.private == 80 or port.private == 8080 or port.private == 8000 %}
<a href="http://{{port.ipv6.host}}:{{port.ipv6.port}}">
{{port.ipv6.host}}:{{port.ipv6.port}}
</a>
{% elif port.private == 443 %}
<a href="https://{{port.ipv6.host}}:{{port.ipv6.port}}">
{{port.ipv6.host}}:{{port.ipv6.port}}
</a>
{% else %}
{{port.ipv6.host}}:{{port.ipv6.port}}
{% endif %}
</td>
<td>
<a href="{% url one.views.vm_port_del i.id port.proto port.public %}">{% trans "Delete" %}</a>
</td>
</tr>
{% endfor %}
<tr>
<th>Protokoll</th>
<th colspan="2">Port</th>
</tr>
<tr>
<td>
<select style="min-width:50px;" name=proto>
<option value="tcp">tcp</option>
......@@ -169,11 +200,6 @@
<td>
<input style="min-width:70px;width:70px;" type="text" name="public"/>
</td>
{% if i.template.network.nat %}
<td>
<input style="min-width:70px;width:70px;" type="text" name="private"/>
</td>
{% endif %}
<td>
<input type="submit" style="min-width:3em" value="{% trans "Add" %}" />
</td>
......
......@@ -37,13 +37,23 @@
</td>
</tr>
<tr>
<th>{% trans "Host" %}{% if i.is_ipv6 %} (<a href="#" class="host-toggle"><span class="v4">IPv4</span><span class="v6">IPv6</span></a>){% endif %}:</th>
<td><span class="host">{{ i.hostname }}</span><span class="ipv4host">{{i.hostname_v4}}</span></td>
<th>{% trans "IPv4 Host" %}{% if i.is_ipv6 %} ({% trans "You are using IPv6" %}){% endif %}:</th>
<td>{{ i.hostname_v4 }}</td>
</tr>
{% if i.nat %}<tr>
<th>{% trans "Port" %}:</th>
<td>{{ i.port}}</td>
</tr>{% endif %}
<tr>
<th>{% trans "IPv6 Host" %}{% if not i.is_ipv6 %} ({% trans "You are using IPv4" %}){% endif %}:</th>
<td>{{ i.hostname_v6 }}</td>
</tr>
{% if i.nat %}
<tr>
<th>{% trans "IPv4 Port" %}:</th>
<td>{{ i.port_v4 }}</td>
</tr>
<tr>
<th>{% trans "IPv6 Port" %}:</th>
<td>{{ i.port_v6 }}</td>
</tr>
{% endif %}
<tr>
<th>{% trans "Username" %}:</th>
<td>cloud</td>
......
......@@ -105,11 +105,12 @@ def vm_credentials(request, iid):
try:
vm = get_object_or_404(Instance, pk=iid, owner=request.user)
is_ipv6 = len(request.META["REMOTE_ADDR"].split('.')) == 1
vm.hostname = vm.get_connect_host(use_ipv6=is_ipv6)
vm.is_ipv6 = is_ipv6
vm.hostname_v4 = vm.get_connect_host(use_ipv6=False)
vm.hostname_v6 = vm.get_connect_host(use_ipv6=True)
vm.is_ipv6 = is_ipv6
vm.nat = vm.template.network.nat
vm.port = vm.get_port(use_ipv6=is_ipv6)
vm.port_v4 = vm.get_port(use_ipv6=False)
vm.port_v6 = vm.get_port(use_ipv6=True)
return render_to_response('vm-credentials.html', RequestContext(request, { 'i' : vm }))
except:
return HttpResponse(_("Could not get Virtual Machine credentials."), status=404)
......@@ -370,10 +371,10 @@ def vm_show(request, iid):
is_ipv6 = len(request.META["REMOTE_ADDR"].split('.')) == 1
inst.is_ipv6 = is_ipv6
inst.hostname_v4 = inst.get_connect_host(use_ipv6=False)
inst.hostname_v6 = inst.get_connect_host(use_ipv6=True)
inst.nat = inst.template.network.nat
inst.port = inst.get_port(use_ipv6=is_ipv6)
inst.hostname = inst.get_connect_host(use_ipv6=is_ipv6)
inst.port = inst.get_port(use_ipv6=is_ipv6)
inst.port_v4 = inst.get_port(use_ipv6=False)
inst.port_v6 = inst.get_port(use_ipv6=True)
return render_to_response("show.html", RequestContext(request,{
'uri': inst.get_connect_uri(),
'state': inst.state,
......
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 sign in to comment