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
This commit is contained in:
parent
4a5af84adf
commit
0932c81584
@ -10,6 +10,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
@ -17,6 +19,8 @@ import horizon
|
|||||||
from openstack_dashboard.api import nova
|
from openstack_dashboard.api import nova
|
||||||
from openstack_dashboard.dashboards.admin import dashboard
|
from openstack_dashboard.dashboards.admin import dashboard
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Aggregates(horizon.Panel):
|
class Aggregates(horizon.Panel):
|
||||||
name = _("Host Aggregates")
|
name = _("Host Aggregates")
|
||||||
@ -26,8 +30,14 @@ class Aggregates(horizon.Panel):
|
|||||||
def allowed(self, context):
|
def allowed(self, context):
|
||||||
# extend basic permission-based check with a check to see whether
|
# extend basic permission-based check with a check to see whether
|
||||||
# the Aggregates extension is even enabled in nova
|
# the Aggregates extension is even enabled in nova
|
||||||
|
try:
|
||||||
if not nova.extension_supported('Aggregates', context['request']):
|
if not nova.extension_supported('Aggregates', context['request']):
|
||||||
return False
|
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)
|
return super(Aggregates, self).allowed(context)
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
@ -17,6 +19,8 @@ import horizon
|
|||||||
from openstack_dashboard.api import neutron
|
from openstack_dashboard.api import neutron
|
||||||
from openstack_dashboard.dashboards.project import dashboard
|
from openstack_dashboard.dashboards.project import dashboard
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Firewall(horizon.Panel):
|
class Firewall(horizon.Panel):
|
||||||
name = _("Firewalls")
|
name = _("Firewalls")
|
||||||
@ -27,10 +31,16 @@ class Firewall(horizon.Panel):
|
|||||||
request = context['request']
|
request = context['request']
|
||||||
if not request.user.has_perms(self.permissions):
|
if not request.user.has_perms(self.permissions):
|
||||||
return False
|
return False
|
||||||
|
try:
|
||||||
if not neutron.is_service_enabled(request,
|
if not neutron.is_service_enabled(request,
|
||||||
config_name='enable_firewall',
|
config_name='enable_firewall',
|
||||||
ext_name='fwaas'):
|
ext_name='fwaas'):
|
||||||
return False
|
return False
|
||||||
|
except Exception:
|
||||||
|
LOG.error("Call to list enabled services failed. This is likely "
|
||||||
|
"due to a problem communicating with the Neutron "
|
||||||
|
"endpoint. Firewalls panel will not be displayed.")
|
||||||
|
return False
|
||||||
if not super(Firewall, self).allowed(context):
|
if not super(Firewall, self).allowed(context):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
@ -17,6 +19,8 @@ import horizon
|
|||||||
from openstack_dashboard.api import neutron
|
from openstack_dashboard.api import neutron
|
||||||
from openstack_dashboard.dashboards.project import dashboard
|
from openstack_dashboard.dashboards.project import dashboard
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class LoadBalancer(horizon.Panel):
|
class LoadBalancer(horizon.Panel):
|
||||||
name = _("Load Balancers")
|
name = _("Load Balancers")
|
||||||
@ -27,10 +31,16 @@ class LoadBalancer(horizon.Panel):
|
|||||||
request = context['request']
|
request = context['request']
|
||||||
if not request.user.has_perms(self.permissions):
|
if not request.user.has_perms(self.permissions):
|
||||||
return False
|
return False
|
||||||
|
try:
|
||||||
if not neutron.is_service_enabled(request,
|
if not neutron.is_service_enabled(request,
|
||||||
config_name='enable_lb',
|
config_name='enable_lb',
|
||||||
ext_name='lbaas'):
|
ext_name='lbaas'):
|
||||||
return False
|
return False
|
||||||
|
except Exception:
|
||||||
|
LOG.error("Call to list enabled services failed. This is likely "
|
||||||
|
"due to a problem communicating with the Neutron "
|
||||||
|
"endpoint. Load Balancers panel will not be displayed.")
|
||||||
|
return False
|
||||||
if not super(LoadBalancer, self).allowed(context):
|
if not super(LoadBalancer, self).allowed(context):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
@ -19,6 +21,8 @@ import horizon
|
|||||||
from openstack_dashboard.api import neutron
|
from openstack_dashboard.api import neutron
|
||||||
from openstack_dashboard.dashboards.project import dashboard
|
from openstack_dashboard.dashboards.project import dashboard
|
||||||
|
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class VPN(horizon.Panel):
|
class VPN(horizon.Panel):
|
||||||
name = _("VPN")
|
name = _("VPN")
|
||||||
@ -29,10 +33,16 @@ class VPN(horizon.Panel):
|
|||||||
request = context['request']
|
request = context['request']
|
||||||
if not request.user.has_perms(self.permissions):
|
if not request.user.has_perms(self.permissions):
|
||||||
return False
|
return False
|
||||||
|
try:
|
||||||
if not neutron.is_service_enabled(request,
|
if not neutron.is_service_enabled(request,
|
||||||
config_name='enable_vpn',
|
config_name='enable_vpn',
|
||||||
ext_name='vpnaas'):
|
ext_name='vpnaas'):
|
||||||
return False
|
return False
|
||||||
|
except Exception:
|
||||||
|
LOG.error("Call to list enabled services failed. This is likely "
|
||||||
|
"due to a problem communicating with the Neutron "
|
||||||
|
"endpoint. VPN panel will not be displayed.")
|
||||||
|
return False
|
||||||
if not super(VPN, self).allowed(context):
|
if not super(VPN, self).allowed(context):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
Loading…
Reference in New Issue
Block a user