bug 7362: we were missing the size validation check, when we create a volume from disk offering (the storage.max.volume.size param wasn't being used for validation). Fixed the same, made the validation method name more generic to be applicable to all validations, and changed the param description to denote GB as the unit

status 7362: resolved fixed
This commit is contained in:
abhishek 2010-11-29 17:21:30 -08:00
parent 8157294597
commit 0273872b34
2 changed files with 8 additions and 4 deletions

View File

@ -48,7 +48,7 @@ public enum Config {
StorageOverprovisioningFactor("Storage", StoragePoolAllocator.class, String.class, "storage.overprovisioning.factor", "2", "Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", null),
StorageStatsInterval("Storage", ManagementServer.class, String.class, "storage.stats.interval", "60000", "The interval in milliseconds when storage stats (per host) are retrieved from agents.", null),
MaxVolumeSize("Storage", ManagementServer.class, Integer.class, "storage.max.volume.size", "2000", "The maximum size for a volume.", null),
MaxVolumeSize("Storage", ManagementServer.class, Integer.class, "storage.max.volume.size", "2000", "The maximum size for a volume in GB.", null),
TotalRetries("Storage", AgentManager.class, Integer.class, "total.retries", "4", "The number of times each command sent to a host should be retried in case of failure.", null),
// Network

View File

@ -1726,7 +1726,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
if ((diskOfferingId == null) && (size == null)) {
throw new InvalidParameterValueException("Missing parameter(s),either a positive volume size or a valid disk offering id must be specified.");
} else if ((diskOfferingId == null) && (size != null)) {
boolean ok = validateCustomVolumeSizeRange(size);
boolean ok = validateVolumeSizeRange(size);
if (!ok) {
throw new InvalidParameterValueException("Invalid size for custom volume creation: " + size);
@ -1742,10 +1742,14 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
throw new InvalidParameterValueException("Please specify a valid disk offering.");
}
if(!validateVolumeSizeRange(diskOffering.getDiskSize()/1024)){//convert size from mb to gb for validation
throw new InvalidParameterValueException("Invalid size for custom volume creation: " + size+" ,max volume size is:"+_maxVolumeSizeInGb);
}
if(diskOffering.getDiskSize() > 0)
size = (diskOffering.getDiskSize()*1024*1024);//the disk offering size is in MB, which needs to be converted into bytes
else{
if(!validateCustomVolumeSizeRange(size)){
if(!validateVolumeSizeRange(size)){
throw new InvalidParameterValueException("Invalid size for custom volume creation: " + size+" ,max volume size is:"+_maxVolumeSizeInGb);
}
size = (size*1024*1024*1024);//custom size entered is in GB, to be converted to bytes
@ -2618,7 +2622,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
private boolean validateCustomVolumeSizeRange(long size) throws InvalidParameterValueException {
private boolean validateVolumeSizeRange(long size) throws InvalidParameterValueException {
if (size<0 || (size>0 && size < 1)) {
throw new InvalidParameterValueException("Please specify a size of at least 1 Gb.");
} else if (size > _maxVolumeSizeInGb) {