Merge "If the flavor_id not in full_flavors, don't make a new API request"
This commit is contained in:
commit
67eba64439
|
@ -205,8 +205,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
|||
})
|
||||
def test_index_flavor_list_exception(self):
|
||||
servers = self.servers.list()
|
||||
flavors = self.flavors.list()
|
||||
full_flavors = OrderedDict([(f.id, f) for f in flavors])
|
||||
search_opts = {'marker': None, 'paginate': True}
|
||||
api.nova.extension_supported('AdminActions', IsA(http.HttpRequest)) \
|
||||
.MultipleTimes().AndReturn(True)
|
||||
|
@ -222,9 +220,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
|
|||
.AndRaise(self.exceptions.nova)
|
||||
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"]). \
|
||||
AndReturn(full_flavors[server.flavor["id"]])
|
||||
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
|
||||
.MultipleTimes().AndReturn(self.limits['absolute'])
|
||||
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
|
||||
|
|
|
@ -132,19 +132,15 @@ class IndexView(tables.DataTableView):
|
|||
else:
|
||||
instance.image['name'] = _("-")
|
||||
|
||||
try:
|
||||
flavor_id = instance.flavor["id"]
|
||||
if flavor_id in full_flavors:
|
||||
instance.full_flavor = full_flavors[flavor_id]
|
||||
else:
|
||||
# If the flavor_id is not in full_flavors list,
|
||||
# get it via nova api.
|
||||
instance.full_flavor = api.nova.flavor_get(
|
||||
self.request, flavor_id)
|
||||
except Exception:
|
||||
LOG.info('Unable to retrieve flavor "%(flavor)s" for '
|
||||
'instance "%(id)s".',
|
||||
{'flavor': flavor_id, 'id': instance.id})
|
||||
flavor_id = instance.flavor["id"]
|
||||
if flavor_id in full_flavors:
|
||||
instance.full_flavor = full_flavors[flavor_id]
|
||||
else:
|
||||
# If the flavor_id is not in full_flavors list,
|
||||
# put info in the log file.
|
||||
msg = ('Unable to retrieve flavor "%s" for instance "%s".'
|
||||
% (flavor_id, instance.id))
|
||||
LOG.info(msg)
|
||||
|
||||
return instances
|
||||
|
||||
|
|
Loading…
Reference in New Issue