mirror of https://github.com/apache/cloudstack.git
bug 7635: stop vms if this host is the last one in cluster , when put this host into maintenance mode
status 7635: resolved fixed
This commit is contained in:
parent
88ff55849d
commit
c85e13fbf9
|
|
@ -112,6 +112,7 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.UnsupportedVersionException;
|
||||
import com.cloud.ha.HighAvailabilityManager;
|
||||
import com.cloud.ha.HighAvailabilityManager.WorkType;
|
||||
import com.cloud.host.DetailVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Host.Type;
|
||||
|
|
@ -2071,13 +2072,21 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory,
|
|||
final Host.Type type = host.getType();
|
||||
|
||||
if (type == Host.Type.Routing) {
|
||||
|
||||
final List<VMInstanceVO> vms = _vmDao.listByHostId(hostId);
|
||||
if (vms.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<HostVO> hosts = _hostDao.listBy(host.getClusterId(), host.getPodId(), host.getDataCenterId());
|
||||
|
||||
for (final VMInstanceVO vm : vms) {
|
||||
_haMgr.scheduleMigration(vm);
|
||||
if( hosts == null || hosts.isEmpty()) {
|
||||
// for the last host in this cluster, stop all the VMs
|
||||
_haMgr.scheduleStop(vm, hostId, WorkType.ForceStop);
|
||||
} else {
|
||||
_haMgr.scheduleMigration(vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,5 +151,7 @@ public interface HostDao extends GenericDao<HostVO, Long> {
|
|||
* @param statuses the host needs to be in.
|
||||
* @return ids of the host meeting the search parameters.
|
||||
*/
|
||||
List<Long> listBy(Long dataCenterId, Long podId, Long clusterId, Type hostType, Status... statuses);
|
||||
List<Long> listBy(Long dataCenterId, Long podId, Long clusterId, Type hostType, Status... statuses);
|
||||
|
||||
List<HostVO> listBy(Long clusterId, Long podId, long dcId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,6 +313,19 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listBy(Long clusterId, Long podId, long dcId) {
|
||||
SearchCriteria<HostVO> sc = TypePodDcStatusSearch.create();
|
||||
if (podId != null) {
|
||||
sc.setParameters("pod", podId);
|
||||
}
|
||||
if (clusterId != null) {
|
||||
sc.setParameters("cluster", clusterId);
|
||||
}
|
||||
sc.setParameters("dc", dcId);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByCluster(long clusterId) {
|
||||
SearchCriteria<HostVO> sc = ClusterSearch.create();
|
||||
|
|
|
|||
Loading…
Reference in New Issue