Make API calls in Instances.DetailView parallel
In order to increase rendering speed, make nova and network api calls parallel in instance Detail View panel. Closes-bug: #1675788 Change-Id: I3c94292981d6bf11e6e2947704b314842a99676f
This commit is contained in:
parent
a6cc518d1f
commit
7fdd875703
@ -354,42 +354,52 @@ class DetailView(tabs.TabView):
|
|||||||
instance.status_label = (
|
instance.status_label = (
|
||||||
filters.get_display_label(choices, instance.status))
|
filters.get_display_label(choices, instance.status))
|
||||||
|
|
||||||
try:
|
def _task_get_volumes():
|
||||||
instance.volumes = api.nova.instance_volumes_list(self.request,
|
try:
|
||||||
instance_id)
|
instance.volumes = api.nova.instance_volumes_list(self.request,
|
||||||
# Sort by device name
|
instance_id)
|
||||||
instance.volumes.sort(key=lambda vol: vol.device)
|
# Sort by device name
|
||||||
except Exception:
|
instance.volumes.sort(key=lambda vol: vol.device)
|
||||||
msg = _('Unable to retrieve volume list for instance '
|
except Exception:
|
||||||
'"%(name)s" (%(id)s).') % {'name': instance.name,
|
msg = _('Unable to retrieve volume list for instance '
|
||||||
'id': instance_id}
|
'"%(name)s" (%(id)s).') % {'name': instance.name,
|
||||||
exceptions.handle(self.request, msg, ignore=True)
|
'id': instance_id}
|
||||||
|
exceptions.handle(self.request, msg, ignore=True)
|
||||||
|
|
||||||
try:
|
def _task_get_flavor():
|
||||||
instance.full_flavor = api.nova.flavor_get(
|
try:
|
||||||
self.request, instance.flavor["id"])
|
instance.full_flavor = api.nova.flavor_get(
|
||||||
except Exception:
|
self.request, instance.flavor["id"])
|
||||||
msg = _('Unable to retrieve flavor information for instance '
|
except Exception:
|
||||||
'"%(name)s" (%(id)s).') % {'name': instance.name,
|
msg = _('Unable to retrieve flavor information for instance '
|
||||||
'id': instance_id}
|
'"%(name)s" (%(id)s).') % {'name': instance.name,
|
||||||
exceptions.handle(self.request, msg, ignore=True)
|
'id': instance_id}
|
||||||
|
exceptions.handle(self.request, msg, ignore=True)
|
||||||
|
|
||||||
try:
|
def _task_get_security_groups():
|
||||||
instance.security_groups = api.neutron.server_security_groups(
|
try:
|
||||||
self.request, instance_id)
|
instance.security_groups = api.neutron.server_security_groups(
|
||||||
except Exception:
|
self.request, instance_id)
|
||||||
msg = _('Unable to retrieve security groups for instance '
|
except Exception:
|
||||||
'"%(name)s" (%(id)s).') % {'name': instance.name,
|
msg = _('Unable to retrieve security groups for instance '
|
||||||
'id': instance_id}
|
'"%(name)s" (%(id)s).') % {'name': instance.name,
|
||||||
exceptions.handle(self.request, msg, ignore=True)
|
'id': instance_id}
|
||||||
|
exceptions.handle(self.request, msg, ignore=True)
|
||||||
|
|
||||||
try:
|
def _task_update_addresses():
|
||||||
api.network.servers_update_addresses(self.request, [instance])
|
try:
|
||||||
except Exception:
|
api.network.servers_update_addresses(self.request, [instance])
|
||||||
msg = _('Unable to retrieve IP addresses from Neutron for '
|
except Exception:
|
||||||
'instance "%(name)s" (%(id)s).') % {'name': instance.name,
|
msg = _('Unable to retrieve IP addresses from Neutron for '
|
||||||
'id': instance_id}
|
'instance "%(name)s" (%(id)s).') \
|
||||||
exceptions.handle(self.request, msg, ignore=True)
|
% {'name': instance.name, 'id': instance_id}
|
||||||
|
exceptions.handle(self.request, msg, ignore=True)
|
||||||
|
|
||||||
|
with futurist.ThreadPoolExecutor(max_workers=4) as e:
|
||||||
|
e.submit(fn=_task_get_volumes)
|
||||||
|
e.submit(fn=_task_get_flavor)
|
||||||
|
e.submit(fn=_task_get_security_groups)
|
||||||
|
e.submit(fn=_task_update_addresses)
|
||||||
|
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user