diff options
author | Radoslav Gerganov <rgerganov@vmware.com> | 2014-09-11 14:56:59 +0300 |
---|---|---|
committer | Radoslav Gerganov <rgerganov@vmware.com> | 2014-09-11 15:08:52 +0300 |
commit | 81ef9d49c887c623b531064bd8fb32ab57e517f0 (patch) | |
tree | 6c1ec79afba1206e6cf2f76fda7bdc83795f55e7 | |
parent | 48847a585757ace607de4ab5f8d8176142a39564 (diff) | |
download | oslo-vmware-81ef9d49c887c623b531064bd8fb32ab57e517f0.tar.gz |
Add 'details' property to VMwareDriverException
The details property of the VimFaultException is very important and we
loose this information when we convert VimFaultException to a specific
subclass of VMwareDriverException. This patch fix this by propagating
the details to VMwareDriverException.
Change-Id: I42a50b60fc74383a2c1d9b907125ff17795ce440
-rw-r--r-- | oslo/vmware/api.py | 3 | ||||
-rw-r--r-- | oslo/vmware/exceptions.py | 3 | ||||
-rw-r--r-- | tests/test_api.py | 1 |
3 files changed, 5 insertions, 2 deletions
diff --git a/oslo/vmware/api.py b/oslo/vmware/api.py index 65fe903..e5edbf9 100644 --- a/oslo/vmware/api.py +++ b/oslo/vmware/api.py @@ -321,7 +321,8 @@ class VMwareAPISession(object): if excep.fault_list: LOG.debug("Fault list: %s", excep.fault_list) fault = excep.fault_list[0] - raise exceptions.get_fault_class(fault)(unicode(excep)) + clazz = exceptions.get_fault_class(fault) + raise clazz(unicode(excep), excep.details) raise except exceptions.VimConnectionException: diff --git a/oslo/vmware/exceptions.py b/oslo/vmware/exceptions.py index 8622c0f..06d0dd6 100644 --- a/oslo/vmware/exceptions.py +++ b/oslo/vmware/exceptions.py @@ -116,8 +116,9 @@ class VMwareDriverException(Exception): """ msg_fmt = _("An unknown exception occurred.") - def __init__(self, message=None, **kwargs): + def __init__(self, message=None, details=None, **kwargs): self.kwargs = kwargs + self.details = details if not message: try: diff --git a/tests/test_api.py b/tests/test_api.py index 6c02051..0fffab8 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -278,6 +278,7 @@ class VMwareAPISessionTest(base.TestCase): fault_list, details_str) self.assertEqual(expected_str, unicode(e)) + self.assertEqual(details, e.details) def test_invoke_api_with_empty_response(self): api_session = self._create_api_session(True) |