summaryrefslogtreecommitdiff
path: root/heat/rpc
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-03-29 13:46:53 +0000
committerGerrit Code Review <review@openstack.org>2017-03-29 13:46:53 +0000
commit48ef79c5f7c990255d0312d3c867ace44441d645 (patch)
treef5d2f2dcfea80bbb3bb89a2e39efff1a0ee567fa /heat/rpc
parent73e07966af729feb9a960afbfef40d736e26b398 (diff)
parente2b614c52971aff52a02064eff0d2e591393fa23 (diff)
downloadheat-48ef79c5f7c990255d0312d3c867ace44441d645.tar.gz
Merge "Use exception_filter in RPC client"
Diffstat (limited to 'heat/rpc')
-rw-r--r--heat/rpc/client.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/heat/rpc/client.py b/heat/rpc/client.py
index 4a0f3b348..d5b4b677b 100644
--- a/heat/rpc/client.py
+++ b/heat/rpc/client.py
@@ -15,6 +15,9 @@
"""Client side of the heat engine RPC API."""
+import warnings
+
+from oslo_utils import excutils
from oslo_utils import reflection
from heat.common import messaging
@@ -100,14 +103,26 @@ class EngineClient(object):
error_name = reflection.get_class_name(error, fully_qualified=False)
return error_name.split('_Remote')[0]
+ def ignore_error_by_name(self, name):
+ """Returns a context manager that filters exceptions with a given name.
+
+ :param name: Name to compare the local exception name to.
+ """
+ def error_name_matches(err):
+ return self.local_error_name(err) == name
+
+ return excutils.exception_filter(error_name_matches)
+
def ignore_error_named(self, error, name):
"""Raises the error unless its local name matches the supplied name.
:param error: Remote raised error to derive the local name from.
:param name: Name to compare local name to.
"""
- if self.local_error_name(error) != name:
- raise error
+ warnings.warn("Use ignore_error_by_name() to get a context manager "
+ "instead.",
+ DeprecationWarning)
+ return self.ignore_error_by_name(name)(error)
def identify_stack(self, ctxt, stack_name):
"""Returns the full stack identifier for a single, live stack.