|
64 | 64 | import com.cloud.host.ControlState; |
65 | 65 | import com.cloud.host.DetailVO; |
66 | 66 | import com.cloud.host.Host; |
| 67 | +import com.cloud.host.HostVO; |
| 68 | +import com.cloud.host.dao.HostDao; |
67 | 69 | import com.cloud.host.dao.HostDetailsDao; |
68 | 70 | import com.cloud.network.IpAddress; |
69 | 71 | import com.cloud.network.vpc.VpcVO; |
@@ -139,6 +141,8 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation<UserVmJo |
139 | 141 | @Inject |
140 | 142 | HostDetailsDao hostDetailsDao; |
141 | 143 | @Inject |
| 144 | + HostDao hostDao; |
| 145 | + @Inject |
142 | 146 | ExtensionHelper extensionHelper; |
143 | 147 |
|
144 | 148 | private final SearchBuilder<UserVmJoinVO> VmDetailSearch; |
@@ -564,8 +568,17 @@ private long computeLeaseDurationFromExpiryDate(Date created, Date leaseExpiryDa |
564 | 568 | } |
565 | 569 |
|
566 | 570 | int effectiveCdromMaxCount(UserVmJoinVO userVm) { |
567 | | - int configuredCap = TemplateManager.VmIsoMaxCount.valueIn(userVm.getClusterId()); |
568 | | - int hypervisorCap = advertisedCdromCap(userVm.getHostId() != null ? userVm.getHostId() : userVm.getLastHostId()); |
| 571 | + Long hostId = userVm.getHostId() != null && userVm.getHostId() > 0 |
| 572 | + ? userVm.getHostId() : userVm.getLastHostId(); |
| 573 | + Long clusterId = userVm.getClusterId(); |
| 574 | + if (clusterId == null && hostId != null) { |
| 575 | + HostVO host = hostDao.findById(hostId); |
| 576 | + if (host != null) { |
| 577 | + clusterId = host.getClusterId(); |
| 578 | + } |
| 579 | + } |
| 580 | + int configuredCap = TemplateManager.VmIsoMaxCount.valueIn(clusterId); |
| 581 | + int hypervisorCap = advertisedCdromCap(hostId); |
569 | 582 | // List endpoint clamps for display robustness; the action paths in TemplateManagerImpl |
570 | 583 | // throw on misconfiguration so operators still see the loud error when they try to attach. |
571 | 584 | return Math.min(configuredCap, hypervisorCap); |
|
0 commit comments