diff options
author | Vipin Balachandran <vbala@vmware.com> | 2015-04-23 02:58:41 -0700 |
---|---|---|
committer | Vipin Balachandran <vbala@vmware.com> | 2015-04-30 12:10:29 +0530 |
commit | 1668fef9cabea6a23023aab6b97617b4368b14d6 (patch) | |
tree | e6846ef097302dd4894aa584d60a0a97f0d30f0d /oslo_vmware/api.py | |
parent | c338f19f84a202bf2bd8ca4153a32460688cf6c0 (diff) | |
download | oslo-vmware-1668fef9cabea6a23023aab6b97617b4368b14d6.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: I34f84f3ea3f5f0d6878f1d4438cf25bf22f293fd
Diffstat (limited to 'oslo_vmware/api.py')
-rw-r--r-- | oslo_vmware/api.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/oslo_vmware/api.py b/oslo_vmware/api.py index df68bc9..dabc461 100644 --- a/oslo_vmware/api.py +++ b/oslo_vmware/api.py @@ -321,7 +321,8 @@ 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), excep.details) + if clazz: + raise clazz(six.text_type(excep), excep.details) raise except exceptions.VimConnectionException: @@ -413,7 +414,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): |