horizon/openstack_dashboard/dashboards/admin/aggregates/panel.py
David Lyle 0932c81584 Potential 500 pages on allowed methods removed
The VPN, Firewall and Loadbalancers panels all have checks to see if the
appropriate service is enabled. This call requires a neutron API call
that is not protected in a try/except block. If there is a problem with
the neutron service, on login, the user encounters the 500 page and is
unable to do anything in Horizon.

The same is true of checking enabled extensions in the Aggregates panel.

The desired experience is the user should still be able to log in and
perform actions unrelated to those misconfigured/down services.

Closes-Bug: #1406329
Change-Id: I8b0eae53c1b8c9a8bc9376e6d813dd6d2bea0e9b
2014-12-29 10:53:49 -07:00

45 lines
1.6 KiB
Python

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import logging
from django.utils.translation import ugettext_lazy as _
import horizon
from openstack_dashboard.api import nova
from openstack_dashboard.dashboards.admin import dashboard
LOG = logging.getLogger(__name__)
class Aggregates(horizon.Panel):
name = _("Host Aggregates")
slug = 'aggregates'
permissions = ('openstack.services.compute',)
def allowed(self, context):
# extend basic permission-based check with a check to see whether
# the Aggregates extension is even enabled in nova
try:
if not nova.extension_supported('Aggregates', context['request']):
return False
except Exception:
LOG.error("Call to list supported extensions failed. This is "
"likely due to a problem communicating with the Nova "
"endpoint. Host Aggregates panel will not be displayed.")
return False
return super(Aggregates, self).allowed(context)
dashboard.Admin.register(Aggregates)