mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 5147: implemented the logic to ensure that the volume creation is blocked when all sp's are in maintenance (or any of the status != UP)
This commit is contained in:
parent
f74d4f89df
commit
4682b25cb5
@ -2200,4 +2200,5 @@ public interface ManagementServer {
|
|||||||
VolumeVO findVolumeByInstanceAndDeviceId(long instanceId, long deviceId);
|
VolumeVO findVolumeByInstanceAndDeviceId(long instanceId, long deviceId);
|
||||||
VolumeVO getRootVolume(Long instanceId);
|
VolumeVO getRootVolume(Long instanceId);
|
||||||
long getPsMaintenanceCount(long podId);
|
long getPsMaintenanceCount(long podId);
|
||||||
|
boolean isPoolUp(long instanceId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -79,6 +79,9 @@ public class StartVMCmd extends BaseCmd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!getManagementServer().isPoolUp(vmId)){
|
||||||
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"Storage pool for this vm is under maintenance");
|
||||||
|
}
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
userId = Long.valueOf(1);
|
userId = Long.valueOf(1);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1762,11 +1762,22 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
|
|
||||||
// Check that there is a shared primary storage pool in the specified zone
|
// Check that there is a shared primary storage pool in the specified zone
|
||||||
List<StoragePoolVO> storagePools = _poolDao.listByDataCenterId(zoneId);
|
List<StoragePoolVO> storagePools = _poolDao.listByDataCenterId(zoneId);
|
||||||
|
|
||||||
boolean sharedPoolExists = false;
|
boolean sharedPoolExists = false;
|
||||||
|
boolean readyPoolExists = false;
|
||||||
for (StoragePoolVO storagePool : storagePools) {
|
for (StoragePoolVO storagePool : storagePools) {
|
||||||
if (storagePool.isShared()) {
|
if (storagePool.isShared()) {
|
||||||
sharedPoolExists = true;
|
sharedPoolExists = true;
|
||||||
}
|
}
|
||||||
|
//check if there are any pools in the UP state
|
||||||
|
//if not, throw an error
|
||||||
|
if(storagePool.getStatus().equals(Status.Up)){
|
||||||
|
readyPoolExists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!readyPoolExists){
|
||||||
|
throw new InternalErrorException("There are no ready pools for volume creation");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that there is at least one host in the specified zone
|
// Check that there is at least one host in the specified zone
|
||||||
@ -8729,5 +8740,21 @@ public class ManagementServerImpl implements ManagementServer {
|
|||||||
else
|
else
|
||||||
return poolsInMaintenance.size();
|
return poolsInMaintenance.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isPoolUp(long instanceId){
|
||||||
|
VolumeVO rootVolume = _volumeDao.findByInstance(instanceId).get(0);
|
||||||
|
|
||||||
|
if(rootVolume!=null){
|
||||||
|
Status poolStatus = _poolDao.findById(rootVolume.getPoolId()).getStatus();
|
||||||
|
|
||||||
|
if(!poolStatus.equals(Status.Up))
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user