mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix changeOfferingForVolume API to consider storage type in the disk offering (#6377)
This commit is contained in:
parent
ea37d757d3
commit
57ecdf9ea6
@ -405,7 +405,7 @@ public interface ManagementService {
|
||||
*/
|
||||
Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolume(Long volumeId);
|
||||
|
||||
Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolumeInternal(Long volumeId, Long newDiskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, boolean keepSourceStoragePool);
|
||||
Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolumeInternal(Long volumeId, Long newDiskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, boolean keepSourceStoragePool, boolean bypassStorageTypeCheck);
|
||||
|
||||
String[] listEventTypes();
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ public class ChangeOfferingForVolumeCmd extends BaseAsyncCmd implements UserCmd
|
||||
}
|
||||
|
||||
public boolean getAutoMigrate() {
|
||||
return autoMigrate == null ? true : autoMigrate;
|
||||
return autoMigrate == null ? false : autoMigrate;
|
||||
}
|
||||
|
||||
public boolean isShrinkOk() {
|
||||
|
||||
@ -1526,7 +1526,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
@Override
|
||||
public Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolume(final Long volumeId) {
|
||||
|
||||
Pair<List<? extends StoragePool>, List<? extends StoragePool>> allPoolsAndSuitablePoolsPair = listStoragePoolsForMigrationOfVolumeInternal(volumeId, null, null, null, null, false);
|
||||
Pair<List<? extends StoragePool>, List<? extends StoragePool>> allPoolsAndSuitablePoolsPair = listStoragePoolsForMigrationOfVolumeInternal(volumeId, null, null, null, null, false, true);
|
||||
List<? extends StoragePool> allPools = allPoolsAndSuitablePoolsPair.first();
|
||||
List<? extends StoragePool> suitablePools = allPoolsAndSuitablePoolsPair.second();
|
||||
List<StoragePool> avoidPools = new ArrayList<>();
|
||||
@ -1542,7 +1542,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
return new Pair<List<? extends StoragePool>, List<? extends StoragePool>>(allPools, suitablePools);
|
||||
}
|
||||
|
||||
public Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolumeInternal(final Long volumeId, Long newDiskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, boolean keepSourceStoragePool) {
|
||||
public Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolumeInternal(final Long volumeId, Long newDiskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, boolean keepSourceStoragePool, boolean bypassStorageTypeCheck) {
|
||||
final Account caller = getCaller();
|
||||
if (!_accountMgr.isRootAdmin(caller.getId())) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
@ -1623,7 +1623,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
}
|
||||
if (vm != null) {
|
||||
suitablePools = findAllSuitableStoragePoolsForVm(volume, diskOfferingId, newSize, newMinIops, newMaxIops, vm, vmHost, avoid,
|
||||
CollectionUtils.isNotEmpty(clusters) ? clusters.get(0) : null, hypervisorType);
|
||||
CollectionUtils.isNotEmpty(clusters) ? clusters.get(0) : null, hypervisorType, bypassStorageTypeCheck);
|
||||
} else {
|
||||
suitablePools = findAllSuitableStoragePoolsForDetachedVolume(volume, diskOfferingId, allPools);
|
||||
}
|
||||
@ -1714,7 +1714,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
*
|
||||
* Side note: the idea behind this method is to provide power for administrators of manually overriding deployments defined by CloudStack.
|
||||
*/
|
||||
private List<StoragePool> findAllSuitableStoragePoolsForVm(final VolumeVO volume, Long diskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, VMInstanceVO vm, Host vmHost, ExcludeList avoid, Cluster srcCluster, HypervisorType hypervisorType) {
|
||||
private List<StoragePool> findAllSuitableStoragePoolsForVm(final VolumeVO volume, Long diskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, VMInstanceVO vm, Host vmHost, ExcludeList avoid, Cluster srcCluster, HypervisorType hypervisorType, boolean bypassStorageTypeCheck) {
|
||||
List<StoragePool> suitablePools = new ArrayList<>();
|
||||
Long clusterId = null;
|
||||
Long podId = null;
|
||||
@ -1736,7 +1736,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
}
|
||||
|
||||
for (StoragePoolAllocator allocator : _storagePoolAllocators) {
|
||||
List<StoragePool> pools = allocator.allocateToPool(diskProfile, profile, plan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL, true);
|
||||
List<StoragePool> pools = allocator.allocateToPool(diskProfile, profile, plan, avoid, StoragePoolAllocator.RETURN_UPTO_ALL, bypassStorageTypeCheck);
|
||||
if (CollectionUtils.isEmpty(pools)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1765,7 +1765,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
|
||||
StoragePoolVO existingStoragePool = _storagePoolDao.findById(volume.getPoolId());
|
||||
|
||||
Pair<List<? extends StoragePool>, List<? extends StoragePool>> poolsPair = managementService.listStoragePoolsForMigrationOfVolumeInternal(volume.getId(), newDiskOffering.getId(), newSize, newMinIops, newMaxIops, true);
|
||||
Pair<List<? extends StoragePool>, List<? extends StoragePool>> poolsPair = managementService.listStoragePoolsForMigrationOfVolumeInternal(volume.getId(), newDiskOffering.getId(), newSize, newMinIops, newMaxIops, true, false);
|
||||
List<? extends StoragePool> suitableStoragePools = poolsPair.second();
|
||||
|
||||
if (!suitableStoragePools.stream().anyMatch(p -> (p.getId() == existingStoragePool.getId()))) {
|
||||
|
||||
@ -794,7 +794,7 @@ public class UnmanagedVMsManagerImpl implements UnmanagedVMsManager {
|
||||
continue;
|
||||
}
|
||||
LOGGER.debug(String.format("Volume %s needs to be migrated", volumeVO.getUuid()));
|
||||
Pair<List<? extends StoragePool>, List<? extends StoragePool>> poolsPair = managementService.listStoragePoolsForMigrationOfVolumeInternal(profile.getVolumeId(), null, null, null, null, false);
|
||||
Pair<List<? extends StoragePool>, List<? extends StoragePool>> poolsPair = managementService.listStoragePoolsForMigrationOfVolumeInternal(profile.getVolumeId(), null, null, null, null, false, true);
|
||||
if (CollectionUtils.isEmpty(poolsPair.first()) && CollectionUtils.isEmpty(poolsPair.second())) {
|
||||
cleanupFailedImportVM(vm);
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("VM import failed for unmanaged vm: %s during volume ID: %s migration as no suitable pool(s) found", userVm.getInstanceName(), volumeVO.getUuid()));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user