Skip to content

Commit b08f2a9

Browse files
authored
Merge pull request #514 from jschoiRR/mold-diplo-2024-main
[Mold API] 가상머신 생성시 전달되는 customParameters null 체크방식 변경 및 containsKey 방식으로 volumeId 키 존재 여부 확인
2 parents 3aaa61b + 7880baa commit b08f2a9

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ public void allocate(final String vmInstanceName, final VirtualMachineTemplate t
511511

512512
logger.debug("Allocating disks for {}", persistedVm);
513513

514-
if (customParameters.get("volumeId") != null){
514+
if (!MapUtils.isEmpty(customParameters) && customParameters.containsKey("volumeId")){
515515
VolumeVO volVO =_volsDao.findById(Long.parseLong(customParameters.get("volumeId")));
516516
volVO.setInstanceId(vm.getId());
517517
_volsDao.update(volVO.getId(), volVO);

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// under the License.
1717
package com.cloud.vm;
1818

19+
import static com.cloud.configuration.ConfigurationManager.VM_USERDATA_MAX_LENGTH;
1920
import static com.cloud.configuration.ConfigurationManagerImpl.VM_USERDATA_MAX_LENGTH;
2021
import static com.cloud.storage.Volume.IOPS_LIMIT;
2122
import static com.cloud.utils.NumbersUtil.toHumanReadableSize;
@@ -3992,7 +3993,7 @@ private UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
39923993
throw new PermissionDeniedException("The owner of vm to deploy is disabled: " + owner);
39933994
}
39943995
VMTemplateVO template = _templateDao.findById(tmplt.getId());
3995-
if (customParameters.get("volumeId") != null) {
3996+
if (!MapUtils.isEmpty(customParameters) && customParameters.containsKey("volumeId")){
39963997
template = _templateDao.findByIdIncludingRemoved(tmplt.getId());
39973998
}
39983999

@@ -4074,7 +4075,7 @@ private UserVm createVirtualMachine(DataCenter zone, ServiceOffering serviceOffe
40744075
throw new InvalidParameterValueException("Root volume encryption is not supported for hypervisor type " + hypervisorType);
40754076
}
40764077

4077-
if (customParameters.get("volumeId") != null) {
4078+
if (!MapUtils.isEmpty(customParameters) && customParameters.containsKey("volumeId")){
40784079
Long volumeId = Long.valueOf(customParameters.get("volumeId"));
40794080
VolumeVO volume = _volsDao.findById(volumeId);
40804081
// Compute the size of the volume
@@ -4498,14 +4499,14 @@ protected long configureCustomRootDiskSize(Map<String, String> customParameters,
44984499
_volumeService.validateVolumeSizeInBytes(rootDiskSize);
44994500
return rootDiskSize;
45004501
} else {
4501-
if (customParameters.get("volumeId") == null) {
4502-
// For baremetal, size can be 0 (zero)
4503-
Long templateSize = _templateDao.findById(template.getId()).getSize();
4504-
if (templateSize != null) {
4505-
return templateSize;
4502+
if (!MapUtils.isEmpty(customParameters) && !customParameters.containsKey("volumeId")){
4503+
// For baremetal, size can be 0 (zero)
4504+
Long templateSize = _templateDao.findById(template.getId()).getSize();
4505+
if (templateSize != null) {
4506+
return templateSize;
4507+
}
45064508
}
45074509
}
4508-
}
45094510
return 0;
45104511
}
45114512

@@ -4562,7 +4563,7 @@ private UserVmVO commitUserVm(final boolean isImport, final DataCenter zone, fin
45624563
offering.getLimitCpuUse(), owner.getDomainId(), owner.getId(), userId, offering.getId(), userData, userDataId, userDataDetails, hostName);
45634564
vm.setUuid(uuidName);
45644565
vm.setDynamicallyScalable(dynamicScalingEnabled);
4565-
if (customParameters.get("volumeId") != null) {
4566+
if (!MapUtils.isEmpty(customParameters) && customParameters.containsKey("volumeId")){
45664567
template = _templateDao.findByIdIncludingRemoved(template.getId());
45674568
}
45684569
Map<String, String> details = template.getDetails();
@@ -4596,7 +4597,7 @@ private UserVmVO commitUserVm(final boolean isImport, final DataCenter zone, fin
45964597

45974598
Long rootDiskSize = null;
45984599
// custom root disk size, resizes base template to larger size
4599-
if (customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE) && customParameters.get("volumeId") == null) {
4600+
if (customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE) && !customParameters.containsKey("volumeId")) {
46004601
// already verified for positive number
46014602
rootDiskSize = Long.parseLong(customParameters.get(VmDetailConstants.ROOT_DISK_SIZE));
46024603

@@ -4606,7 +4607,6 @@ private UserVmVO commitUserVm(final boolean isImport, final DataCenter zone, fin
46064607
ipve.add(VirtualMachine.class, vm.getUuid());
46074608
throw ipve;
46084609
}
4609-
46104610
validateRootDiskResize(hypervisorType, rootDiskSize, templateVO, vm, customParameters);
46114611
}
46124612

@@ -9341,10 +9341,10 @@ public UserVm createVirtualMachineVolume(DeployVMVolumeCmd cmd) throws Insuffici
93419341
Map<String, String> userVmOVFProperties = cmd.getVmProperties();
93429342
Map<String, String> customParameters = cmd.getDetails();
93439343
Long volumeId = cmd.getVolumeId();
9344-
if (cmd.getVolumeId() != null) {
9344+
if (volumeId != null) {
93459345
customParameters.put("volumeId", String.valueOf(volumeId));
93469346
}
9347-
VolumeVO volVO =_volsDao.findById(Long.parseLong(customParameters.get("volumeId")));
9347+
VolumeVO volVO =_volsDao.findById(volumeId);
93489348
volVO.setDeviceId(0L);
93499349
volVO.setTemplateId(template.getId());
93509350
_volsDao.update(volVO.getId(), volVO);

ui/public/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"docBase": "http://docs.ablecloud.io/latest",
1111
"appTitle": "Mold-ABLESTACK",
1212
"footer": "Copyright (c) 2021-2024, ABLECLOUD.Co.Ltd",
13-
"buildVersion": "Diplo-v4.0.0-20240305",
13+
"buildVersion": "ABLESTACK V4.0-4.0.15",
1414
"loginFooter": "",
1515
"logo": "assets/ablestack-logo.png",
1616
"minilogo": "assets/mini-ablestack-logo.png",

0 commit comments

Comments
 (0)