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
This commit is contained in:
parent
394765e1ab
commit
8c8b130722
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
import uuid
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
@ -161,55 +160,6 @@ class InstanceTests(helpers.TestCase):
|
|||||||
|
|
||||||
self.assertItemsEqual(instances, self.servers.list())
|
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({
|
@helpers.create_stubs({
|
||||||
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
|
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
|
||||||
'extension_supported',),
|
'extension_supported',),
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
"""
|
"""
|
||||||
Views for managing instances.
|
Views for managing instances.
|
||||||
"""
|
"""
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
from django import http
|
from django import http
|
||||||
@ -48,6 +50,8 @@ from openstack_dashboard.dashboards.project.instances \
|
|||||||
from openstack_dashboard.dashboards.project.instances \
|
from openstack_dashboard.dashboards.project.instances \
|
||||||
import workflows as project_workflows
|
import workflows as project_workflows
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class IndexView(tables.DataTableView):
|
class IndexView(tables.DataTableView):
|
||||||
table_class = project_tables.InstancesTable
|
table_class = project_tables.InstancesTable
|
||||||
@ -119,8 +123,9 @@ class IndexView(tables.DataTableView):
|
|||||||
instance.full_flavor = api.nova.flavor_get(
|
instance.full_flavor = api.nova.flavor_get(
|
||||||
self.request, flavor_id)
|
self.request, flavor_id)
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = _('Unable to retrieve instance size information.')
|
msg = ('Unable to retrieve flavor "%s" for instance "%s".'
|
||||||
exceptions.handle(self.request, msg)
|
% (flavor_id, instance.id))
|
||||||
|
LOG.info(msg)
|
||||||
return instances
|
return instances
|
||||||
|
|
||||||
def get_filters(self, filters):
|
def get_filters(self, filters):
|
||||||
|
Loading…
Reference in New Issue
Block a user