summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Runge <mrunge@redhat.com>2015-04-08 11:35:11 +0200
committerlin-hua-cheng <os.lcheng@gmail.com>2015-04-10 22:11:55 -0700
commit8c8b130722e3b834fa3f334164c833e0b21f2c82 (patch)
tree489ef1192c7c79fbd4ebab0bc26e871a0c7cfd60
parent394765e1abd63bb658f50bedf784bf6da4165c8f (diff)
downloadhorizon-8c8b130722e3b834fa3f334164c833e0b21f2c82.tar.gz
Silently drop access to non-existent flavours
Although not ideal, users are merely confused, when an error message pops up, but everything works. Change-Id: I765a8ba361e47e5a0af91328865db2515e51606a Closes-bug: #1441523
-rw-r--r--openstack_dashboard/dashboards/project/instances/tests.py50
-rw-r--r--openstack_dashboard/dashboards/project/instances/views.py9
2 files changed, 7 insertions, 52 deletions
diff --git a/openstack_dashboard/dashboards/project/instances/tests.py b/openstack_dashboard/dashboards/project/instances/tests.py
index a5fe31955..ca9adc4ba 100644
--- a/openstack_dashboard/dashboards/project/instances/tests.py
+++ b/openstack_dashboard/dashboards/project/instances/tests.py
@@ -18,7 +18,6 @@
import json
import sys
-import uuid
from django.conf import settings
from django.core.urlresolvers import reverse
@@ -162,55 +161,6 @@ class InstanceTests(helpers.TestCase):
self.assertItemsEqual(instances, self.servers.list())
@helpers.create_stubs({
- api.nova: ('flavor_list', 'server_list', 'flavor_get',
- 'tenant_absolute_limits', 'extension_supported',),
- api.glance: ('image_list_detailed',),
- api.network: ('floating_ip_simple_associate_supported',
- 'floating_ip_supported',
- 'servers_update_addresses',),
- })
- def test_index_flavor_get_exception(self):
- servers = self.servers.list()
- flavors = self.flavors.list()
- api.nova.extension_supported('AdminActions',
- IsA(http.HttpRequest)) \
- .MultipleTimes().AndReturn(True)
- # UUIDs generated using indexes are unlikely to match
- # any of existing flavor ids and are guaranteed to be deterministic.
- for i, server in enumerate(servers):
- server.flavor['id'] = str(uuid.UUID(int=i))
-
- search_opts = {'marker': None, 'paginate': True}
- api.nova.server_list(IsA(http.HttpRequest), search_opts=search_opts) \
- .AndReturn([servers, False])
- api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
- api.nova.flavor_list(IsA(http.HttpRequest)).AndReturn(flavors)
- api.glance.image_list_detailed(IgnoreArg()) \
- .AndReturn((self.images.list(), False, False))
- for server in servers:
- api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"]). \
- AndRaise(self.exceptions.nova)
- api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
- .MultipleTimes().AndReturn(self.limits['absolute'])
- api.network.floating_ip_supported(IsA(http.HttpRequest)) \
- .MultipleTimes().AndReturn(True)
- api.network.floating_ip_simple_associate_supported(
- IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)
-
- self.mox.ReplayAll()
-
- res = self.client.get(INDEX_URL)
-
- instances = res.context['instances_table'].data
-
- self.assertTemplateUsed(res, 'project/instances/index.html')
- # Since error messages produced for each instance are identical,
- # there will be only one error message for all instances
- # (messages de-duplication)
- self.assertMessageCount(res, error=1)
- self.assertItemsEqual(instances, self.servers.list())
-
- @helpers.create_stubs({
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
'extension_supported',),
api.glance: ('image_list_detailed',),
diff --git a/openstack_dashboard/dashboards/project/instances/views.py b/openstack_dashboard/dashboards/project/instances/views.py
index 8e0ee0f8a..674e201ec 100644
--- a/openstack_dashboard/dashboards/project/instances/views.py
+++ b/openstack_dashboard/dashboards/project/instances/views.py
@@ -19,6 +19,8 @@
"""
Views for managing instances.
"""
+import logging
+
from django.core.urlresolvers import reverse
from django.core.urlresolvers import reverse_lazy
from django import http
@@ -48,6 +50,8 @@ from openstack_dashboard.dashboards.project.instances \
from openstack_dashboard.dashboards.project.instances \
import workflows as project_workflows
+LOG = logging.getLogger(__name__)
+
class IndexView(tables.DataTableView):
table_class = project_tables.InstancesTable
@@ -119,8 +123,9 @@ class IndexView(tables.DataTableView):
instance.full_flavor = api.nova.flavor_get(
self.request, flavor_id)
except Exception:
- msg = _('Unable to retrieve instance size information.')
- exceptions.handle(self.request, msg)
+ msg = ('Unable to retrieve flavor "%s" for instance "%s".'
+ % (flavor_id, instance.id))
+ LOG.info(msg)
return instances
def get_filters(self, filters):