diff --git a/openstack_dashboard/dashboards/admin/instances/tests.py b/openstack_dashboard/dashboards/admin/instances/tests.py index 3630cb79ad..c6cf65e5da 100644 --- a/openstack_dashboard/dashboards/admin/instances/tests.py +++ b/openstack_dashboard/dashboards/admin/instances/tests.py @@ -133,10 +133,6 @@ class InstanceViewTest(test.BaseAdminViewTests): res = self.client.get(INDEX_URL) instances = res.context['table'].data self.assertTemplateUsed(res, INDEX_TEMPLATE) - # 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.assertCountEqual(instances, servers) self.assertEqual(self.mock_image_list_detailed.call_count, 4) diff --git a/openstack_dashboard/dashboards/admin/instances/views.py b/openstack_dashboard/dashboards/admin/instances/views.py index c35527fe46..efa28dd763 100644 --- a/openstack_dashboard/dashboards/admin/instances/views.py +++ b/openstack_dashboard/dashboards/admin/instances/views.py @@ -33,6 +33,8 @@ from openstack_dashboard.dashboards.admin.instances \ from openstack_dashboard.dashboards.admin.instances \ import tables as project_tables from openstack_dashboard.dashboards.admin.instances import tabs +from openstack_dashboard.dashboards.project.instances \ + import utils as instance_utils from openstack_dashboard.dashboards.project.instances import views from openstack_dashboard.dashboards.project.instances.workflows \ import update_instance @@ -215,18 +217,9 @@ class AdminIndexView(tables.PagedTableMixin, tables.DataTableView): else: inst.image['name'] = _("-") - flavor_id = inst.flavor["id"] - try: - if flavor_id in flavor_dict: - inst.full_flavor = flavor_dict[flavor_id] - else: - # If the flavor_id is not in flavor_dict list, - # gets it via nova api. - inst.full_flavor = api.nova.flavor_get( - self.request, flavor_id) - except Exception: - msg = _('Unable to retrieve instance size information.') - exceptions.handle(self.request, msg) + inst.full_flavor = instance_utils.resolve_flavor(self.request, + inst, flavor_dict) + tenant = tenant_dict.get(inst.tenant_id, None) inst.tenant_name = getattr(tenant, "name", None) return instances diff --git a/openstack_dashboard/dashboards/project/instances/tests.py b/openstack_dashboard/dashboards/project/instances/tests.py index 5e074a7005..9f0c7833d4 100644 --- a/openstack_dashboard/dashboards/project/instances/tests.py +++ b/openstack_dashboard/dashboards/project/instances/tests.py @@ -316,6 +316,7 @@ class InstanceTableTests(InstanceTestBase, InstanceTableTestMixin): self.mock_is_feature_available.return_value = True self.mock_server_list_paged.return_value = [servers, False, False] self.mock_servers_update_addresses.return_value = None + self.mock_flavor_get.side_effect = self.exceptions.nova self.mock_flavor_list.side_effect = self.exceptions.nova self.mock_image_list_detailed.return_value = (self.images.list(), False, False) diff --git a/openstack_dashboard/dashboards/project/instances/views.py b/openstack_dashboard/dashboards/project/instances/views.py index b91e00ea41..ca7e6333be 100644 --- a/openstack_dashboard/dashboards/project/instances/views.py +++ b/openstack_dashboard/dashboards/project/instances/views.py @@ -171,14 +171,9 @@ class IndexView(tables.PagedTableMixin, tables.DataTableView): for instance in instances: self._populate_image_info(instance, image_dict, volume_dict) - flavor_id = instance.flavor["id"] - if flavor_id in flavor_dict: - instance.full_flavor = flavor_dict[flavor_id] - else: - # If the flavor_id is not in flavor_dict, - # put info in the log file. - LOG.info('Unable to retrieve flavor "%s" for instance "%s".', - flavor_id, instance.id) + instance.full_flavor = instance_utils.resolve_flavor(self.request, + instance, + flavor_dict) return instances