Skip to content

Commit a2f8419

Browse files
Pearl1594dhslove
authored andcommitted
Fix listing disk offerings for newly created VMs that haven't yet been started (apache#10476)
1 parent ebe7029 commit a2f8419

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6084,6 +6084,9 @@ protected boolean isDiskOfferingSuitableForVm(VMInstanceVO vm, VirtualMachinePro
60846084
@Override
60856085
public Map<Long, Boolean> getDiskOfferingSuitabilityForVm(long vmId, List<Long> diskOfferingIds) {
60866086
VMInstanceVO vm = _vmDao.findById(vmId);
6087+
if (userVmDetailsDao.findDetail(vm.getId(), VmDetailConstants.DEPLOY_VM) != null) {
6088+
return new HashMap<>();
6089+
}
60876090
VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
60886091
Pair<Long, Long> clusterAndHost = findClusterAndHostIdForVm(vm, false);
60896092
Long clusterId = clusterAndHost.first();

server/src/main/java/com/cloud/api/ApiDBUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2147,7 +2147,7 @@ public static List<DiskOfferingResponse> newDiskOfferingResponses(Long vmId, Lis
21472147
for (DiskOfferingJoinVO offering : offerings) {
21482148
DiskOfferingResponse response = s_diskOfferingJoinDao.newDiskOfferingResponse(offering);
21492149
if (vmId != null) {
2150-
response.setSuitableForVm(suitability.get(offering.getId()));
2150+
response.setSuitableForVm(suitability.getOrDefault(offering.getId(), true));
21512151
}
21522152
list.add(response);
21532153
}

0 commit comments

Comments
 (0)