Merge "Fix non-API bound filters in project and admin instance panels"
This commit is contained in:
commit
18e8623eea
|
@ -162,17 +162,10 @@ class AdminIndexView(tables.DataTableView):
|
|||
message=_('Unable to retrieve IP addresses from Neutron.'),
|
||||
ignore=True)
|
||||
|
||||
with futurist.ThreadPoolExecutor(max_workers=4) as e:
|
||||
with futurist.ThreadPoolExecutor(max_workers=3) as e:
|
||||
e.submit(fn=_task_get_tenants)
|
||||
e.submit(fn=_task_get_images)
|
||||
e.submit(fn=_task_get_flavors)
|
||||
e.submit(fn=_task_get_instances)
|
||||
|
||||
# This code gets activated only in case of filtering by nonexistent
|
||||
# project, image or flavor. Executing it before _task_get_instances
|
||||
# would make Horizon make less API calls, but as a drawback would make
|
||||
# it impossible to parallelize the request. Executing it after is
|
||||
# a tradeoff, as it happens less often to filter by nonexistent values.
|
||||
|
||||
if 'project' in search_opts and \
|
||||
not swap_filter(tenants, search_opts, 'project', 'tenant_id'):
|
||||
|
@ -187,6 +180,8 @@ class AdminIndexView(tables.DataTableView):
|
|||
self._more = False
|
||||
return instances
|
||||
|
||||
_task_get_instances()
|
||||
|
||||
# Loop through instances to get flavor and tenant info.
|
||||
for inst in instances:
|
||||
flavor_id = inst.flavor["id"]
|
||||
|
|
|
@ -71,7 +71,9 @@ class IndexView(tables.DataTableView):
|
|||
search_opts = self.get_filters({'marker': marker, 'paginate': True})
|
||||
|
||||
instances = []
|
||||
flavors = []
|
||||
full_flavors = {}
|
||||
images = []
|
||||
image_map = {}
|
||||
|
||||
def _task_get_instances():
|
||||
|
@ -100,7 +102,8 @@ class IndexView(tables.DataTableView):
|
|||
def _task_get_flavors():
|
||||
# Gather our flavors to correlate our instances to them
|
||||
try:
|
||||
flavors = api.nova.flavor_list(self.request)
|
||||
tmp_flavors = api.nova.flavor_list(self.request)
|
||||
flavors.extend(tmp_flavors)
|
||||
full_flavors.update([(str(flavor.id), flavor)
|
||||
for flavor in flavors])
|
||||
except Exception:
|
||||
|
@ -110,16 +113,27 @@ class IndexView(tables.DataTableView):
|
|||
# Gather our images to correlate our instances to them
|
||||
try:
|
||||
# TODO(gabriel): Handle pagination.
|
||||
images = api.glance.image_list_detailed(self.request)[0]
|
||||
tmp_images = api.glance.image_list_detailed(self.request)[0]
|
||||
images.extend(tmp_images)
|
||||
image_map.update([(str(image.id), image) for image in images])
|
||||
except Exception:
|
||||
exceptions.handle(self.request, ignore=True)
|
||||
|
||||
with futurist.ThreadPoolExecutor(max_workers=3) as e:
|
||||
e.submit(fn=_task_get_instances)
|
||||
e.submit(fn=_task_get_flavors)
|
||||
e.submit(fn=_task_get_images)
|
||||
|
||||
if 'image_name' in search_opts and \
|
||||
not swap_filter(images, search_opts, 'image_name', 'image'):
|
||||
self._more = False
|
||||
return instances
|
||||
elif 'flavor_name' in search_opts and \
|
||||
not swap_filter(flavors, search_opts, 'flavor_name', 'flavor'):
|
||||
self._more = False
|
||||
return instances
|
||||
|
||||
_task_get_instances()
|
||||
|
||||
# Loop through instances to get flavor info.
|
||||
for instance in instances:
|
||||
if hasattr(instance, 'image'):
|
||||
|
|
Loading…
Reference in New Issue