Fixes inconsistent console problem

The `open console` link in `Network Topology` page is inconsistent with
console in `Instance Detail` page.

Fixes bug 1228990

Change-Id: I845a9fa4cc17a296bde5da624d3b8833fef9ade6
This commit is contained in:
liyingjun 2013-09-23 11:04:44 +08:00
parent 8432143b5d
commit b643e430c8
3 changed files with 9 additions and 1 deletions

View File

@ -531,6 +531,7 @@ horizon.network_topology = {
}); });
} else if (d.type == 'instance') { } else if (d.type == 'instance') {
html_data.console_id = d.id; html_data.console_id = d.id;
html_data.console = d.console;
html = balloon_tmpl.render(html_data,{ html = balloon_tmpl.render(html_data,{
table1:device_tmpl table1:device_tmpl
}); });

View File

@ -16,7 +16,7 @@
<div class="cell link"> <div class="cell link">
<a href="[[url]]">» view [[type]] details</a> <a href="[[url]]">» view [[type]] details</a>
[[#console_id]] [[#console_id]]
<a href="[[url]]vnc" class="vnc_window">» open console</a> <a href="[[url]][[console]]" class="vnc_window">» open console</a>
[[/console_id]] [[/console_id]]
</div> </div>
<div class="cell delete"> <div class="cell delete">

View File

@ -20,6 +20,7 @@
import json import json
from django.conf import settings # noqa
from django.core.urlresolvers import reverse # noqa from django.core.urlresolvers import reverse # noqa
from django.core.urlresolvers import reverse_lazy # noqa from django.core.urlresolvers import reverse_lazy # noqa
from django.http import HttpResponse # noqa from django.http import HttpResponse # noqa
@ -114,8 +115,14 @@ class JSONView(View):
servers, more = api.nova.server_list(request) servers, more = api.nova.server_list(request)
except Exception: except Exception:
servers = [] servers = []
console_type = getattr(settings, 'CONSOLE_TYPE', 'AUTO')
if console_type == 'SPICE':
console = 'spice'
else:
console = 'vnc'
data['servers'] = [{'name': server.name, data['servers'] = [{'name': server.name,
'status': server.status, 'status': server.status,
'console': console,
'task': getattr(server, 'OS-EXT-STS:task_state'), 'task': getattr(server, 'OS-EXT-STS:task_state'),
'id': server.id} for server in servers] 'id': server.id} for server in servers]
self.add_resource_url('horizon:project:instances:detail', self.add_resource_url('horizon:project:instances:detail',