bug 12245: Added config parameters custom.diskoffering.size.min, custom.diskoffering.size.max. Added check while adding volumes with custom offering.

status 12245: resolved fixed
reviewed-by: Nitin
This commit is contained in:
kishan 2011-12-13 15:04:01 +05:30
parent 353bc396e3
commit bc32e0e60c
3 changed files with 23 additions and 5 deletions

View File

@ -327,8 +327,10 @@ public enum Config {
ProjectSMTPUsername("Project Defaults", ManagementServer.class, String.class, "project.smtp.username", null, "Username for SMTP authentication (applies only if project.smtp.useAuth is true)", null),
DefaultExternalLoadBalancerCapacity("Advanced", ManagementServer.class, String.class, "external.lb.default.capacity", "50", "default number of networks permitted per external load balancer device", null),
DefaultExternalFirewallCapacity("Advanced", ManagementServer.class, String.class, "external.firewall.default.capacity", "50", "default number of networks permitted per external load firewall device", null);
DefaultExternalFirewallCapacity("Advanced", ManagementServer.class, String.class, "external.firewall.default.capacity", "50", "default number of networks permitted per external load firewall device", null),
CustomDiskOfferingMinSize("Advanced", ManagementServer.class, Integer.class, "custom.diskoffering.size.min", "1", "Minimum size in GB for custom disk offering", null),
CustomDiskOfferingMaxSize("Advanced", ManagementServer.class, Integer.class, "custom.diskoffering.size.max", "1024", "Maximum size in GB for custom disk offering", null);
private final String _category;
private final Class<?> _componentClass;
private final Class<?> _type;

View File

@ -320,7 +320,9 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
private long _maxVolumeSizeInGb;
private long _serverId;
private StateMachine2<Volume.State, Volume.Event, Volume> _volStateMachine;
private int _customDiskOfferingMinSize = 1;
private int _customDiskOfferingMaxSize = 1024;
public boolean share(VMInstanceVO vm, List<VolumeVO> vols, HostVO host, boolean cancelPreviousShare) throws StorageUnavailableException {
@ -883,6 +885,12 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
String maxVolumeSizeInGbString = configDao.getValue("storage.max.volume.size");
_maxVolumeSizeInGb = NumbersUtil.parseLong(maxVolumeSizeInGbString, 2000);
String _customDiskOfferingMinSizeStr = configDao.getValue(Config.CustomDiskOfferingMinSize.toString());
_customDiskOfferingMinSize = NumbersUtil.parseInt(_customDiskOfferingMinSizeStr, Integer.parseInt(Config.CustomDiskOfferingMinSize.getDefaultValue()));
String _customDiskOfferingMaxSizeStr = configDao.getValue(Config.CustomDiskOfferingMaxSize.toString());
_customDiskOfferingMaxSize = NumbersUtil.parseInt(_customDiskOfferingMaxSizeStr, Integer.parseInt(Config.CustomDiskOfferingMaxSize.getDefaultValue()));
HostTemplateStatesSearch = _vmTemplateHostDao.createSearchBuilder();
HostTemplateStatesSearch.and("id", HostTemplateStatesSearch.entity().getTemplateId(), SearchCriteria.Op.EQ);
HostTemplateStatesSearch.and("state", HostTemplateStatesSearch.entity().getDownloadState(), SearchCriteria.Op.EQ);
@ -1625,6 +1633,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
diskOfferingId = cmd.getDiskOfferingId();
size = cmd.getSize();
Long sizeInGB = size;
if ( size != null ) {
if ( size > 0 ) {
size = size * 1024 * 1024 * 1024; // user specify size in GB
@ -1641,8 +1650,13 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
throw new InvalidParameterValueException("Please specify a valid disk offering.");
}
if ((diskOffering.isCustomized() && size == null)) {
throw new InvalidParameterValueException("This disk offering requires a custom size specified");
if (diskOffering.isCustomized()) {
if(size == null){
throw new InvalidParameterValueException("This disk offering requires a custom size specified");
}
if((sizeInGB < _customDiskOfferingMinSize) || (sizeInGB > _customDiskOfferingMaxSize)){
throw new InvalidParameterValueException("Volume size: "+sizeInGB+"GB is out of allowed range. Max: "+_customDiskOfferingMaxSize+" Min:"+_customDiskOfferingMinSize);
}
}
if (!diskOffering.isCustomized() && size != null) {

View File

@ -112,6 +112,8 @@ INSERT IGNORE INTO configuration VALUES ('Alert', 'DEFAULT', 'management-server'
INSERT IGNORE INTO configuration VALUES ('Alert', 'DEFAULT', 'management-server', 'cluster.localStorage.capacity.notificationthreshold' , .75, 'Percentage (as a value between 0 and 1) of Direct Network Public Ip Utilization above which alerts will be sent about low number of direct network public ips.');
INSERT IGNORE INTO configuration VALUES ('Alert', 'DEFAULT', 'management-server', 'zone.directnetwork.publicip.capacity.notificationthreshold' , .75, 'Percentage (as a value between 0 and 1) of Direct Network Public Ip Utilization above which alerts will be sent about low number of direct network public ips.');
INSERT IGNORE INTO configuration VALUES ('Alert', 'DEFAULT', 'management-server', 'zone.secstorage.capacity.notificationthreshold' , .75, 'Percentage (as a value between 0 and 1) of secondary storage utilization above which alerts will be sent about low storage available.');
INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-server', 'custom.diskoffering.size.min', '1', 'Minimum size in GB for custom disk offering');
INSERT IGNORE INTO configuration VALUES ('Advanced', 'DEFAULT', 'management-server', 'custom.diskoffering.size.max', '1024', 'Maximum size in GB for custom disk offering');
update configuration set name = 'cluster.storage.allocated.capacity.notificationthreshold' , category = 'Alert' where name = 'storage.allocated.capacity.threshold' ;
update configuration set name = 'cluster.storage.capacity.notificationthreshold' , category = 'Alert' where name = 'storage.capacity.threshold' ;