Fix generating empty pagination link in TableTab

In `NFV` dashboard, each of panels, such as `VNF Catalog` or `VIM
Management`, has a table with pagination. However, some of tables
cannot be displayed, or have a `Next` link which doesn't work. The
reason why the tables cannot be displayed is because some table
templates in Horizon doesn't expect a pagination link which is not None
but empty filled with a white space.

Generating pagination link is defined in each of TableTab class derived
from `tabs.TableTab` in Horizon. For example, TableTab for `VNF Catalog`
is defined as `VNFCatalogTab` in
`tacker_horizon/openstack_dashboard/dashboards/nfv/vnfcatalog/tabs.py`
in tacker-horizon repository. Considering the behavior of the
pagination, it should generate `Next` link if the number of entries of
the table is larger than the maximum number of entries per page which is
defined in Horizon as `20` as default.

The problem is it always set `self._has_more = True` without checking
the number of entries, and Horizon wrongly expects it must be over the
maximum number. As a result, it generates a empty pagination link.

Closes-Bug: #1889993

Change-Id: I9dc7ebc58405048b333d1ca7dd9ec05bd692c01e
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
This commit is contained in:
Yasufumi Ogawa 2020-08-01 17:01:08 +00:00
parent 68b5b32035
commit 58b0de5dcb
7 changed files with 90 additions and 18 deletions

View File

@ -15,6 +15,7 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from horizon import utils as horizon_utils
from tacker_horizon.openstack_dashboard import api
from tacker_horizon.openstack_dashboard.dashboards.nfv.nscatalog import tables
@ -40,9 +41,15 @@ class NSCatalogTab(tabs.TableTab):
def get_nscatalog_data(self):
try:
self._has_more = False
instances = []
nsds = api.tacker.nsd_list(self.request)
if len(nsds) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for nsd in nsds:
item = NSCatalogItem(nsd['name'],
nsd['description'],
@ -84,10 +91,16 @@ class NSDEventsTab(tabs.TableTab):
def get_events_data(self):
try:
self._has_more = True
utils.EventItemList.clear_list()
events = api.tacker.events_list(self.request,
self.tab_group.kwargs['nsd_id'])
if len(events) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for event in events:
evt_obj = utils.EventItem(
event['id'], event['resource_state'],

View File

@ -13,6 +13,7 @@
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from horizon import utils as horizon_utils
from tacker_horizon.openstack_dashboard import api
from tacker_horizon.openstack_dashboard.dashboards.nfv.nsmanager import tables
@ -31,9 +32,15 @@ class NSManagerTab(tabs.TableTab):
def get_nsmanager_data(self):
try:
self._has_more = True
tables.NSManagerItemList.clear_list()
nss = api.tacker.ns_list(self.request)
if len(nss) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for ns in nss:
try:
ns_desc_str = ns['description']
@ -76,10 +83,16 @@ class NSEventsTab(tabs.TableTab):
def get_events_data(self):
try:
self._has_more = True
utils.EventItemList.clear_list()
events = api.tacker.events_list(self.request,
self.tab_group.kwargs['ns_id'])
if len(events) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for event in events:
evt_obj = utils.EventItem(
event['id'], event['resource_state'],

View File

@ -17,6 +17,7 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from horizon import utils as horizon_utils
from tacker_horizon.openstack_dashboard import api
from tacker_horizon.openstack_dashboard.dashboards.nfv import utils # noqa
@ -50,9 +51,15 @@ class VIMTab(tabs.TableTab):
def get_vim_data(self):
try:
self._has_more = False
instances = []
vims = api.tacker.vim_list(self.request)
if len(vims) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for vim in vims:
auth_cred = vim['auth_cred']
placement_attr = vim['placement_attr']
@ -97,10 +104,16 @@ class VIMEventsTab(tabs.TableTab):
def get_events_data(self):
try:
self._has_more = True
utils.EventItemList.clear_list()
events = api.tacker.events_list(self.request,
self.tab_group.kwargs['vim_id'])
if len(events) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for event in events:
evt_obj = utils.EventItem(
event['id'], event['resource_state'],

View File

@ -17,6 +17,7 @@ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from horizon import utils as horizon_utils
from tacker_horizon.openstack_dashboard import api
from tacker_horizon.openstack_dashboard.dashboards.nfv import utils
@ -43,11 +44,16 @@ class VNFCatalogTab(tabs.TableTab):
def get_vnfcatalog_data(self):
try:
self._has_more = False
catalogs = []
vnfds = api.tacker.vnfd_list(self.request,
template_source="onboarded")
if len(vnfds) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for vnfd in vnfds:
s_types = [s_type for s_type in vnfd['service_types']]
s_types_string = ""
@ -94,10 +100,16 @@ class VNFDEventsTab(tabs.TableTab):
def get_events_data(self):
try:
self._has_more = True
utils.EventItemList.clear_list()
events = api.tacker.events_list(self.request,
self.tab_group.kwargs['vnfd_id'])
if len(events) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for event in events:
evt_obj = utils.EventItem(
event['id'], event['resource_state'],

View File

@ -16,6 +16,7 @@ import yaml
from horizon import exceptions
from horizon import tabs
from horizon import utils as horizon_utils
from tacker_horizon.openstack_dashboard import api
from tacker_horizon.openstack_dashboard.dashboards.nfv.vnffgcatalog \
@ -41,9 +42,15 @@ class VNFFGCatalogTab(tabs.TableTab):
def get_vnffgcatalog_data(self):
try:
self._has_more = False
instances = []
vnffgds = api.tacker.vnffgd_list(self.request)
if len(vnffgds) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for vnffgd in vnffgds:
item = VNFFGCatalogItem(vnffgd['name'],
vnffgd['description'],

View File

@ -14,6 +14,7 @@
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from horizon import utils as horizon_utils
from tacker_horizon.openstack_dashboard import api
from tacker_horizon.openstack_dashboard.dashboards.nfv.vnffgmanager \
@ -36,9 +37,15 @@ class VNFFGManagerTab(tabs.TableTab):
def get_vnffgmanager_data(self):
try:
self._has_more = True
VNFFGManagerItemList.clear_list()
vnffgs = api.tacker.vnffg_list(self.request)
if len(vnffgs) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for vnffg in vnffgs:
try:
vnffg_desc_str = vnffg['description']

View File

@ -15,6 +15,7 @@
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
from horizon import tabs
from horizon import utils as horizon_utils
from tacker_horizon.openstack_dashboard import api
from tacker_horizon.openstack_dashboard.dashboards.nfv import utils
@ -33,15 +34,15 @@ class VNFManagerTab(tabs.TableTab):
def get_vnfmanager_data(self):
try:
# marker = self.request.GET.get(
# tables.VNFManagerTable._meta.pagination_param, None)
# instances, self._has_more = api.nova.server_list(
# self.request,
# search_opts={'marker': marker, 'paginate': True})
self._has_more = True
tables.VNFManagerItemList.clear_list()
vnfs = api.tacker.vnf_list(self.request)
if len(vnfs) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for vnf in vnfs:
try:
vnf_services_str = vnf['attributes']['service_type']
@ -99,10 +100,16 @@ class VNFEventsTab(tabs.TableTab):
def get_events_data(self):
try:
self._has_more = True
utils.EventItemList.clear_list()
events = api.tacker.events_list(self.request,
self.tab_group.kwargs['vnf_id'])
if len(events) > horizon_utils.functions.get_page_size(
self.request):
self._has_more = True
else:
self._has_more = False
for event in events:
evt_obj = utils.EventItem(
event['id'], event['resource_state'],