diff options
2 files changed, 20 insertions, 13 deletions
diff --git a/openstack_dashboard/dashboards/project/network_topology/templates/network_topology/client_side/_balloon_container.html b/openstack_dashboard/dashboards/project/network_topology/templates/network_topology/client_side/_balloon_container.html index bbf70c4ae..952609bc1 100644 --- a/openstack_dashboard/dashboards/project/network_topology/templates/network_topology/client_side/_balloon_container.html +++ b/openstack_dashboard/dashboards/project/network_topology/templates/network_topology/client_side/_balloon_container.html @@ -15,12 +15,11 @@ <div class="footerInner"> <div class="cell link"> <a href="[[url]]">» [[view_details_label]]</a> - {% comment %}The Console link is available if settings.CONSOLE_TYPE is not set at all, or if it's set to any value other than None or False.{% endcomment %} - {% if console_type %} - [[#console_id]] + {% comment %}The console link will only appear if the console item is defined + on the javascript side while rendering the template.{% endcomment %} + [[#console]] <a href="[[url]][[console]]" class="vnc_window">» [[open_console_label]]</a> - [[/console_id]] - {% endif %} + [[/console]] </div> [[#type]] <div class="cell delete"> diff --git a/openstack_dashboard/dashboards/project/network_topology/views.py b/openstack_dashboard/dashboards/project/network_topology/views.py index 683576ec7..68de75977 100644 --- a/openstack_dashboard/dashboards/project/network_topology/views.py +++ b/openstack_dashboard/dashboards/project/network_topology/views.py @@ -77,6 +77,12 @@ from openstack_dashboard.dashboards.project.routers.tables import \ from openstack_dashboard.dashboards.project.routers import\ views as r_views +# List of known server statuses that wont connect to the console +console_invalid_status = { + 'shutoff', 'suspended', 'resize', 'verify_resize', + 'revert_resize', 'migrating', 'build', 'shelved', + 'shelved_offloaded'} + class TranslationHelper(object): """Helper class to provide the translations of instances, networks, @@ -251,19 +257,21 @@ class JSONView(View): console_type = getattr(settings, 'CONSOLE_TYPE', 'AUTO') # lowercase of the keys will be used at the end of the console URL. for server in servers: - try: - console = i_console.get_console( - request, console_type, server)[0].lower() - except exceptions.NotAvailable: - console = None - server_data = {'name': server.name, 'status': self.trans.instance[server.status], 'original_status': server.status, 'task': getattr(server, 'OS-EXT-STS:task_state'), 'id': server.id} - if console: - server_data['console'] = console + # Avoid doing extra calls for console if the server is in + # a invalid status for console connection + if server.status.lower() not in console_invalid_status: + try: + console = i_console.get_console( + request, console_type, server)[0].lower() + server_data['console'] = console + except exceptions.NotAvailable: + pass + data.append(server_data) self.add_resource_url('horizon:project:instances:detail', data) return data |