Skip to content

Commit 80e87df

Browse files
committed
refactor: enhance effective CD-ROM max count logic to retrieve host ID from candidates based on hypervisor type
1 parent fa84824 commit 80e87df

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,12 @@ private long computeLeaseDurationFromExpiryDate(Date created, Date leaseExpiryDa
570570
int effectiveCdromMaxCount(UserVmJoinVO userVm) {
571571
Long hostId = userVm.getHostId() != null && userVm.getHostId() > 0
572572
? userVm.getHostId() : userVm.getLastHostId();
573+
if (hostId == null && userVm.getHypervisorType() != null) {
574+
List<HostVO> candidates = hostDao.listByDataCenterIdAndHypervisorType(userVm.getDataCenterId(), userVm.getHypervisorType());
575+
if (!candidates.isEmpty()) {
576+
hostId = candidates.get(0).getId();
577+
}
578+
}
573579
Long clusterId = userVm.getClusterId();
574580
if (clusterId == null && hostId != null) {
575581
HostVO host = hostDao.findById(hostId);

0 commit comments

Comments
 (0)