|
16 | 16 | // under the License. |
17 | 17 | package com.cloud.capacity; |
18 | 18 |
|
| 19 | +import static com.cloud.utils.NumbersUtil.toHumanReadableSize; |
| 20 | + |
19 | 21 | import java.net.URI; |
20 | 22 | import java.util.HashMap; |
21 | 23 | import java.util.List; |
|
96 | 98 | import com.cloud.vm.dao.VMInstanceDao; |
97 | 99 | import com.cloud.vm.snapshot.dao.VMSnapshotDao; |
98 | 100 |
|
99 | | -import static com.cloud.utils.NumbersUtil.toHumanReadableSize; |
100 | | - |
101 | 101 | public class CapacityManagerImpl extends ManagerBase implements CapacityManager, StateListener<State, VirtualMachine.Event, VirtualMachine>, Listener, ResourceListener, |
102 | 102 | Configurable { |
103 | 103 | private static final Logger s_logger = Logger.getLogger(CapacityManagerImpl.class); |
@@ -1232,13 +1232,17 @@ public void processPrepareMaintenaceEventBefore(Long hostId) { |
1232 | 1232 |
|
1233 | 1233 | @Override |
1234 | 1234 | public boolean checkIfHostReachMaxGuestLimit(Host host) { |
1235 | | - Long vmCount = _vmDao.countActiveByHostId(host.getId()); |
1236 | 1235 | HypervisorType hypervisorType = host.getHypervisorType(); |
| 1236 | + if (hypervisorType.equals(HypervisorType.KVM)) { |
| 1237 | + s_logger.debug(String.format("Host {id: %s, name: %s, uuid: %s} is %s hypervisor type, no max guest limit check needed", host.getId(), host.getName(), host.getUuid(), hypervisorType)); |
| 1238 | + return false; |
| 1239 | + } |
| 1240 | + Long vmCount = _vmDao.countActiveByHostId(host.getId()); |
1237 | 1241 | String hypervisorVersion = host.getHypervisorVersion(); |
1238 | 1242 | Long maxGuestLimit = _hypervisorCapabilitiesDao.getMaxGuestsLimit(hypervisorType, hypervisorVersion); |
1239 | | - if (vmCount.longValue() >= maxGuestLimit.longValue()) { |
1240 | | - s_logger.info("Host name: " + host.getName() + ", hostId: " + host.getId() + " already reached max Running VMs(count includes system VMs), limit: " + |
1241 | | - maxGuestLimit + ", Running VM count: " + vmCount.longValue()); |
| 1243 | + if (vmCount >= maxGuestLimit) { |
| 1244 | + s_logger.info(String.format("Host {id: %s, name: %s, uuid: %s} already reached max Running VMs(count includes system VMs), limit: %d, running VM count: %s", |
| 1245 | + host.getId(), host.getName(), host.getUuid(), maxGuestLimit, vmCount)); |
1242 | 1246 | return true; |
1243 | 1247 | } |
1244 | 1248 | return false; |
|
0 commit comments