Revert "Raise VimFaultException for unknown faults"
This reverts commit 1668fef9cabea6a23023aab6b97617b4368b14d6 This is a backwards incompatible change, as we see with the nova driver code that is expecting a VMwareDriverException but is now getting back a VimFaultException because the unit tests in nova were passing an unknown fault class name. Change-Id: I0f8042c6e47f6eb9802e770ffb7d09bdbe57013b Closes-Bug: #1459021
This commit is contained in:
parent
1668fef9ca
commit
8ec7f0fe04
@ -321,8 +321,7 @@ class VMwareAPISession(object):
|
||||
LOG.debug("Fault list: %s", excep.fault_list)
|
||||
fault = excep.fault_list[0]
|
||||
clazz = exceptions.get_fault_class(fault)
|
||||
if clazz:
|
||||
raise clazz(six.text_type(excep), excep.details)
|
||||
raise clazz(six.text_type(excep), excep.details)
|
||||
raise
|
||||
|
||||
except exceptions.VimConnectionException:
|
||||
@ -414,12 +413,7 @@ class VMwareAPISession(object):
|
||||
error_msg = six.text_type(task_info.error.localizedMessage)
|
||||
error = task_info.error
|
||||
name = error.fault.__class__.__name__
|
||||
fault_class = exceptions.get_fault_class(name)
|
||||
if fault_class:
|
||||
task_ex = fault_class(error_msg)
|
||||
else:
|
||||
task_ex = exceptions.VimFaultException([name],
|
||||
error_msg)
|
||||
task_ex = exceptions.get_fault_class(name)(error_msg)
|
||||
raise task_ex
|
||||
|
||||
def wait_for_lease_ready(self, lease):
|
||||
|
@ -254,6 +254,7 @@ def get_fault_class(name):
|
||||
fault_class = _fault_classes_registry.get(name)
|
||||
if not fault_class:
|
||||
LOG.debug('Fault %s not matched.', name)
|
||||
fault_class = VMwareDriverException
|
||||
return fault_class
|
||||
|
||||
|
||||
|
@ -373,19 +373,6 @@ class VMwareAPISessionTest(base.TestCase):
|
||||
userName=api_session._session_username)
|
||||
api_session._create_session.assert_called_once_with()
|
||||
|
||||
def test_invoke_api_with_unknown_fault(self):
|
||||
api_session = self._create_api_session(True)
|
||||
fault_list = ['NotAFile']
|
||||
|
||||
module = mock.Mock()
|
||||
module.api.side_effect = exceptions.VimFaultException(fault_list,
|
||||
'Not a file.')
|
||||
ex = self.assertRaises(exceptions.VimFaultException,
|
||||
api_session.invoke_api,
|
||||
module,
|
||||
'api')
|
||||
self.assertEqual(fault_list, ex.fault_list)
|
||||
|
||||
def test_wait_for_task(self):
|
||||
api_session = self._create_api_session(True)
|
||||
task_info_list = [('queued', 0), ('running', 40), ('success', 100)]
|
||||
@ -426,7 +413,7 @@ class VMwareAPISessionTest(base.TestCase):
|
||||
api_session.invoke_api = mock.Mock(side_effect=invoke_api_side_effect)
|
||||
task = mock.Mock()
|
||||
with mock.patch.object(greenthread, 'sleep'):
|
||||
self.assertRaises(exceptions.VimFaultException,
|
||||
self.assertRaises(exceptions.VMwareDriverException,
|
||||
api_session.wait_for_task,
|
||||
task)
|
||||
api_session.invoke_api.assert_called_with(vim_util,
|
||||
@ -544,8 +531,8 @@ class VMwareAPISessionTest(base.TestCase):
|
||||
|
||||
def test_poll_task_unknown_exception(self):
|
||||
_unknown_exceptions = {
|
||||
'NotAFile': exceptions.VimFaultException,
|
||||
'RuntimeFault': exceptions.VimFaultException
|
||||
'NotAFile': exceptions.VMwareDriverException,
|
||||
'RuntimeFault': exceptions.VMwareDriverException
|
||||
}
|
||||
|
||||
for k, v in six.iteritems(_unknown_exceptions):
|
||||
|
@ -107,4 +107,5 @@ class ExceptionsTest(base.TestCase):
|
||||
self.assertEqual(exceptions.NoDiskSpaceException,
|
||||
exceptions.get_fault_class("NoDiskSpace"))
|
||||
# Test unknown fault.
|
||||
self.assertIsNone(exceptions.get_fault_class("NotAFile"))
|
||||
self.assertEqual(exceptions.VMwareDriverException,
|
||||
exceptions.get_fault_class("NotAFile"))
|
||||
|
@ -412,7 +412,7 @@ class VMwareAPISessionTest(base.TestCase):
|
||||
api_session.invoke_api = mock.Mock(side_effect=invoke_api_side_effect)
|
||||
task = mock.Mock()
|
||||
with mock.patch.object(greenthread, 'sleep'):
|
||||
self.assertRaises(exceptions.VimFaultException,
|
||||
self.assertRaises(exceptions.VMwareDriverException,
|
||||
api_session.wait_for_task,
|
||||
task)
|
||||
api_session.invoke_api.assert_called_with(new_vim_util,
|
||||
@ -526,8 +526,8 @@ class VMwareAPISessionTest(base.TestCase):
|
||||
|
||||
def test_poll_task_unknown_exception(self):
|
||||
_unknown_exceptions = {
|
||||
'NotAFile': exceptions.VimFaultException,
|
||||
'RuntimeFault': exceptions.VimFaultException
|
||||
'NoDiskSpace': exceptions.VMwareDriverException,
|
||||
'RuntimeFault': exceptions.VMwareDriverException
|
||||
}
|
||||
|
||||
for k, v in six.iteritems(_unknown_exceptions):
|
||||
|
Loading…
x
Reference in New Issue
Block a user