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