Skip to content

Commit

Permalink
vmware: find_vmdk_file with trailing / (ansible#55957)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
goneri authored and Akasurde committed May 10, 2019
1 parent d55c0cf commit 7a02c40
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/ansible/module_utils/vmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -1276,11 +1276,14 @@ def find_vmdk_file(self, datastore_obj, vmdk_fullpath, vmdk_filename, vmdk_folde
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)
Expand Down

0 comments on commit 7a02c40

Please sign in to comment.