Only get detailed info for Nova servers when necessary
Horizon will get all servers from Nova in different several places,
but sometimes it only need ID and name instead of all the related
information of servers. novaclient already support 'detailed=False'
param for servers query.
Horizon page loading performance can also be improved with this patch.
Closes-Bug: #1661423
Change-Id: Ic4cc95cb4eaed0461a22ab1045fa83ba5a5e9ce4
(cherry picked from commit c33b0840cb
)
This commit is contained in:
parent
984d9cf7b8
commit
8a922df86b
@ -485,7 +485,7 @@ class FloatingIpManager(network_base.FloatingIpManager):
|
||||
def list_targets(self):
|
||||
tenant_id = self.request.user.tenant_id
|
||||
ports = port_list(self.request, tenant_id=tenant_id)
|
||||
servers, has_more = nova.server_list(self.request)
|
||||
servers, has_more = nova.server_list(self.request, detailed=False)
|
||||
server_dict = collections.OrderedDict(
|
||||
[(s.id, s.name) for s in servers])
|
||||
reachable_subnets = self._get_reachable_subnets(ports)
|
||||
|
@ -723,7 +723,7 @@ def server_get(request, instance_id):
|
||||
|
||||
|
||||
@profiler.trace
|
||||
def server_list(request, search_opts=None, all_tenants=False):
|
||||
def server_list(request, search_opts=None, all_tenants=False, detailed=True):
|
||||
page_size = utils.get_page_size(request)
|
||||
c = novaclient(request)
|
||||
paginate = False
|
||||
@ -739,7 +739,7 @@ def server_list(request, search_opts=None, all_tenants=False):
|
||||
else:
|
||||
search_opts['project_id'] = request.user.tenant_id
|
||||
servers = [Server(s, request)
|
||||
for s in c.servers.list(True, search_opts)]
|
||||
for s in c.servers.list(detailed, search_opts)]
|
||||
|
||||
has_more_data = False
|
||||
if paginate and len(servers) > page_size:
|
||||
|
@ -76,7 +76,8 @@ class IndexView(tables.DataTableView):
|
||||
instances = []
|
||||
try:
|
||||
instances, has_more = api.nova.server_list(self.request,
|
||||
all_tenants=True)
|
||||
all_tenants=True,
|
||||
detailed=False)
|
||||
except Exception:
|
||||
exceptions.handle(
|
||||
self.request,
|
||||
|
@ -54,7 +54,7 @@ class VolumeTests(test.BaseAdminViewTests):
|
||||
'all_tenants': True}).AndReturn([])
|
||||
if not instanceless_volumes:
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts={
|
||||
'all_tenants': True}) \
|
||||
'all_tenants': True}, detailed=False) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
keystone.tenant_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn([self.tenants.list(), False])
|
||||
@ -86,7 +86,7 @@ class VolumeTests(test.BaseAdminViewTests):
|
||||
api.cinder.volume_snapshot_list(
|
||||
IsA(http.HttpRequest), search_opts=None).AndReturn(vol_snaps)
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts={
|
||||
'all_tenants': True}) \
|
||||
'all_tenants': True}, detailed=False) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
keystone.tenant_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn([self.tenants.list(), False])
|
||||
|
@ -173,7 +173,7 @@ class FloatingIpViewTests(test.TestCase):
|
||||
def test_disassociate_post(self):
|
||||
floating_ip = self.floating_ips.first()
|
||||
|
||||
api.nova.server_list(IsA(http.HttpRequest)) \
|
||||
api.nova.server_list(IsA(http.HttpRequest), detailed=False) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.floating_ips.list())
|
||||
@ -197,7 +197,7 @@ class FloatingIpViewTests(test.TestCase):
|
||||
def test_disassociate_post_with_exception(self):
|
||||
floating_ip = self.floating_ips.first()
|
||||
|
||||
api.nova.server_list(IsA(http.HttpRequest)) \
|
||||
api.nova.server_list(IsA(http.HttpRequest), detailed=False) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.floating_ips.list())
|
||||
@ -232,7 +232,7 @@ class FloatingIpViewTests(test.TestCase):
|
||||
IsA(http.HttpRequest)) \
|
||||
.AndReturn(floating_pools)
|
||||
api.nova.server_list(
|
||||
IsA(http.HttpRequest)) \
|
||||
IsA(http.HttpRequest), detailed=False) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest)).MultipleTimes() \
|
||||
@ -274,7 +274,7 @@ class FloatingIpViewTests(test.TestCase):
|
||||
IsA(http.HttpRequest)) \
|
||||
.AndReturn(floating_pools)
|
||||
api.nova.server_list(
|
||||
IsA(http.HttpRequest)) \
|
||||
IsA(http.HttpRequest), detailed=False) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
quotas.tenant_quota_usages(
|
||||
IsA(http.HttpRequest)).MultipleTimes() \
|
||||
|
@ -116,7 +116,8 @@ class IndexView(tables.DataTableView):
|
||||
try:
|
||||
# TODO(tsufiev): we should pass attached_instance_ids to
|
||||
# nova.server_list as soon as Nova API allows for this
|
||||
instances, has_more = api.nova.server_list(self.request)
|
||||
instances, has_more = api.nova.server_list(self.request,
|
||||
detailed=False)
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve instance list.'))
|
||||
|
@ -62,7 +62,8 @@ class VolumeTableMixIn(object):
|
||||
# TODO(tsufiev): we should pass attached_instance_ids to
|
||||
# nova.server_list as soon as Nova API allows for this
|
||||
instances, has_more = api.nova.server_list(self.request,
|
||||
search_opts=search_opts)
|
||||
search_opts=search_opts,
|
||||
detailed=False)
|
||||
return instances
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
|
@ -64,7 +64,8 @@ class VolumeAndSnapshotsAndBackupsTests(test.TestCase):
|
||||
sort_dir='desc', paginate=True).\
|
||||
AndReturn([volumes, False, False])
|
||||
if not instanceless_volumes:
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None,
|
||||
detailed=False).\
|
||||
AndReturn([self.servers.list(), False])
|
||||
api.cinder.volume_snapshot_list(IsA(http.HttpRequest)).\
|
||||
AndReturn(vol_snaps)
|
||||
@ -123,7 +124,8 @@ class VolumeAndSnapshotsAndBackupsTests(test.TestCase):
|
||||
AndReturn([volumes, has_more, has_prev])
|
||||
api.cinder.volume_snapshot_list(
|
||||
IsA(http.HttpRequest), search_opts=None).AndReturn(vol_snaps)
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None,
|
||||
detailed=False).\
|
||||
AndReturn([self.servers.list(), False])
|
||||
api.cinder.tenant_absolute_limits(IsA(http.HttpRequest)).MultipleTimes().\
|
||||
AndReturn(self.cinder_limits['absolute'])
|
||||
|
@ -942,7 +942,8 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
cinder.volume_delete(IsA(http.HttpRequest), volume.id)
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None,
|
||||
detailed=False).\
|
||||
AndReturn([self.servers.list(), False])
|
||||
cinder.volume_list_paged(
|
||||
IsA(http.HttpRequest), marker=None, paginate=True, sort_dir='desc',
|
||||
@ -950,7 +951,8 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None,
|
||||
detailed=False).\
|
||||
AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest)).MultipleTimes().\
|
||||
AndReturn(self.cinder_limits['absolute'])
|
||||
@ -1175,7 +1177,8 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None,
|
||||
detailed=False)\
|
||||
.AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest))\
|
||||
.MultipleTimes().AndReturn(limits)
|
||||
@ -1216,7 +1219,8 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None,
|
||||
detailed=False)\
|
||||
.AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest))\
|
||||
.MultipleTimes().AndReturn(limits)
|
||||
@ -1614,7 +1618,8 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn(self.cinder_volume_snapshots.list())
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None,
|
||||
detailed=False)\
|
||||
.AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest))\
|
||||
.MultipleTimes('limits').AndReturn(limits)
|
||||
@ -1675,7 +1680,8 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None,
|
||||
detailed=False)\
|
||||
.AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest))\
|
||||
.MultipleTimes().AndReturn(limits)
|
||||
@ -1741,7 +1747,8 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
cinder.transfer_delete(IsA(http.HttpRequest), transfer.id)
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None,
|
||||
detailed=False).\
|
||||
AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest)).MultipleTimes().\
|
||||
AndReturn(self.cinder_limits['absolute'])
|
||||
|
@ -760,7 +760,7 @@ class NetworkApiNeutronFloatingIpTests(NetworkApiNeutronTestBase):
|
||||
novaclient = self.stub_novaclient()
|
||||
novaclient.servers = self.mox.CreateMockAnything()
|
||||
search_opts = {'project_id': self.request.user.tenant_id}
|
||||
novaclient.servers.list(True, search_opts).AndReturn(servers)
|
||||
novaclient.servers.list(False, search_opts).AndReturn(servers)
|
||||
|
||||
search_opts = {'router:external': True}
|
||||
ext_nets = [n for n in self.api_networks.list()
|
||||
|
Loading…
Reference in New Issue
Block a user