bug 6203: incremental fix

This commit is contained in:
abhishek 2010-09-17 15:19:21 -07:00
parent 263bfe13bd
commit a016aa27cd
5 changed files with 27 additions and 13 deletions

View File

@ -1836,8 +1836,9 @@ public interface ManagementServer {
* @param mirrored boolean value of whether or not the offering provides disk mirroring
* @param tags Comma separated string to indicate special tags for the disk offering.
* @return the created disk offering, null if failed to create
* @throws InternalErrorException
*/
DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException;
DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException, InternalErrorException;
/**
* Delete a disk offering

View File

@ -27,6 +27,7 @@ import org.apache.log4j.Logger;
import com.cloud.api.BaseCmd;
import com.cloud.api.ServerApiException;
import com.cloud.domain.DomainVO;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.user.User;
@ -86,7 +87,9 @@ public class CreateDiskOfferingCmd extends BaseCmd {
diskOffering = getManagementServer().createDiskOffering(userId, domainId.longValue(), name, displayText, numGB.intValue(),tags);
} catch (InvalidParameterValueException ex) {
throw new ServerApiException (BaseCmd.VM_INVALID_PARAM_ERROR, ex.getMessage());
}
} catch (InternalErrorException e) {
throw new ServerApiException (BaseCmd.INTERNAL_ERROR, e.getMessage());
}
if (diskOffering == null) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create disk offering");

View File

@ -64,7 +64,7 @@ public class DeleteDiskOfferingCmd extends BaseCmd {
throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find a disk offering with id " + id);
}
if(disk.getName().equals("Private") && disk.getDisplayText().equals("Private Disk")){
if(disk.getDiskSize()==0){
//block deletion of these disks
throw new ServerApiException(BaseCmd.INTERNAL_ERROR,"Cannot delete this diskoffering as it is private");
}

View File

@ -145,7 +145,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Small", "Small Disk, 5 GB", 5, null);
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Medium", "Medium Disk, 20 GB", 20, null);
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Large", "Large Disk, 100 GB", 100, null);
_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Private", "Private Disk", 0, null);
//_configMgr.createDiskOffering(User.UID_SYSTEM, DomainVO.ROOT_DOMAIN, "Private", "Private Disk", 0, null);
//Add default manual snapshot policy
SnapshotPolicyVO snapPolicy = new SnapshotPolicyVO(0L, "00", "GMT", (short)4, 0);

View File

@ -368,7 +368,7 @@ public class ManagementServerImpl implements ManagementServer {
private final int _proxyRamSize;
private final int _ssRamSize;
private final long _maxVolumeSizeInTb;
private final long _maxVolumeSizeInGb;
private final Map<String, Boolean> _availableIdsMap;
private boolean _networkGroupsEnabled = false;
@ -465,9 +465,9 @@ public class ManagementServerImpl implements ManagementServer {
// and set them in the right places
String maxVolumeSizeInTbString = _configs.get("max.volume.size.gb");
long maxVolumeSizeTb = NumbersUtil.parseLong(maxVolumeSizeInTbString, new Long("2093049000000"));
long maxVolumeSizeBytes = NumbersUtil.parseLong(maxVolumeSizeInTbString, new Long("2093049000000"));
_maxVolumeSizeInTb = maxVolumeSizeTb;
_maxVolumeSizeInGb = maxVolumeSizeBytes/1000000000;
_routerRamSize = NumbersUtil.parseInt(_configs.get("router.ram.size"),NetworkManager.DEFAULT_ROUTER_VM_RAMSIZE);
_proxyRamSize = NumbersUtil.parseInt(_configs.get("consoleproxy.ram.size"), ConsoleProxyManager.DEFAULT_PROXY_VM_RAMSIZE);
@ -7091,12 +7091,22 @@ public class ManagementServerImpl implements ManagementServer {
}
@Override
public DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException {
if (numGibibytes!=0 && numGibibytes < 1) {
throw new InvalidParameterValueException("Please specify a disk size of at least 1 Gb.");
} else if (numGibibytes > _maxVolumeSizeInTb) {
throw new InvalidParameterValueException("The maximum size for a disk is " + _maxVolumeSizeInTb + " Gb.");
public DiskOfferingVO createDiskOffering(long userId, long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException, InternalErrorException {
if(numGibibytes!=0 && numGibibytes<1){
throw new InvalidParameterValueException("The minimum disk offering size is 1 GB");
}
if (numGibibytes > _maxVolumeSizeInGb) {
throw new InvalidParameterValueException("The maximum allowed size for a disk is " + _maxVolumeSizeInGb + " Gb.");
}
if(numGibibytes==0){
List<DiskOfferingVO> existingOffering = _diskOfferingDao.findPrivateDiskOffering();
if(existingOffering!=null && existingOffering.size()>0)
throw new InternalErrorException("There already exists a private disk offering");
}
return _configMgr.createDiskOffering(userId, domainId, name, description, numGibibytes, tags);
}
@ -8820,7 +8830,7 @@ public class ManagementServerImpl implements ManagementServer {
public boolean validateCustomVolumeSizeRange(long size) throws InvalidParameterValueException {
if (size<0 || (size>0 && size < 2097152)) {
throw new InvalidParameterValueException("Please specify a size (in bytes) of at least 2 MB or above.");
} else if (size > _maxVolumeSizeInTb) {
} else if (size > (_maxVolumeSizeInGb*1000000000)) {
throw new InvalidParameterValueException("The maximum size allowed is 2 TB");
}