mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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:
parent
ca13586331
commit
2aafc39f3d
@ -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,6 +251,7 @@ 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);
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user