summaryrefslogtreecommitdiff
path: root/oslo_vmware/api.py
diff options
context:
space:
mode:
authorVipin Balachandran <vbala@vmware.com>2015-04-23 02:58:41 -0700
committerVipin Balachandran <vbala@vmware.com>2015-06-19 17:58:18 +0530
commit5cb43a9bb787b207004716e54ef26da04c610672 (patch)
tree808f1f51fc9e20d58d1e637805c7c2fb7b5cc6a1 /oslo_vmware/api.py
parent084f5475839a9742af74c24a8a2d6d5cf60f1da8 (diff)
downloadoslo-vmware-5cb43a9bb787b207004716e54ef26da04c610672.tar.gz
Raise VimFaultException for unknown faults
Currently VMwareDriverException is raised for unknown VIM faults. Sometimes clients may need to handle such faults. Therefore it is better if we throw VimFaultException with the fault_list set to the relevant VIM fault class name. Change-Id: I97d93ceaa82514d029fff87f1c5ad942895d8940
Diffstat (limited to 'oslo_vmware/api.py')
-rw-r--r--oslo_vmware/api.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/oslo_vmware/api.py b/oslo_vmware/api.py
index 58c3e8d..39a37c9 100644
--- a/oslo_vmware/api.py
+++ b/oslo_vmware/api.py
@@ -321,8 +321,9 @@ class VMwareAPISession(object):
LOG.debug("Fault list: %s", excep.fault_list)
fault = excep.fault_list[0]
clazz = exceptions.get_fault_class(fault)
- raise clazz(six.text_type(excep),
- details=excep.details)
+ if clazz:
+ raise clazz(six.text_type(excep),
+ details=excep.details)
raise
except exceptions.VimConnectionException:
@@ -414,7 +415,12 @@ class VMwareAPISession(object):
error_msg = six.text_type(task_info.error.localizedMessage)
error = task_info.error
name = error.fault.__class__.__name__
- task_ex = exceptions.get_fault_class(name)(error_msg)
+ fault_class = exceptions.get_fault_class(name)
+ if fault_class:
+ task_ex = fault_class(error_msg)
+ else:
+ task_ex = exceptions.VimFaultException([name],
+ error_msg)
raise task_ex
def wait_for_lease_ready(self, lease):