VMware: treat cases when SOAP reply does not have a body
There are cases when the SOAP reply does not return a body (for example UnregisterVM may return this when running the CI). This patch ensures that an exception is not thrown. Change-Id: I394320641c648effd1209345cfd729e975f12aab Closes-bug: #1300788
This commit is contained in:
@@ -165,6 +165,8 @@ class Vim(object):
|
||||
# of the managed object.
|
||||
managed_object = vim_util.get_moref(managed_object,
|
||||
managed_object)
|
||||
if managed_object is None:
|
||||
return
|
||||
request = getattr(self.client.service, attr_name)
|
||||
LOG.debug(_("Invoking %(attr_name)s on %(moref)s."),
|
||||
{'attr_name': attr_name,
|
||||
|
||||
@@ -25,6 +25,7 @@ import suds
|
||||
|
||||
from oslo.vmware import exceptions
|
||||
from oslo.vmware import vim
|
||||
from oslo.vmware import vim_util
|
||||
from tests import base
|
||||
|
||||
|
||||
@@ -231,6 +232,13 @@ class VimTest(base.TestCase):
|
||||
self.assertRaises(exceptions.VimConnectionException,
|
||||
lambda: vim_obj.powerOn(managed_object))
|
||||
|
||||
@mock.patch.object(vim_util, 'get_moref', return_value=None)
|
||||
def test_vim_request_handler_no_value(self, mock_moref):
|
||||
managed_object = 'VirtualMachine'
|
||||
vim_obj = vim.Vim()
|
||||
ret = vim_obj.UnregisterVM(managed_object)
|
||||
self.assertIsNone(ret)
|
||||
|
||||
def _test_vim_request_handler_with_exception(self, message, exception):
|
||||
managed_object = 'VirtualMachine'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user