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,6 +354,7 @@ class DetailView(tabs.TabView):
|
||||
instance.status_label = (
|
||||
filters.get_display_label(choices, instance.status))
|
||||
|
||||
def _task_get_volumes():
|
||||
try:
|
||||
instance.volumes = api.nova.instance_volumes_list(self.request,
|
||||
instance_id)
|
||||
@ -365,6 +366,7 @@ class DetailView(tabs.TabView):
|
||||
'id': instance_id}
|
||||
exceptions.handle(self.request, msg, ignore=True)
|
||||
|
||||
def _task_get_flavor():
|
||||
try:
|
||||
instance.full_flavor = api.nova.flavor_get(
|
||||
self.request, instance.flavor["id"])
|
||||
@ -374,6 +376,7 @@ class DetailView(tabs.TabView):
|
||||
'id': instance_id}
|
||||
exceptions.handle(self.request, msg, ignore=True)
|
||||
|
||||
def _task_get_security_groups():
|
||||
try:
|
||||
instance.security_groups = api.neutron.server_security_groups(
|
||||
self.request, instance_id)
|
||||
@ -383,14 +386,21 @@ class DetailView(tabs.TabView):
|
||||
'id': instance_id}
|
||||
exceptions.handle(self.request, msg, ignore=True)
|
||||
|
||||
def _task_update_addresses():
|
||||
try:
|
||||
api.network.servers_update_addresses(self.request, [instance])
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve IP addresses from Neutron for '
|
||||
'instance "%(name)s" (%(id)s).') % {'name': instance.name,
|
||||
'id': instance_id}
|
||||
'instance "%(name)s" (%(id)s).') \
|
||||
% {'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
|
||||
|
||||
def get_tabs(self, request, *args, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user