Commit a154a24c by Bence Dányi

webui: show port only if necessary

parent db60e34b
......@@ -40,10 +40,10 @@
<th>{% trans "IP" %}:</th>
<td>{{ i.hostname }}</td>
</tr>
<tr>
{% if i.nat %}<tr>
<th>{% trans "Port" %}:</th>
<td>{{ i.port}}</td>
</tr>
</tr>{% endif %}
<tr>
<th>{% trans "Username" %}:</th>
<td>cloud</td>
......
......@@ -104,9 +104,12 @@ def ajax_template_name_unique(request):
def vm_credentials(request, iid):
try:
vm = get_object_or_404(Instance, pk=iid, owner=request.user)
proto = len(request.META["REMOTE_ADDR"].split('.')) == 1
vm.hostname = vm.get_connect_host(use_ipv6=proto)
vm.port = vm.get_port(use_ipv6=proto)
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.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 }))
except:
return HttpResponse(_("Could not get Virtual Machine credentials."), status=404)
......@@ -355,6 +358,11 @@ vm_list = login_required(VmListView.as_view())
@login_required
def vm_show(request, iid):
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:
ports = inst.firewall_host.list_ports()
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