mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix hosts for migration count (#4500)
* Fixing count for findHostsForMigration * Changing list name
This commit is contained in:
parent
a979ab9050
commit
2eef0e5af3
@ -1164,8 +1164,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
final Object resourceState = cmd.getResourceState();
|
final Object resourceState = cmd.getResourceState();
|
||||||
final Object haHosts = cmd.getHaHost();
|
final Object haHosts = cmd.getHaHost();
|
||||||
|
|
||||||
final Pair<List<HostVO>, Integer> result = searchForServers(cmd.getStartIndex(), cmd.getPageSizeVal(), name, type, state, zoneId, pod, cluster, id, keyword, resourceState, haHosts, null,
|
final Pair<List<HostVO>, Integer> result = searchForServers(cmd.getStartIndex(), cmd.getPageSizeVal(), name, type, state, zoneId, pod,
|
||||||
null);
|
cluster, id, keyword, resourceState, haHosts, null, null);
|
||||||
return new Pair<List<? extends Host>, Integer>(result.first(), result.second());
|
return new Pair<List<? extends Host>, Integer>(result.first(), result.second());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1267,19 +1267,20 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
final Type hostType = srcHost.getType();
|
final Type hostType = srcHost.getType();
|
||||||
Pair<List<HostVO>, Integer> allHostsPair = null;
|
Pair<List<HostVO>, Integer> allHostsPair = null;
|
||||||
List<HostVO> allHosts = null;
|
List<HostVO> allHosts = null;
|
||||||
|
List<HostVO> hostsForMigrationWithStorage = null;
|
||||||
final Map<Host, Boolean> requiresStorageMotion = new HashMap<Host, Boolean>();
|
final Map<Host, Boolean> requiresStorageMotion = new HashMap<Host, Boolean>();
|
||||||
DataCenterDeployment plan = null;
|
DataCenterDeployment plan = null;
|
||||||
if (canMigrateWithStorage) {
|
if (canMigrateWithStorage) {
|
||||||
allHostsPair = searchForServers(startIndex, pageSize, null, hostType, null, srcHost.getDataCenterId(), null, null, null, keyword, null, null, srcHost.getHypervisorType(),
|
allHostsPair = searchForServers(startIndex, pageSize, null, hostType, null, srcHost.getDataCenterId(), null, null, null, keyword,
|
||||||
srcHost.getHypervisorVersion());
|
null, null, srcHost.getHypervisorType(), srcHost.getHypervisorVersion(), srcHost.getId());
|
||||||
allHosts = allHostsPair.first();
|
allHosts = allHostsPair.first();
|
||||||
allHosts.remove(srcHost);
|
hostsForMigrationWithStorage = new ArrayList<>(allHosts);
|
||||||
|
|
||||||
for (final VolumeVO volume : volumes) {
|
for (final VolumeVO volume : volumes) {
|
||||||
StoragePool storagePool = _poolDao.findById(volume.getPoolId());
|
StoragePool storagePool = _poolDao.findById(volume.getPoolId());
|
||||||
Long volClusterId = storagePool.getClusterId();
|
Long volClusterId = storagePool.getClusterId();
|
||||||
|
|
||||||
for (Iterator<HostVO> iterator = allHosts.iterator(); iterator.hasNext();) {
|
for (Iterator<HostVO> iterator = hostsForMigrationWithStorage.iterator(); iterator.hasNext();) {
|
||||||
final Host host = iterator.next();
|
final Host host = iterator.next();
|
||||||
|
|
||||||
if (volClusterId != null) {
|
if (volClusterId != null) {
|
||||||
@ -1318,10 +1319,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Searching for all hosts in cluster " + cluster + " for migrating VM " + vm);
|
s_logger.debug("Searching for all hosts in cluster " + cluster + " for migrating VM " + vm);
|
||||||
}
|
}
|
||||||
allHostsPair = searchForServers(startIndex, pageSize, null, hostType, null, null, null, cluster, null, keyword, null, null, null, null);
|
allHostsPair = searchForServers(startIndex, pageSize, null, hostType, null, null, null, cluster, null, keyword, null, null, null,
|
||||||
// Filter out the current host.
|
null, srcHost.getId());
|
||||||
allHosts = allHostsPair.first();
|
allHosts = allHostsPair.first();
|
||||||
allHosts.remove(srcHost);
|
|
||||||
plan = new DataCenterDeployment(srcHost.getDataCenterId(), srcHost.getPodId(), srcHost.getClusterId(), null, null, null);
|
plan = new DataCenterDeployment(srcHost.getDataCenterId(), srcHost.getPodId(), srcHost.getClusterId(), null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1350,7 +1350,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
|
|
||||||
for (final HostAllocator allocator : hostAllocators) {
|
for (final HostAllocator allocator : hostAllocators) {
|
||||||
if (canMigrateWithStorage) {
|
if (canMigrateWithStorage) {
|
||||||
suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, allHosts, HostAllocator.RETURN_UPTO_ALL, false);
|
suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, hostsForMigrationWithStorage, HostAllocator.RETURN_UPTO_ALL, false);
|
||||||
} else {
|
} else {
|
||||||
suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, HostAllocator.RETURN_UPTO_ALL, false);
|
suitableHosts = allocator.allocateTo(vmProfile, plan, Host.Type.Routing, excludes, HostAllocator.RETURN_UPTO_ALL, false);
|
||||||
}
|
}
|
||||||
@ -1542,12 +1542,14 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
return suitablePools;
|
return suitablePools;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<List<HostVO>, Integer> searchForServers(final Long startIndex, final Long pageSize, final Object name, final Object type, final Object state, final Object zone, final Object pod,
|
private Pair<List<HostVO>, Integer> searchForServers(final Long startIndex, final Long pageSize, final Object name, final Object type,
|
||||||
final Object cluster, final Object id, final Object keyword, final Object resourceState, final Object haHosts, final Object hypervisorType, final Object hypervisorVersion) {
|
final Object state, final Object zone, final Object pod, final Object cluster, final Object id, final Object keyword,
|
||||||
|
final Object resourceState, final Object haHosts, final Object hypervisorType, final Object hypervisorVersion, final Object... excludes) {
|
||||||
final Filter searchFilter = new Filter(HostVO.class, "id", Boolean.TRUE, startIndex, pageSize);
|
final Filter searchFilter = new Filter(HostVO.class, "id", Boolean.TRUE, startIndex, pageSize);
|
||||||
|
|
||||||
final SearchBuilder<HostVO> sb = _hostDao.createSearchBuilder();
|
final SearchBuilder<HostVO> sb = _hostDao.createSearchBuilder();
|
||||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||||
|
sb.and("idsNotIn", sb.entity().getId(), SearchCriteria.Op.NOTIN);
|
||||||
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
|
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
|
||||||
sb.and("type", sb.entity().getType(), SearchCriteria.Op.LIKE);
|
sb.and("type", sb.entity().getType(), SearchCriteria.Op.LIKE);
|
||||||
sb.and("status", sb.entity().getStatus(), SearchCriteria.Op.EQ);
|
sb.and("status", sb.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||||
@ -1588,6 +1590,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||||||
sc.setParameters("id", id);
|
sc.setParameters("id", id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (excludes != null && excludes.length > 0) {
|
||||||
|
sc.setParameters("idsNotIn", excludes);
|
||||||
|
}
|
||||||
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
sc.setParameters("name", "%" + name + "%");
|
sc.setParameters("name", "%" + name + "%");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user