mirror of https://github.com/apache/cloudstack.git
continuation of 1d47e4d4ae
list host IDs instead of complete row where possible Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
33321f00ce
commit
35ed30bd51
|
|
@ -39,7 +39,7 @@ public interface OutOfBandManagementService {
|
|||
long getId();
|
||||
boolean isOutOfBandManagementEnabled(Host host);
|
||||
void submitBackgroundPowerSyncTask(Host host);
|
||||
boolean transitionPowerStateToDisabled(List<? extends Host> hosts);
|
||||
boolean transitionPowerStateToDisabled(List<Long> hostIds);
|
||||
|
||||
OutOfBandManagementResponse enableOutOfBandManagement(DataCenter zone);
|
||||
OutOfBandManagementResponse enableOutOfBandManagement(Cluster cluster);
|
||||
|
|
|
|||
|
|
@ -89,26 +89,27 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
|
|||
|
||||
List<HostVO> findByDataCenterId(Long zoneId);
|
||||
|
||||
List<Long> listIdsByDataCenterId(Long zoneId);
|
||||
|
||||
List<HostVO> findByPodId(Long podId);
|
||||
|
||||
List<Long> listIdsByPodId(Long podId);
|
||||
|
||||
List<HostVO> findByClusterId(Long clusterId);
|
||||
|
||||
List<Long> listIdsByClusterId(Long clusterId);
|
||||
|
||||
List<HostVO> findByClusterIdAndEncryptionSupport(Long clusterId);
|
||||
|
||||
/**
|
||||
* Returns hosts that are 'Up' and 'Enabled' from the given Data Center/Zone
|
||||
*/
|
||||
List<HostVO> listByDataCenterId(long id);
|
||||
|
||||
/**
|
||||
* Returns hosts that are from the given Data Center/Zone and at a given state (e.g. Creating, Enabled, Disabled, etc).
|
||||
*/
|
||||
List<HostVO> listByDataCenterIdAndState(long id, ResourceState state);
|
||||
List<Long> listEnabledIdsByDataCenterId(long id);
|
||||
|
||||
/**
|
||||
* Returns hosts that are 'Up' and 'Disabled' from the given Data Center/Zone
|
||||
*/
|
||||
List<HostVO> listDisabledByDataCenterId(long id);
|
||||
List<Long> listDisabledIdsByDataCenterId(long id);
|
||||
|
||||
List<HostVO> listByDataCenterIdAndHypervisorType(long zoneId, Hypervisor.HypervisorType hypervisorType);
|
||||
|
||||
|
|
@ -176,6 +177,4 @@ public interface HostDao extends GenericDao<HostVO, Long>, StateDao<Status, Stat
|
|||
List<Long> listAllIds();
|
||||
|
||||
List<HypervisorType> listDistinctHypervisorTypes(final Long zoneId);
|
||||
|
||||
List<Long> listAllHostIdsInCluster(final long clusterId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
|
||||
protected SearchBuilder<HostVO> GuidSearch;
|
||||
protected SearchBuilder<HostVO> DcSearch;
|
||||
protected GenericSearchBuilder<HostVO, Long> IdsDcSearch;
|
||||
protected SearchBuilder<HostVO> PodSearch;
|
||||
protected SearchBuilder<HostVO> ClusterSearch;
|
||||
protected SearchBuilder<HostVO> TypeSearch;
|
||||
|
|
@ -283,6 +284,13 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
DcSearch.and("resourceState", DcSearch.entity().getResourceState(), Op.EQ);
|
||||
DcSearch.done();
|
||||
|
||||
IdsDcSearch = createSearchBuilder(Long.class);
|
||||
IdsDcSearch.and("zoneId", IdsDcSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
IdsDcSearch.and("resourceState", IdsDcSearch.entity().getResourceState(), SearchCriteria.Op.EQ);
|
||||
IdsDcSearch.and("status", IdsDcSearch.entity().getStatus(), Op.EQ);
|
||||
IdsDcSearch.and("type", IdsDcSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
IdsDcSearch.done();
|
||||
|
||||
ClusterStatusSearch = createSearchBuilder();
|
||||
ClusterStatusSearch.and("cluster", ClusterStatusSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||
ClusterStatusSearch.and("status", ClusterStatusSearch.entity().getStatus(), SearchCriteria.Op.EQ);
|
||||
|
|
@ -533,29 +541,23 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return cpuSockets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByDataCenterId(long id) {
|
||||
return listByDataCenterIdAndState(id, ResourceState.Enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listByDataCenterIdAndState(long id, ResourceState state) {
|
||||
SearchCriteria<HostVO> sc = scHostsFromZoneUpRouting(id);
|
||||
private List<Long> listIdsByDataCenterIdAndResourceState(long id, ResourceState state) {
|
||||
SearchCriteria<Long> sc = IdsDcSearch.create();
|
||||
sc.setParameters("zoneId", id);
|
||||
sc.setParameters("resourceState", state);
|
||||
return listBy(sc);
|
||||
sc.setParameters("status", Status.Up);
|
||||
sc.setParameters("type", Type.Routing);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> listDisabledByDataCenterId(long id) {
|
||||
return listByDataCenterIdAndState(id, ResourceState.Disabled);
|
||||
public List<Long> listEnabledIdsByDataCenterId(long id) {
|
||||
return listIdsByDataCenterIdAndResourceState(id, ResourceState.Enabled);
|
||||
}
|
||||
|
||||
private SearchCriteria<HostVO> scHostsFromZoneUpRouting(long id) {
|
||||
SearchCriteria<HostVO> sc = DcSearch.create();
|
||||
sc.setParameters("dc", id);
|
||||
sc.setParameters("status", Status.Up);
|
||||
sc.setParameters("type", Host.Type.Routing);
|
||||
return sc;
|
||||
@Override
|
||||
public List<Long> listDisabledIdsByDataCenterId(long id) {
|
||||
return listIdsByDataCenterIdAndResourceState(id, ResourceState.Disabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1190,6 +1192,14 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listIdsByDataCenterId(Long zoneId) {
|
||||
SearchCriteria<Long> sc = IdsDcSearch.create();
|
||||
sc.setParameters("dc", zoneId);
|
||||
sc.setParameters("type", Type.Routing);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> findByPodId(Long podId) {
|
||||
SearchCriteria<HostVO> sc = PodSearch.create();
|
||||
|
|
@ -1197,6 +1207,16 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listIdsByPodId(Long podId) {
|
||||
GenericSearchBuilder<HostVO, Long> sb = createSearchBuilder(Long.class);
|
||||
sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
sb.done();
|
||||
SearchCriteria<Long> sc = sb.create();
|
||||
sc.setParameters("podId", podId);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> findByClusterId(Long clusterId) {
|
||||
SearchCriteria<HostVO> sc = ClusterSearch.create();
|
||||
|
|
@ -1204,6 +1224,16 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listIdsByClusterId(Long clusterId) {
|
||||
GenericSearchBuilder<HostVO, Long> sb = createSearchBuilder(Long.class);
|
||||
sb.and("clusterId", sb.entity().getClusterId(), SearchCriteria.Op.EQ);
|
||||
sb.done();
|
||||
SearchCriteria<Long> sc = sb.create();
|
||||
sc.setParameters("clusterId", clusterId);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HostVO> findByClusterIdAndEncryptionSupport(Long clusterId) {
|
||||
SearchBuilder<DetailVO> hostCapabilitySearch = _detailsDao.createSearchBuilder();
|
||||
|
|
@ -1575,11 +1605,4 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
|||
sc.setParameters("type", Type.Routing);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listAllHostIdsInCluster(final long clusterId) {
|
||||
SearchCriteria<Long> sc = HostIdSearch.create();
|
||||
sc.setParameters("clusterId", clusterId);
|
||||
return customSearch(sc, null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,13 +323,13 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement
|
|||
}
|
||||
}
|
||||
//add all hosts inside this in includeList
|
||||
List<HostVO> hostList = _hostDao.listByDataCenterId(dr.getDataCenterId());
|
||||
for (HostVO host : hostList) {
|
||||
DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
|
||||
List<Long> hostList = _hostDao.listEnabledIdsByDataCenterId(dr.getDataCenterId());
|
||||
for (Long hostId : hostList) {
|
||||
DedicatedResourceVO dHost = _dedicatedDao.findByHostId(hostId);
|
||||
if (dHost != null && !dedicatedResources.contains(dHost)) {
|
||||
avoidList.addHost(host.getId());
|
||||
avoidList.addHost(hostId);
|
||||
} else {
|
||||
includeList.addHost(host.getId());
|
||||
includeList.addHost(hostId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -339,7 +339,7 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement
|
|||
|
||||
List<HostPodVO> pods = _podDao.listByDataCenterId(dc.getId());
|
||||
List<ClusterVO> clusters = _clusterDao.listClustersByDcId(dc.getId());
|
||||
List<HostVO> hosts = _hostDao.listByDataCenterId(dc.getId());
|
||||
List<Long> hostIds = _hostDao.listEnabledIdsByDataCenterId(dc.getId());
|
||||
Set<Long> podsInIncludeList = includeList.getPodsToAvoid();
|
||||
Set<Long> clustersInIncludeList = includeList.getClustersToAvoid();
|
||||
Set<Long> hostsInIncludeList = includeList.getHostsToAvoid();
|
||||
|
|
@ -359,9 +359,9 @@ public class ExplicitDedicationProcessor extends AffinityProcessorBase implement
|
|||
}
|
||||
}
|
||||
|
||||
for (HostVO host : hosts) {
|
||||
if (hostsInIncludeList != null && !hostsInIncludeList.contains(host.getId())) {
|
||||
avoidList.addHost(host.getId());
|
||||
for (Long hostId : hostIds) {
|
||||
if (hostsInIncludeList != null && !hostsInIncludeList.contains(hostId)) {
|
||||
avoidList.addHost(hostId);
|
||||
}
|
||||
}
|
||||
return avoidList;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
@ActionEvent(eventType = EventTypes.EVENT_DEDICATE_RESOURCE, eventDescription = "dedicating a Zone")
|
||||
public List<DedicatedResourceVO> dedicateZone(final Long zoneId, final Long domainId, final String accountName) {
|
||||
Long accountId = null;
|
||||
List<HostVO> hosts = null;
|
||||
List<Long> hostIds = null;
|
||||
if (accountName != null) {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Account owner = _accountMgr.finalizeOwner(caller, accountName, domainId, null);
|
||||
|
|
@ -201,17 +201,19 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
releaseDedicatedResource(null, null, dr.getClusterId(), null);
|
||||
}
|
||||
|
||||
hosts = _hostDao.listByDataCenterId(dc.getId());
|
||||
for (HostVO host : hosts) {
|
||||
DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
|
||||
hostIds = _hostDao.listEnabledIdsByDataCenterId(dc.getId());
|
||||
for (Long hostId : hostIds) {
|
||||
DedicatedResourceVO dHost = _dedicatedDao.findByHostId(hostId);
|
||||
if (dHost != null) {
|
||||
if (!(childDomainIds.contains(dHost.getDomainId()))) {
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
throw new CloudRuntimeException("Host " + host.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain");
|
||||
}
|
||||
if (accountId != null) {
|
||||
if (dHost.getAccountId().equals(accountId)) {
|
||||
hostsToRelease.add(dHost);
|
||||
} else {
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
s_logger.error("Host " + host.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain");
|
||||
throw new CloudRuntimeException("Host " + host.getName() + " under this Zone " + dc.getName() + " is dedicated to different account/domain");
|
||||
}
|
||||
|
|
@ -228,7 +230,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
}
|
||||
}
|
||||
|
||||
checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hosts);
|
||||
checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hostIds);
|
||||
|
||||
final Long accountIdFinal = accountId;
|
||||
return Transaction.execute(new TransactionCallback<List<DedicatedResourceVO>>() {
|
||||
|
|
@ -282,7 +284,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
childDomainIds.add(domainId);
|
||||
checkAccountAndDomain(accountId, domainId);
|
||||
HostPodVO pod = _podDao.findById(podId);
|
||||
List<HostVO> hosts = null;
|
||||
List<Long> hostIds = null;
|
||||
if (pod == null) {
|
||||
throw new InvalidParameterValueException("Unable to find pod by id " + podId);
|
||||
} else {
|
||||
|
|
@ -337,17 +339,19 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
releaseDedicatedResource(null, null, dr.getClusterId(), null);
|
||||
}
|
||||
|
||||
hosts = _hostDao.findByPodId(pod.getId());
|
||||
for (HostVO host : hosts) {
|
||||
DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
|
||||
hostIds = _hostDao.listIdsByPodId(pod.getId());
|
||||
for (Long hostId : hostIds) {
|
||||
DedicatedResourceVO dHost = _dedicatedDao.findByHostId(hostId);
|
||||
if (dHost != null) {
|
||||
if (!(getDomainChildIds(domainId).contains(dHost.getDomainId()))) {
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
throw new CloudRuntimeException("Host " + host.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain");
|
||||
}
|
||||
if (accountId != null) {
|
||||
if (dHost.getAccountId().equals(accountId)) {
|
||||
hostsToRelease.add(dHost);
|
||||
} else {
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
s_logger.error("Host " + host.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain");
|
||||
throw new CloudRuntimeException("Host " + host.getName() + " under this Pod " + pod.getName() + " is dedicated to different account/domain");
|
||||
}
|
||||
|
|
@ -364,7 +368,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
}
|
||||
}
|
||||
|
||||
checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hosts);
|
||||
checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hostIds);
|
||||
|
||||
final Long accountIdFinal = accountId;
|
||||
return Transaction.execute(new TransactionCallback<List<DedicatedResourceVO>>() {
|
||||
|
|
@ -400,7 +404,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
@ActionEvent(eventType = EventTypes.EVENT_DEDICATE_RESOURCE, eventDescription = "dedicating a Cluster")
|
||||
public List<DedicatedResourceVO> dedicateCluster(final Long clusterId, final Long domainId, final String accountName) {
|
||||
Long accountId = null;
|
||||
List<HostVO> hosts = null;
|
||||
List<Long> hostIds = null;
|
||||
if (accountName != null) {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Account owner = _accountMgr.finalizeOwner(caller, accountName, domainId, null);
|
||||
|
|
@ -446,12 +450,13 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
}
|
||||
|
||||
//check if any resource under this cluster is dedicated to different account or sub-domain
|
||||
hosts = _hostDao.findByClusterId(cluster.getId());
|
||||
hostIds = _hostDao.listIdsByClusterId(cluster.getId());
|
||||
List<DedicatedResourceVO> hostsToRelease = new ArrayList<DedicatedResourceVO>();
|
||||
for (HostVO host : hosts) {
|
||||
DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
|
||||
for (Long hostId : hostIds) {
|
||||
DedicatedResourceVO dHost = _dedicatedDao.findByHostId(hostId);
|
||||
if (dHost != null) {
|
||||
if (!(childDomainIds.contains(dHost.getDomainId()))) {
|
||||
HostVO host = _hostDao.findById(hostId);
|
||||
throw new CloudRuntimeException("Host " + host.getName() + " under this Cluster " + cluster.getName() +
|
||||
" is dedicated to different account/domain");
|
||||
}
|
||||
|
|
@ -477,7 +482,7 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
}
|
||||
}
|
||||
|
||||
checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hosts);
|
||||
checkHostsSuitabilityForExplicitDedication(accountId, childDomainIds, hostIds);
|
||||
|
||||
final Long accountIdFinal = accountId;
|
||||
return Transaction.execute(new TransactionCallback<List<DedicatedResourceVO>>() {
|
||||
|
|
@ -682,10 +687,10 @@ public class DedicatedResourceManagerImpl implements DedicatedService {
|
|||
return suitable;
|
||||
}
|
||||
|
||||
private boolean checkHostsSuitabilityForExplicitDedication(Long accountId, List<Long> domainIds, List<HostVO> hosts) {
|
||||
private boolean checkHostsSuitabilityForExplicitDedication(Long accountId, List<Long> domainIds, List<Long> hostIds) {
|
||||
boolean suitable = true;
|
||||
for (HostVO host : hosts) {
|
||||
checkHostSuitabilityForExplicitDedication(accountId, domainIds, host.getId());
|
||||
for (Long hostId : hostIds) {
|
||||
checkHostSuitabilityForExplicitDedication(accountId, domainIds, hostId);
|
||||
}
|
||||
return suitable;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public class ImplicitDedicationPlanner extends FirstFitPlanner implements Deploy
|
|||
List<Long> allHosts = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(clusterList)) {
|
||||
allHosts = clusterList.stream()
|
||||
.flatMap(cluster -> hostDao.listAllHostIdsInCluster(cluster).stream())
|
||||
.flatMap(cluster -> hostDao.listIdsByClusterId(cluster).stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ public class ImplicitDedicationPlanner extends FirstFitPlanner implements Deploy
|
|||
}
|
||||
return clusterList.stream()
|
||||
.filter(cluster -> {
|
||||
Set<Long> hostsInClusterSet = new HashSet<>(hostDao.listAllHostIdsInCluster(cluster));
|
||||
Set<Long> hostsInClusterSet = new HashSet<>(hostDao.listIdsByClusterId(cluster));
|
||||
return !hostsSet.containsAll(hostsInClusterSet);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
|
@ -253,7 +253,7 @@ public class ImplicitDedicationPlanner extends FirstFitPlanner implements Deploy
|
|||
List<Long> allHosts = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(clusterList)) {
|
||||
allHosts = clusterList.stream()
|
||||
.flatMap(cluster -> hostDao.listAllHostIdsInCluster(cluster).stream())
|
||||
.flatMap(cluster -> hostDao.listIdsByClusterId(cluster).stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
// Go over all the hosts in the cluster and get a list of
|
||||
|
|
|
|||
|
|
@ -385,9 +385,9 @@ public class ImplicitPlannerTest {
|
|||
when(serviceOfferingDetailsDao.listDetailsKeyPairs(offeringId)).thenReturn(details);
|
||||
|
||||
// Initialize hosts in clusters
|
||||
when(hostDao.listAllHostIdsInCluster(1)).thenReturn(List.of(5L));
|
||||
when(hostDao.listAllHostIdsInCluster(2)).thenReturn(List.of(6L));
|
||||
when(hostDao.listAllHostIdsInCluster(3)).thenReturn(List.of(7L));
|
||||
when(hostDao.listIdsByClusterId(1L)).thenReturn(List.of(5L));
|
||||
when(hostDao.listIdsByClusterId(2L)).thenReturn(List.of(6L));
|
||||
when(hostDao.listIdsByClusterId(3L)).thenReturn(List.of(7L));
|
||||
|
||||
// Mock vms on each host.
|
||||
long offeringIdForVmsOfThisAccount = 15L;
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
sc.and(sc.entity().getGuid(), Op.EQ, guid);
|
||||
List<ClusterVO> clusters = sc.list();
|
||||
ClusterVO clu = clusters.get(0);
|
||||
List<Long> clusterHostIds = _hostDao.listAllHostIdsInCluster(clu.getId());
|
||||
List<Long> clusterHostIds = _hostDao.listIdsByClusterId(clu.getId());
|
||||
if (CollectionUtils.isEmpty(clusterHostIds)) {
|
||||
clu.setGuid(null);
|
||||
_clusterDao.update(clu.getId(), clu);
|
||||
|
|
@ -248,7 +248,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
|
|||
if (clu.getGuid() == null) {
|
||||
setClusterGuid(clu, poolUuid);
|
||||
} else {
|
||||
List<Long> clusterHostIds = _hostDao.listAllHostIdsInCluster(clusterId);
|
||||
List<Long> clusterHostIds = _hostDao.listIdsByClusterId(clusterId);
|
||||
if (CollectionUtils.isNotEmpty(clusterHostIds)) {
|
||||
if (!clu.getGuid().equals(poolUuid)) {
|
||||
String msg = "Please join the host " + hostIp + " to XS pool "
|
||||
|
|
|
|||
|
|
@ -2350,7 +2350,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
|||
|
||||
|
||||
// Check if there are any non-removed hosts in the zone.
|
||||
if (!_hostDao.listByDataCenterId(zoneId).isEmpty()) {
|
||||
if (!_hostDao.listEnabledIdsByDataCenterId(zoneId).isEmpty()) {
|
||||
throw new CloudRuntimeException(errorMsg + "there are servers in this zone.");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -649,10 +649,8 @@ StateListener<State, VirtualMachine.Event, VirtualMachine>, Configurable {
|
|||
* Adds disabled Hosts to the ExcludeList in order to avoid them at the deployment planner.
|
||||
*/
|
||||
protected void avoidDisabledHosts(DataCenter dc, ExcludeList avoids) {
|
||||
List<HostVO> disabledHosts = _hostDao.listDisabledByDataCenterId(dc.getId());
|
||||
for (HostVO host : disabledHosts) {
|
||||
avoids.addHost(host.getId());
|
||||
}
|
||||
List<Long> disabledHostIds = _hostDao.listDisabledIdsByDataCenterId(dc.getId());
|
||||
disabledHostIds.forEach(avoids::addHost);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -643,7 +643,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
throw ex;
|
||||
} else {
|
||||
if (cluster.getGuid() == null) {
|
||||
final List<Long> hostIds = _hostDao.listAllHostIdsInCluster(clusterId);
|
||||
final List<Long> hostIds = _hostDao.listIdsByClusterId(clusterId);
|
||||
if (!hostIds.isEmpty()) {
|
||||
final CloudRuntimeException ex =
|
||||
new CloudRuntimeException("Guid is not updated for cluster with specified cluster id; need to wait for hosts in this cluster to come up");
|
||||
|
|
@ -962,7 +962,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
Host hostRemoved = _hostDao.findById(hostId);
|
||||
_hostDao.remove(hostId);
|
||||
if (clusterId != null) {
|
||||
final List<Long> hostIds = _hostDao.listAllHostIdsInCluster(clusterId);
|
||||
final List<Long> hostIds = _hostDao.listIdsByClusterId(clusterId);
|
||||
if (CollectionUtils.isEmpty(hostIds)) {
|
||||
final ClusterVO cluster = _clusterDao.findById(clusterId);
|
||||
cluster.setGuid(null);
|
||||
|
|
@ -1087,7 +1087,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
|
||||
final Hypervisor.HypervisorType hypervisorType = cluster.getHypervisorType();
|
||||
|
||||
final List<Long> hostIds = _hostDao.listAllHostIdsInCluster(cmd.getId());
|
||||
final List<Long> hostIds = _hostDao.listIdsByClusterId(cmd.getId());
|
||||
if (!hostIds.isEmpty()) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cluster: " + cmd.getId() + " still has hosts, can't remove");
|
||||
|
|
@ -2425,10 +2425,10 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
|
||||
boolean clusterSupportsResigning = true;
|
||||
|
||||
List<HostVO> hostVOs = _hostDao.findByClusterId(host.getClusterId());
|
||||
List<Long> hostIds = _hostDao.listIdsByClusterId(host.getClusterId());
|
||||
|
||||
for (HostVO hostVO : hostVOs) {
|
||||
DetailVO hostDetailVO = _hostDetailsDao.findDetail(hostVO.getId(), name);
|
||||
for (Long hostId : hostIds) {
|
||||
DetailVO hostDetailVO = _hostDetailsDao.findDetail(hostId, name);
|
||||
|
||||
if (hostDetailVO == null || Boolean.parseBoolean(hostDetailVO.getValue()) == false) {
|
||||
clusterSupportsResigning = false;
|
||||
|
|
@ -3034,7 +3034,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
|||
public boolean updateClusterPassword(final UpdateHostPasswordCmd command) {
|
||||
final boolean shouldUpdateHostPasswd = command.getUpdatePasswdOnHost();
|
||||
// get agents for the cluster
|
||||
final List<Long> hostIds = _hostDao.listAllHostIdsInCluster(command.getClusterId());
|
||||
final List<Long> hostIds = _hostDao.listIdsByClusterId(command.getClusterId());
|
||||
for (final Long hostId : hostIds) {
|
||||
try {
|
||||
final Boolean result = propagateResourceEvent(hostId, ResourceState.Event.UpdatePassword);
|
||||
|
|
|
|||
|
|
@ -4860,7 +4860,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
|||
|
||||
private boolean updateHostsInCluster(final UpdateHostPasswordCmd command) {
|
||||
// get all the hosts in this cluster
|
||||
final List<Long> hostIds = _hostDao.listAllHostIdsInCluster(command.getClusterId());
|
||||
final List<Long> hostIds = _hostDao.listIdsByClusterId(command.getClusterId());
|
||||
|
||||
String userNameWithoutSpaces = StringUtils.deleteWhitespace(command.getUsername());
|
||||
if (StringUtils.isBlank(userNameWithoutSpaces)) {
|
||||
|
|
|
|||
|
|
@ -285,11 +285,11 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
&& isOutOfBandManagementEnabledForHost(host.getId());
|
||||
}
|
||||
|
||||
public boolean transitionPowerStateToDisabled(List<? extends Host> hosts) {
|
||||
public boolean transitionPowerStateToDisabled(List<Long> hostIds) {
|
||||
boolean result = true;
|
||||
for (Host host : hosts) {
|
||||
for (Long hostId : hostIds) {
|
||||
result = result && transitionPowerState(OutOfBandManagement.PowerState.Event.Disabled,
|
||||
outOfBandManagementDao.findByHost(host.getId()));
|
||||
outOfBandManagementDao.findByHost(hostId));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -318,7 +318,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE, eventDescription = "disabling out-of-band management on a zone")
|
||||
public OutOfBandManagementResponse disableOutOfBandManagement(final DataCenter zone) {
|
||||
dataCenterDetailsDao.persist(zone.getId(), OOBM_ENABLED_DETAIL, String.valueOf(false));
|
||||
transitionPowerStateToDisabled(hostDao.findByDataCenterId(zone.getId()));
|
||||
transitionPowerStateToDisabled(hostDao.listIdsByDataCenterId(zone.getId()));
|
||||
|
||||
return buildEnableDisableResponse(false);
|
||||
}
|
||||
|
|
@ -334,7 +334,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
@ActionEvent(eventType = EventTypes.EVENT_HOST_OUTOFBAND_MANAGEMENT_DISABLE, eventDescription = "disabling out-of-band management on a cluster")
|
||||
public OutOfBandManagementResponse disableOutOfBandManagement(final Cluster cluster) {
|
||||
clusterDetailsDao.persist(cluster.getId(), OOBM_ENABLED_DETAIL, String.valueOf(false));
|
||||
transitionPowerStateToDisabled(hostDao.findByClusterId(cluster.getId()));
|
||||
transitionPowerStateToDisabled(hostDao.listIdsByClusterId(cluster.getId()));
|
||||
return buildEnableDisableResponse(false);
|
||||
}
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
outOfBandManagementConfig.setEnabled(true);
|
||||
boolean updateResult = outOfBandManagementDao.update(outOfBandManagementConfig.getId(), (OutOfBandManagementVO) outOfBandManagementConfig);
|
||||
if (updateResult) {
|
||||
transitionPowerStateToDisabled(Collections.singletonList(host));
|
||||
transitionPowerStateToDisabled(Collections.singletonList(host.getId()));
|
||||
}
|
||||
return buildEnableDisableResponse(true);
|
||||
}
|
||||
|
|
@ -367,7 +367,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
outOfBandManagementConfig.setEnabled(false);
|
||||
boolean updateResult = outOfBandManagementDao.update(outOfBandManagementConfig.getId(), (OutOfBandManagementVO) outOfBandManagementConfig);
|
||||
if (updateResult) {
|
||||
transitionPowerStateToDisabled(Collections.singletonList(host));
|
||||
transitionPowerStateToDisabled(Collections.singletonList(host.getId()));
|
||||
}
|
||||
return buildEnableDisableResponse(false);
|
||||
}
|
||||
|
|
@ -578,7 +578,7 @@ public class OutOfBandManagementServiceImpl extends ManagerBase implements OutOf
|
|||
if (isOutOfBandManagementEnabled(host)) {
|
||||
submitBackgroundPowerSyncTask(host);
|
||||
} else if (outOfBandManagementHost.getPowerState() != OutOfBandManagement.PowerState.Disabled) {
|
||||
if (transitionPowerStateToDisabled(Collections.singletonList(host))) {
|
||||
if (transitionPowerStateToDisabled(Collections.singletonList(host.getId()))) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug(String.format("Out-of-band management was disabled in zone/cluster/host, disabled power state for %s", host));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -733,7 +733,7 @@ public class ConfigurationManagerTest {
|
|||
|
||||
@Test
|
||||
public void checkIfZoneIsDeletableSuccessTest() {
|
||||
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
|
||||
Mockito.when(_hostDao.listEnabledIdsByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
|
||||
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
|
||||
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
|
|
@ -747,11 +747,7 @@ public class ConfigurationManagerTest {
|
|||
|
||||
@Test(expected = CloudRuntimeException.class)
|
||||
public void checkIfZoneIsDeletableFailureOnHostTest() {
|
||||
HostVO hostVO = Mockito.mock(HostVO.class);
|
||||
ArrayList<HostVO> arrayList = new ArrayList<HostVO>();
|
||||
arrayList.add(hostVO);
|
||||
|
||||
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(arrayList);
|
||||
Mockito.when(_hostDao.listEnabledIdsByDataCenterId(anyLong())).thenReturn(List.of(1L));
|
||||
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
|
||||
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
|
|
@ -769,7 +765,7 @@ public class ConfigurationManagerTest {
|
|||
ArrayList<HostPodVO> arrayList = new ArrayList<HostPodVO>();
|
||||
arrayList.add(hostPodVO);
|
||||
|
||||
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
|
||||
Mockito.when(_hostDao.listEnabledIdsByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
|
||||
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(arrayList);
|
||||
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
|
|
@ -783,7 +779,7 @@ public class ConfigurationManagerTest {
|
|||
|
||||
@Test(expected = CloudRuntimeException.class)
|
||||
public void checkIfZoneIsDeletableFailureOnPrivateIpAddressTest() {
|
||||
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
|
||||
Mockito.when(_hostDao.listEnabledIdsByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
|
||||
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
|
||||
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(1);
|
||||
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
|
|
@ -797,7 +793,7 @@ public class ConfigurationManagerTest {
|
|||
|
||||
@Test(expected = CloudRuntimeException.class)
|
||||
public void checkIfZoneIsDeletableFailureOnPublicIpAddressTest() {
|
||||
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
|
||||
Mockito.when(_hostDao.listEnabledIdsByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
|
||||
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
|
||||
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(1);
|
||||
|
|
@ -815,7 +811,7 @@ public class ConfigurationManagerTest {
|
|||
ArrayList<VMInstanceVO> arrayList = new ArrayList<VMInstanceVO>();
|
||||
arrayList.add(vMInstanceVO);
|
||||
|
||||
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
|
||||
Mockito.when(_hostDao.listEnabledIdsByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
|
||||
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
|
||||
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
|
|
@ -833,7 +829,7 @@ public class ConfigurationManagerTest {
|
|||
ArrayList<VolumeVO> arrayList = new ArrayList<VolumeVO>();
|
||||
arrayList.add(volumeVO);
|
||||
|
||||
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
|
||||
Mockito.when(_hostDao.listEnabledIdsByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
|
||||
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
|
||||
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
|
|
@ -851,7 +847,7 @@ public class ConfigurationManagerTest {
|
|||
ArrayList<PhysicalNetworkVO> arrayList = new ArrayList<PhysicalNetworkVO>();
|
||||
arrayList.add(physicalNetworkVO);
|
||||
|
||||
Mockito.when(_hostDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostVO>());
|
||||
Mockito.when(_hostDao.listEnabledIdsByDataCenterId(anyLong())).thenReturn(new ArrayList<>());
|
||||
Mockito.when(_podDao.listByDataCenterId(anyLong())).thenReturn(new ArrayList<HostPodVO>());
|
||||
Mockito.when(_privateIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
Mockito.when(_publicIpAddressDao.countIPs(anyLong(), anyBoolean())).thenReturn(0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue