diff options
| author | Mark McLoughlin <markmc@redhat.com> | 2012-12-05 13:48:18 +0000 |
|---|---|---|
| committer | Mark McLoughlin <markmc@redhat.com> | 2012-12-05 13:48:18 +0000 |
| commit | 670dc3f8844e6fd3bcf9df1195891162a13719fe (patch) | |
| tree | 50741bc3e7d47af21c20ea80c82f9ab3077ca930 | |
| parent | 2f7a7edc41d0e7b663877592aeda14e766a64241 (diff) | |
Allow remote stdlib exceptions to be deserialized
Fixes bug #1086798
Add 'exceptions' to allowed_rpc_exception_modules so that stdlib
exceptions (like NotImplementedError) can be deserialized from a
RemoteError.
Change-Id: I57f40fed2a86cc08fb64b81d648c71cd7db8027c
| -rw-r--r-- | openstack/common/rpc/__init__.py | 1 | ||||
| -rw-r--r-- | tests/unit/rpc/test_common.py | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/openstack/common/rpc/__init__.py b/openstack/common/rpc/__init__.py index f84c493..e11fa16 100644 --- a/openstack/common/rpc/__init__.py +++ b/openstack/common/rpc/__init__.py @@ -50,6 +50,7 @@ rpc_opts = [ default=['openstack.common.exception', 'nova.exception', 'cinder.exception', + 'exceptions', ], help='Modules of exceptions that are permitted to be recreated' 'upon receiving exception data from an rpc call.'), diff --git a/tests/unit/rpc/test_common.py b/tests/unit/rpc/test_common.py index 37d4f25..beba9ac 100644 --- a/tests/unit/rpc/test_common.py +++ b/tests/unit/rpc/test_common.py @@ -84,6 +84,20 @@ class RpcCommonTestCase(test_utils.BaseTestCase): def test_deserialize_remote_exception(self): failure = { + 'class': 'NotImplementedError', + 'module': 'exceptions', + 'message': '', + 'tb': ['raise NotImplementedError'], + } + serialized = jsonutils.dumps(failure) + + after_exc = rpc_common.deserialize_remote_exception(FLAGS, serialized) + self.assertTrue(isinstance(after_exc, NotImplementedError)) + #assure the traceback was added + self.assertTrue('raise NotImplementedError' in unicode(after_exc)) + + def test_deserialize_remote_custom_exception(self): + failure = { 'class': 'OpenstackException', 'module': 'openstack.common.exception', 'message': exception.OpenstackException.message, |
