CLOUDSTACK-9851 travis CI build failure after merge of PR#1953

This commit is contained in:
Sudharma Jain 2017-03-28 17:57:28 +05:30
parent 525c45c1e5
commit 7348f9412a

View File

@ -1433,7 +1433,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
// that supported by hypervisor
if (deviceId == null || deviceId.longValue() != 0) {
List<VolumeVO> existingDataVolumes = _volsDao.findByInstanceAndType(vmId, Volume.Type.DATADISK);
int maxAttachableDataVolumesSupported = getMaxDataVolumesSupported(vm) - 2; //IDs: 0 (ROOT) and 3 (CD-ROM) are reserved
int maxAttachableDataVolumesSupported = getMaxDataVolumesSupported(vm);
if (existingDataVolumes.size() >= maxAttachableDataVolumesSupported) {
throw new InvalidParameterValueException("The specified VM already has the maximum number of data disks (" + maxAttachableDataVolumesSupported + ") attached. Please specify another VM.");
}
@ -2634,11 +2634,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
private Long getDeviceId(UserVmVO vm, Long deviceId) {
// allocate deviceId
int maxDeviceId = getMaxDataVolumesSupported(vm) - 1;
int maxDevices = getMaxDataVolumesSupported(vm) + 2; // add 2 to consider devices root volume and cdrom
int maxDeviceId = maxDevices - 1;
List<VolumeVO> vols = _volsDao.findByInstance(vm.getId());
if (deviceId != null) {
if (deviceId.longValue() <= 0 || deviceId.longValue() > maxDeviceId || deviceId.longValue() == 3) {
throw new RuntimeException("deviceId should be 1,2,4-" + maxDeviceId);
if (deviceId.longValue() < 0 || deviceId.longValue() > maxDeviceId || deviceId.longValue() == 3) {
throw new RuntimeException("deviceId should be 0,1,2,4-" + maxDeviceId);
}
for (VolumeVO vol : vols) {
if (vol.getDeviceId().equals(deviceId)) {