We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 80e87df commit a38c383Copy full SHA for a38c383
1 file changed
server/src/main/java/com/cloud/template/TemplateManagerImpl.java
@@ -1599,7 +1599,14 @@ int advertisedCdromCap(Long hostId) {
1599
}
1600
1601
Long hostIdForVm(VirtualMachine vm) {
1602
- return vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
+ Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();
1603
+ if (hostId == null && vm.getHypervisorType() != null) {
1604
+ List<HostVO> candidates = _hostDao.listByDataCenterIdAndHypervisorType(vm.getDataCenterId(), vm.getHypervisorType());
1605
+ if (!candidates.isEmpty()) {
1606
+ hostId = candidates.get(0).getId();
1607
+ }
1608
1609
+ return hostId;
1610
1611
1612
@Override
0 commit comments