diff --git a/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py b/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py index f48cc2af..f44467ab 100644 --- a/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py +++ b/package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py @@ -524,9 +524,13 @@ def _get_datastore(self, clone_params): [self.vim.StoragePod], name) if datastore: - datastore = sorted(datastore.childEntity, - key=lambda data: data.summary.freeSpace, - reverse=True)[0] + storage_by_freespace = sorted(datastore.childEntity, + key=lambda data: data.summary.freeSpace, + reverse=True) + if len(storage_by_freespace) > 0: + datastore = storage_by_freespace[0] + else: + raise ValueError('There are no available storage devices under the provided cluster "{0}"'.format(clone_params.datastore_name)) if not datastore: raise ValueError('Could not find Datastore: "{0}"'.format(clone_params.datastore_name))