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:
Gary Kotton
2014-04-01 07:56:29 -07:00
parent c3942d27b2
commit e39196b30b
2 changed files with 10 additions and 0 deletions

View File

@@ -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,

View File

@@ -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'