Look for load-balancer endpoints in catalog

Load-Blancer tabs should only be enabled when load-balancer endpoint is registered.
When you enable Octavia only on one region and switch to another region which don't have,
It will show you some infinite Error popup : "Error: Unable to retrieve load balancers."

Story 2008853
Task 42372

Change-Id: I1c69f34d70604db0de1e78e8c32716f8744b9e93
This commit is contained in:
Quentin GROLLEAU 2021-04-26 19:27:02 +02:00
parent 7fb4bac2e8
commit 879135b993
2 changed files with 10 additions and 0 deletions

View File

@ -28,6 +28,7 @@ try:
except ImportError:
from os_client_config import config as occ
from openstack_dashboard.api import base
from openstack_dashboard.api import neutron
from openstack_dashboard.api.rest import urls
from openstack_dashboard.api.rest import utils as rest_utils
@ -675,6 +676,10 @@ def add_floating_ip_info(request, loadbalancers):
lb['floating_ip'] = floating_ip
def is_load_balancer_service_enabled(request):
return base.is_service_enabled(request, 'load-balancer')
@urls.register
class LoadBalancers(generic.View):
"""API for load balancers.

View File

@ -13,6 +13,7 @@
# under the License.
from django.utils.translation import ugettext_lazy as _
from octavia_dashboard.api.rest import lbaasv2
import horizon
@ -21,3 +22,7 @@ class NGLoadBalancers(horizon.Panel):
name = _("Load Balancers")
slug = 'load_balancer'
permissions = ('openstack.services.load-balancer',)
def allowed(self, context):
request = context['request']
return lbaasv2.is_load_balancer_service_enabled(request)