vmware: find_vmdk_file with trailing / (#55957)

With the example, the `file_result.folderPath` of the file
does not have any trailing '/'. `target_folder_path` is correctly
generated and equal: `[nfs_1] images`.
This commit is contained in:
Gonéri Le Bouder 2019-05-10 02:19:04 -04:00 committed by Abhijeet Kasurde
parent d55c0cf8dc
commit 7a02c40bbc

View file

@ -1276,11 +1276,14 @@ class PyVmomi(object):
if not changed:
self.module.fail_json(msg="No valid disk vmdk image found for path %s" % vmdk_path)
target_folder_path = datastore_name_sq + " " + vmdk_folder + '/'
target_folder_paths = [
datastore_name_sq + " " + vmdk_folder + '/',
datastore_name_sq + " " + vmdk_folder,
]
for file_result in search_res.info.result:
for f in getattr(file_result, 'file'):
if f.path == vmdk_filename and file_result.folderPath == target_folder_path:
if f.path == vmdk_filename and file_result.folderPath in target_folder_paths:
return f
self.module.fail_json(msg="No vmdk file found for path specified [%s]" % vmdk_path)