Commit a154a24c by Bence Dányi

webui: show port only if necessary

parent db60e34b
...@@ -40,10 +40,10 @@ ...@@ -40,10 +40,10 @@
<th>{% trans "IP" %}:</th> <th>{% trans "IP" %}:</th>
<td>{{ i.hostname }}</td> <td>{{ i.hostname }}</td>
</tr> </tr>
<tr> {% if i.nat %}<tr>
<th>{% trans "Port" %}:</th> <th>{% trans "Port" %}:</th>
<td>{{ i.port}}</td> <td>{{ i.port}}</td>
</tr> </tr>{% endif %}
<tr> <tr>
<th>{% trans "Username" %}:</th> <th>{% trans "Username" %}:</th>
<td>cloud</td> <td>cloud</td>
......
...@@ -104,9 +104,12 @@ def ajax_template_name_unique(request): ...@@ -104,9 +104,12 @@ def ajax_template_name_unique(request):
def vm_credentials(request, iid): 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)
proto = len(request.META["REMOTE_ADDR"].split('.')) == 1 is_ipv6 = len(request.META["REMOTE_ADDR"].split('.')) == 1
vm.hostname = vm.get_connect_host(use_ipv6=proto) vm.hostname = vm.get_connect_host(use_ipv6=is_ipv6)
vm.port = vm.get_port(use_ipv6=proto) vm.is_ipv6 = is_ipv6
vm.hostname_v4 = vm.get_connect_host(use_ipv6=False)
vm.nat = vm.template.network.nat
vm.port = vm.get_port(use_ipv6=is_ipv6)
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)
...@@ -355,6 +358,11 @@ vm_list = login_required(VmListView.as_view()) ...@@ -355,6 +358,11 @@ vm_list = login_required(VmListView.as_view())
@login_required @login_required
def vm_show(request, iid): def vm_show(request, iid):
inst = get_object_or_404(Instance, id=iid, owner=request.user) inst = get_object_or_404(Instance, id=iid, owner=request.user)
is_ipv6 = True #len(request.META["REMOTE_ADDR"].split('.')) == 1
inst.is_ipv6 = is_ipv6
inst.hostname_v4 = inst.get_connect_host(use_ipv6=False)
inst.nat = inst.template.network.nat
inst.port = inst.get_port(use_ipv6=is_ipv6)
try: try:
ports = inst.firewall_host.list_ports() ports = inst.firewall_host.list_ports()
except: except:
......
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