Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vmware_guest_disk: Avoid using in maintenance DS
Browse files Browse the repository at this point in the history
The get_recommended_datastore from the vmware_guest_disk filters out
datastores using the one with the greater amount of free space.
However, it doesn't check the datastore status (eg. inMaintenance).

When running the task on an SDRS cluster, which have a datastore in
maintenance, and that datastore is the one with the greater amount of
free space, the module fails with a pyvmomi error like:
"This operation is not allowed in the current state of the datastore".

This commit ensure to skip the selection of in-maintenance datastores by
not even checking their size, and exclude them immediately.
jcl-fc committed May 17, 2022
1 parent a4b2923 commit 8cdee3c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions plugins/modules/vmware_guest_disk.py
Original file line number Diff line number Diff line change
@@ -1044,6 +1044,8 @@ def get_recommended_datastore(self, datastore_cluster_obj, disk_spec_obj):
datastore = None
datastore_freespace = 0
for ds in datastore_cluster_obj.childEntity:
if ds.summary.maintenanceMode == "inMaintenance":
continue
if ds.summary.freeSpace > datastore_freespace:
# If datastore field is provided, filter destination datastores
datastore = ds

0 comments on commit 8cdee3c

Please sign in to comment.