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:
abhishek 2010-09-10 14:39:39 -07:00
parent f74d4f89df
commit 4682b25cb5
3 changed files with 32 additions and 1 deletions

View File

@ -2200,4 +2200,5 @@ public interface ManagementServer {
VolumeVO findVolumeByInstanceAndDeviceId(long instanceId, long deviceId);
VolumeVO getRootVolume(Long instanceId);
long getPsMaintenanceCount(long podId);
boolean isPoolUp(long instanceId);
}

View File

@ -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) {
userId = Long.valueOf(1);
}

View File

@ -1762,11 +1762,22 @@ public class ManagementServerImpl implements ManagementServer {
// Check that there is a shared primary storage pool in the specified zone
List<StoragePoolVO> storagePools = _poolDao.listByDataCenterId(zoneId);
boolean sharedPoolExists = false;
boolean readyPoolExists = false;
for (StoragePoolVO storagePool : storagePools) {
if (storagePool.isShared()) {
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
@ -8729,5 +8740,21 @@ public class ManagementServerImpl implements ManagementServer {
else
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;
}
}