Remove __del__ usage in vmwareapi driver

The vmwareapi driver uses __del__ in an inappropriate way, which
causes spurious errors to be displayed at inconvenient times. The
python docs clearly detail the caveats of using __del__ (and even
provide a big red warning). This removes the offending code, which
can't work reliably anyway.

Closes-bug: 1262288
Change-Id: I50acb4f1e85650f4c6dffe1a1d25842601be96bf
This commit is contained in:
Dan Smith 2014-02-20 13:03:12 -08:00
parent e0f0f14fb6
commit b28530ce83
3 changed files with 0 additions and 14 deletions

View File

@ -26,15 +26,10 @@ class VMwareVolumeOpsTestCase(test.NoDBTestCase):
def setUp(self):
def fake_del():
return
super(VMwareVolumeOpsTestCase, self).setUp()
vmwareapi_fake.reset()
stubs.set_stubs(self.stubs)
self._session = driver.VMwareAPISession()
self.stubs.Set(self._session, '__del__',
fake_del)
self._volumeops = volumeops.VMwareVolumeOps(self._session)
self.instance = {'name': 'fake_name', 'uuid': 'fake_uuid'}

View File

@ -753,11 +753,6 @@ class VMwareAPISession(object):
time.sleep(delay)
delay = min(2 * delay, 60)
def __del__(self):
"""Logs-out the session."""
if hasattr(self, 'vim') and self.vim:
self.vim.Logout(self.vim.get_service_content().sessionManager)
def _is_vim_object(self, module):
"""Check if the module is a VIM Object instance."""
return isinstance(module, vim.Vim)

View File

@ -87,10 +87,6 @@ class VMwareHTTPFile(object):
except Exception as exc:
LOG.exception(exc)
def __del__(self):
"""Close the file handle on garbage collection."""
self.close()
def _build_vim_cookie_headers(self, vim_cookies):
"""Build ESX host session cookie headers."""
cookie_header = ""