From 31f7fc6bb24995376bb74d7de6866f5bf2b322c8 Mon Sep 17 00:00:00 2001 From: Robin Cernin Date: Mon, 15 Apr 2019 10:22:15 +1000 Subject: [PATCH] Deprecate exceptions.check_message exceptions.handle() is used in most cases consistently. check_message() is a legacy which was introduced when exceptions were not well classified. exceptions.handle() should cover all common error scenarios and there is no role played by check_messages(). Let's clean up its usage and deprecate it for the future removal. Co-Authored-By: Akihiro Motoki Change-Id: I545b6c666d13d39cf5287ccc7c972dc746faf2fb Closes-Bug: #1339885 --- horizon/exceptions.py | 2 ++ openstack_dashboard/dashboards/admin/aggregates/workflows.py | 2 +- openstack_dashboard/dashboards/admin/flavors/workflows.py | 2 +- openstack_dashboard/dashboards/admin/info/tabs.py | 3 --- requirements.txt | 1 + 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/horizon/exceptions.py b/horizon/exceptions.py index 37616c005d..a96c4dfc8b 100644 --- a/horizon/exceptions.py +++ b/horizon/exceptions.py @@ -22,6 +22,7 @@ import sys import six +from debtcollector import removals from django.core.management import color_style from django.utils import encoding from django.utils.translation import ugettext_lazy as _ @@ -193,6 +194,7 @@ def error_color(msg): return color_style().ERROR_OUTPUT(msg) +@removals.remove(message='Use exceptions.handle() instead', version='17.2.0') def check_message(keywords, message): """Checks an exception for given keywords and raises an error if found. diff --git a/openstack_dashboard/dashboards/admin/aggregates/workflows.py b/openstack_dashboard/dashboards/admin/aggregates/workflows.py index 9da82b68d7..fc2e4f6835 100644 --- a/openstack_dashboard/dashboards/admin/aggregates/workflows.py +++ b/openstack_dashboard/dashboards/admin/aggregates/workflows.py @@ -43,7 +43,7 @@ class SetAggregateInfoAction(workflows.Action): aggregates = api.nova.aggregate_details_list(self.request) except Exception: msg = _('Unable to get host aggregate list') - exceptions.check_message(["Connection", "refused"], msg) + exceptions.handle(self.request, msg) raise if aggregates is not None: for aggregate in aggregates: diff --git a/openstack_dashboard/dashboards/admin/flavors/workflows.py b/openstack_dashboard/dashboards/admin/flavors/workflows.py index e98f0ca93c..2d32d33f12 100644 --- a/openstack_dashboard/dashboards/admin/flavors/workflows.py +++ b/openstack_dashboard/dashboards/admin/flavors/workflows.py @@ -85,7 +85,7 @@ class CreateFlavorInfoAction(workflows.Action): except Exception: flavors = [] msg = _('Unable to get flavor list') - exceptions.check_message(["Connection", "refused"], msg) + exceptions.handle(self.request, msg) raise if flavors is not None and name is not None: for flavor in flavors: diff --git a/openstack_dashboard/dashboards/admin/info/tabs.py b/openstack_dashboard/dashboards/admin/info/tabs.py index ed0191d5e2..93d43519b9 100644 --- a/openstack_dashboard/dashboards/admin/info/tabs.py +++ b/openstack_dashboard/dashboards/admin/info/tabs.py @@ -66,7 +66,6 @@ class NovaServicesTab(tabs.TableTab): services = nova.service_list(self.tab_group.request) except Exception: msg = _('Unable to get nova services list.') - exceptions.check_message(["Connection", "refused"], msg) exceptions.handle(self.request, msg) services = [] return services @@ -87,7 +86,6 @@ class CinderServicesTab(tabs.TableTab): services = cinder.service_list(self.tab_group.request) except Exception: msg = _('Unable to get cinder services list.') - exceptions.check_message(["Connection", "refused"], msg) exceptions.handle(self.request, msg) services = [] return services @@ -113,7 +111,6 @@ class NetworkAgentsTab(tabs.TableTab): agents = neutron.agent_list(self.tab_group.request) except Exception: msg = _('Unable to get network agents list.') - exceptions.check_message(["Connection", "refused"], msg) exceptions.handle(self.request, msg) agents = [] return agents diff --git a/requirements.txt b/requirements.txt index 45fa08d335..cdc8bd7ac8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0 # Horizon Core Requirements Babel!=2.4.0,>=2.3.4 # BSD +debtcollector>=1.2.0 # Apache-2.0 Django<2,>=1.11;python_version<'3.0' # BSD Django>=1.11;python_version>='3.0' # BSD django-babel>=0.6.2 # BSD