CLOUDSTACK-2957

deployVm API size attribute should be capped by the storage.max.volume.size as it is in createVolume.
This commit is contained in:
Nitin Mehta 2013-06-12 16:57:59 +05:30
parent ca13586331
commit 2aafc39f3d
3 changed files with 11 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import java.util.Map;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.storage.VolumeManager;
import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity; import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity;
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity; import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity; import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
@ -87,6 +88,9 @@ public class CloudOrchestrator implements OrchestrationService {
@Inject @Inject
protected AccountDao _accountDao = null; protected AccountDao _accountDao = null;
@Inject
VolumeManager _volumeMgr;
public CloudOrchestrator() { public CloudOrchestrator() {
} }
@ -200,6 +204,7 @@ public class CloudOrchestrator implements OrchestrationService {
"Disk offering " + diskOffering "Disk offering " + diskOffering
+ " requires size parameter."); + " requires size parameter.");
} }
_volumeMgr.validateVolumeSizeRange(size * 1024 * 1024 * 1024);
} }
dataDiskOfferings.add(new Pair<DiskOfferingVO, Long>(diskOffering, size)); dataDiskOfferings.add(new Pair<DiskOfferingVO, Long>(diskOffering, size));
} }
@ -246,7 +251,8 @@ public class CloudOrchestrator implements OrchestrationService {
throw new InvalidParameterValueException("Disk offering " throw new InvalidParameterValueException("Disk offering "
+ diskOffering + " requires size parameter."); + diskOffering + " requires size parameter.");
} }
} _volumeMgr.validateVolumeSizeRange(size * 1024 * 1024 * 1024);
}
rootDiskOffering.first(diskOffering); rootDiskOffering.first(diskOffering);
rootDiskOffering.second(size); rootDiskOffering.second(size);

View File

@ -109,4 +109,6 @@ public interface VolumeManager extends VolumeApiService {
String getVmNameFromVolumeId(long volumeId); String getVmNameFromVolumeId(long volumeId);
String getStoragePoolOfVolume(long volumeId); String getStoragePoolOfVolume(long volumeId);
boolean validateVolumeSizeRange(long size);
} }

View File

@ -1311,7 +1311,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
return true; return true;
} }
private boolean validateVolumeSizeRange(long size) { @Override
public boolean validateVolumeSizeRange(long size) {
if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) { if (size < 0 || (size > 0 && size < (1024 * 1024 * 1024))) {
throw new InvalidParameterValueException( throw new InvalidParameterValueException(
"Please specify a size of at least 1 Gb."); "Please specify a size of at least 1 Gb.");