mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix findstoragepoolsformigration cmd not to list the parent datastore cluster as suitable storagepool
This commit is contained in:
parent
d4d372a9a4
commit
d48cab75ab
@ -1488,21 +1488,26 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
} else {
|
} else {
|
||||||
suitablePools = allPools;
|
suitablePools = allPools;
|
||||||
}
|
}
|
||||||
abstractDataStoreClustersList((List<StoragePool>) allPools);
|
List<StoragePool> avoidPools = new ArrayList<>();
|
||||||
abstractDataStoreClustersList((List<StoragePool>) suitablePools);
|
if (srcVolumePool.getParent() != 0L) {
|
||||||
|
StoragePool datastoreCluster = _poolDao.findById(srcVolumePool.getParent());
|
||||||
|
avoidPools.add(datastoreCluster);
|
||||||
|
}
|
||||||
|
abstractDataStoreClustersList((List<StoragePool>) allPools, new ArrayList<StoragePool>());
|
||||||
|
abstractDataStoreClustersList((List<StoragePool>) suitablePools, avoidPools);
|
||||||
return new Pair<List<? extends StoragePool>, List<? extends StoragePool>>(allPools, suitablePools);
|
return new Pair<List<? extends StoragePool>, List<? extends StoragePool>>(allPools, suitablePools);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void abstractDataStoreClustersList(List<StoragePool> storagePools) {
|
private void abstractDataStoreClustersList(List<StoragePool> storagePools, List<StoragePool> avoidPools) {
|
||||||
Predicate<StoragePool> childDatastorePredicate = pool -> (pool.getParent() != 0);
|
Predicate<StoragePool> childDatastorePredicate = pool -> (pool.getParent() != 0);
|
||||||
List<StoragePool> childDatastores = storagePools.stream().filter(childDatastorePredicate).collect(Collectors.toList());
|
List<StoragePool> childDatastores = storagePools.stream().filter(childDatastorePredicate).collect(Collectors.toList());
|
||||||
|
storagePools.removeAll(avoidPools);
|
||||||
if (!childDatastores.isEmpty()) {
|
if (!childDatastores.isEmpty()) {
|
||||||
storagePools.removeAll(childDatastores);
|
storagePools.removeAll(childDatastores);
|
||||||
Set<Long> parentStoragePoolIds = childDatastores.stream().map(mo -> mo.getParent()).collect(Collectors.toSet());
|
Set<Long> parentStoragePoolIds = childDatastores.stream().map(mo -> mo.getParent()).collect(Collectors.toSet());
|
||||||
for (Long parentStoragePoolId : parentStoragePoolIds) {
|
for (Long parentStoragePoolId : parentStoragePoolIds) {
|
||||||
StoragePool parentPool = _poolDao.findById(parentStoragePoolId);
|
StoragePool parentPool = _poolDao.findById(parentStoragePoolId);
|
||||||
if (!storagePools.contains(parentPool))
|
if (!storagePools.contains(parentPool) && !avoidPools.contains(parentPool))
|
||||||
storagePools.add(parentPool);
|
storagePools.add(parentPool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user