Merge "Revert "VMware: fix race for datastore directory existence""

This commit is contained in:
Jenkins
2014-02-25 02:54:45 +00:00
committed by Gerrit Code Review
3 changed files with 3 additions and 23 deletions

View File

@@ -479,18 +479,6 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
self.assertTrue(vmwareapi_fake.get_file(file))
self.assertTrue(vmwareapi_fake.get_file(root))
@mock.patch.object(vmops.VMwareVMOps, '_path_file_exists',
return_value=(False, False))
def test_spawn_with_existing_directory(self, fake_path_file):
# The test will validate that the spawn succeeds when
# base folder already exists.
self.flags(use_linked_clone=True, group='vmware')
vmwareapi_fake._add_file('[%s] vmware_base' % self.ds)
self._create_vm()
info = self.conn.get_info({'uuid': self.uuid,
'node': self.instance_node})
self._check_vm_info(info, power_state.RUNNING)
def test_spawn(self):
self._create_vm()
info = self.conn.get_info({'uuid': self.uuid,

View File

@@ -1153,8 +1153,6 @@ class FakeVim(object):
ds_path = kwargs.get("name")
if _db_content.get("files", None) is None:
raise exception.NoFilesFound()
if get_file(ds_path):
raise error_util.FileAlreadyExistsException()
_db_content["files"].append(ds_path)
def _set_power_state(self, method, vm_ref, pwr_state="poweredOn"):

View File

@@ -1630,19 +1630,13 @@ class VMwareVMOps(object):
then a directory with this name is created at the topmost level of the
DataStore.
"""
LOG.debug(_("Creating directory with path %s"), ds_path)
LOG.debug(_("Creating directory with path %s") % ds_path)
dc_info = self.get_datacenter_ref_and_name(ds_ref)
try:
self._session._call_method(
self._session._get_vim(), "MakeDirectory",
self._session._call_method(self._session._get_vim(), "MakeDirectory",
self._session._get_vim().get_service_content().fileManager,
name=ds_path, datacenter=dc_info.ref,
createParentDirectories=True)
LOG.debug(_("Created directory with path %s"), ds_path)
except error_util.FileAlreadyExistsException:
LOG.debug(_("Multiple processes/threads are trying to create "
"directory %(ds_path)s on %(ds)s."),
{'ds_path': ds_path, 'ds': dc_info.name})
LOG.debug(_("Created directory with path %s") % ds_path)
def _check_if_folder_file_exists(self, ds_ref, ds_name,
folder_name, file_name):