VMware: Detect SDRS for datastore cluster (#35644)
This fix adds a fallback mechanism where Storage Datacluster is not enabled with SDRS. If user has Storage Datacluster without SDRS then we will not get any datastore recommendation. This will fallback to normal datastore selection method. Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
f30a08d049
commit
4ac92c97a3
1 changed files with 26 additions and 13 deletions
|
@ -1303,6 +1303,10 @@ class PyVmomiHelper(PyVmomi):
|
|||
"""
|
||||
if datastore_cluster_obj is None:
|
||||
return None
|
||||
# Check if Datastore Cluster provided by user is SDRS ready
|
||||
sdrs_status = datastore_cluster_obj.podStorageDrsEntry.storageDrsConfig.podConfig.enabled
|
||||
if sdrs_status:
|
||||
# We can get storage recommendation only if SDRS is enabled on given datastorage cluster
|
||||
pod_sel_spec = vim.storageDrs.PodSelectionSpec()
|
||||
pod_sel_spec.storagePod = datastore_cluster_obj
|
||||
storage_spec = vim.storageDrs.StoragePlacementSpec()
|
||||
|
@ -1312,11 +1316,20 @@ class PyVmomiHelper(PyVmomi):
|
|||
try:
|
||||
rec = self.content.storageResourceManager.RecommendDatastores(storageSpec=storage_spec)
|
||||
rec_action = rec.recommendations[0].action[0]
|
||||
real_datastore_name = rec_action.destination.name
|
||||
return rec_action.destination.name
|
||||
except Exception as e:
|
||||
# There is some error so we fall back to general workflow
|
||||
pass
|
||||
datastore = None
|
||||
datastore_freespace = 0
|
||||
for ds in datastore_cluster_obj.childEntity:
|
||||
if isinstance(ds, vim.Datastore) and ds.summary.freeSpace > datastore_freespace:
|
||||
# If datastore field is provided, filter destination datastores
|
||||
datastore = ds
|
||||
datastore_freespace = ds.summary.freeSpace
|
||||
if datastore:
|
||||
return datastore.name
|
||||
return None
|
||||
return real_datastore_name
|
||||
|
||||
def select_datastore(self, vm_obj=None):
|
||||
datastore = None
|
||||
|
|
Loading…
Reference in a new issue