Commit 9a58a90e by Bence Dányi

webui: show ipv4/6 addresses

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