Skip to content

Commit 8ef9481

Browse files
CLOUDSTACK-9682: Block VM migration to a storage which is in maintainenece mode. If
the destination pool is in maintenance mode do not allow a volume to be migrated to the storage pool. Fixed it for volume migration and vm migration with volume.
1 parent 9513053 commit 8ef9481

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

server/src/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,9 @@ public Volume migrateVolume(MigrateVolumeCmd cmd) {
19171917
StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
19181918
if (destPool == null) {
19191919
throw new InvalidParameterValueException("Failed to find the destination storage pool: " + storagePoolId);
1920+
} else if (destPool.isInMaintenance()) {
1921+
throw new InvalidParameterValueException("Cannot migrate volume " + vol + "to the destination storage pool " + destPool.getName() +
1922+
" as the storage pool is in maintenance mode.");
19201923
}
19211924

19221925
if (_volumeMgr.volumeOnSharedStoragePool(vol)) {

server/src/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4983,6 +4983,9 @@ public VirtualMachine migrateVirtualMachineWithVolume(Long vmId, Host destinatio
49834983
throw new InvalidParameterValueException("There is no volume present with the given id " + entry.getKey());
49844984
} else if (pool == null) {
49854985
throw new InvalidParameterValueException("There is no storage pool present with the given id " + entry.getValue());
4986+
} else if (pool.isInMaintenance()) {
4987+
throw new InvalidParameterValueException("Cannot migrate volume " + volume + "to the destination storage pool " + pool.getName() +
4988+
" as the storage pool is in maintenance mode.");
49864989
} else {
49874990
// Verify the volume given belongs to the vm.
49884991
if (!vmVolumes.contains(volume)) {

0 commit comments

Comments
 (0)