From 8ef94819dabfc7b027d638473e9454e9f73ac49d Mon Sep 17 00:00:00 2001 From: Anshul Gangwar Date: Mon, 20 Apr 2015 13:13:48 +0530 Subject: [PATCH] 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. --- server/src/com/cloud/storage/VolumeApiServiceImpl.java | 3 +++ server/src/com/cloud/vm/UserVmManagerImpl.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 759c7b440ff..813830e4099 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -1917,6 +1917,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary); if (destPool == null) { throw new InvalidParameterValueException("Failed to find the destination storage pool: " + storagePoolId); + } else if (destPool.isInMaintenance()) { + throw new InvalidParameterValueException("Cannot migrate volume " + vol + "to the destination storage pool " + destPool.getName() + + " as the storage pool is in maintenance mode."); } if (_volumeMgr.volumeOnSharedStoragePool(vol)) { diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index cf586797b5d..b6400fd5fc8 100644 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -4983,6 +4983,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir throw new InvalidParameterValueException("There is no volume present with the given id " + entry.getKey()); } else if (pool == null) { throw new InvalidParameterValueException("There is no storage pool present with the given id " + entry.getValue()); + } else if (pool.isInMaintenance()) { + throw new InvalidParameterValueException("Cannot migrate volume " + volume + "to the destination storage pool " + pool.getName() + + " as the storage pool is in maintenance mode."); } else { // Verify the volume given belongs to the vm. if (!vmVolumes.contains(volume)) {