CLOUDSTACK-7201. Before initating out live volume migration to a pool check that if the

destination pool is a cluster wide pool, it should be in the same cluster as the vm to
which the volume is attached.
This commit is contained in:
Devdeep Singh 2014-07-30 12:02:43 +05:30
parent ec10e8db27
commit fc14fe1132
1 changed files with 10 additions and 0 deletions

View File

@ -1669,6 +1669,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
boolean liveMigrateVolume = false;
Long instanceId = vol.getInstanceId();
Long srcClusterId = null;
VMInstanceVO vm = null;
if (instanceId != null) {
vm = _vmInstanceDao.findById(instanceId);
@ -1686,6 +1687,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
HypervisorCapabilitiesVO capabilities = null;
if (host != null) {
capabilities = _hypervisorCapabilitiesDao.findByHypervisorTypeAndVersion(host.getHypervisorType(), host.getHypervisorVersion());
srcClusterId = host.getClusterId();
}
if (capabilities != null) {
@ -1711,6 +1713,14 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
if (_volumeMgr.volumeOnSharedStoragePool(vol)) {
if (destPool.isLocal()) {
throw new InvalidParameterValueException("Migration of volume from shared to local storage pool is not supported");
} else {
// If the volume is attached to a running vm and the volume is on a shared storage pool, check
// to make sure that the destination storage pool is in the same cluster as the vm.
if (liveMigrateVolume && destPool.getClusterId() != null && srcClusterId != null) {
if (!srcClusterId.equals(destPool.getClusterId())) {
throw new InvalidParameterValueException("Cannot migrate a volume of a virtual machine to a storage pool in a different cluster");
}
}
}
} else {
throw new InvalidParameterValueException("Migration of volume from local storage pool is not supported");