summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-02-08 01:43:58 +0000
committerGerrit Code Review <review@openstack.org>2013-02-08 01:43:58 +0000
commit9d8bc93fe0af5250097ca5fb1002c86df9809b3c (patch)
tree9b4d8e39cc3e825b2117b1088f8b5f6dff43178c /nova/utils.py
parentaa333c7a7cba7f26eb95735ff2eeeefe9f213608 (diff)
parent12fa59dbb2a96d8f07d6247a08709222b359d87a (diff)
downloadnova-9d8bc93fe0af5250097ca5fb1002c86df9809b3c.tar.gz
nova-9d8bc93fe0af5250097ca5fb1002c86df9809b3c.tar.xz
nova-9d8bc93fe0af5250097ca5fb1002c86df9809b3c.zip
Merge "Move floating ip db access to calling side."
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 545cb5dae..7ad810504 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -48,6 +48,7 @@ from nova.openstack.common import cfg
from nova.openstack.common import excutils
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
+from nova.openstack.common.rpc import common as rpc_common
from nova.openstack.common import timeutils
notify_decorator = 'nova.openstack.common.notifier.api.notify_decorator'
@@ -1321,3 +1322,22 @@ def getcallargs(function, *args, **kwargs):
keyed_args[argname] = value
return keyed_args
+
+
+class ExceptionHelper(object):
+ """Class to wrap another and translate the ClientExceptions raised by its
+ function calls to the actual ones"""
+
+ def __init__(self, target):
+ self._target = target
+
+ def __getattr__(self, name):
+ func = getattr(self._target, name)
+
+ @functools.wraps(func)
+ def wrapper(*args, **kwargs):
+ try:
+ return func(*args, **kwargs)
+ except rpc_common.ClientException, e:
+ raise (e._exc_info[1], None, e._exc_info[2])
+ return wrapper