Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use re.search for more flexibility in selecting a datastore #1793

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/1793-autoselect_datastore-use-regex.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- autoselect_datastore-use-regex - when using autoselect_datastore, use re.search() to match the datastore instead of substring .find()
2 changes: 1 addition & 1 deletion plugins/modules/vmware_guest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2758,7 +2758,7 @@ def select_datastore(self, vm_obj=None):

if (ds.summary.freeSpace > datastore_freespace) or (ds.summary.freeSpace == datastore_freespace and not datastore):
# If datastore field is provided, filter destination datastores
if self.params['disk'][0]['datastore'] and ds.name.find(self.params['disk'][0]['datastore']) < 0:
if self.params['disk'][0]['datastore'] and not re.search(self.params['disk'][0]['datastore'], ds.name):
continue

datastore = ds
Expand Down