Skip to content

Commit 9225922

Browse files
authored
Merge pull request #566 from jschoiRR/mold-diplo-2024-main
[Mold API] 쿠버네티스 클러스터 생성시 호스트 리소스 정보 조회 메소드 추가
2 parents 667888e + 7c71f07 commit 9225922

File tree

5 files changed

+22
-3
lines changed

5 files changed

+22
-3
lines changed

engine/components-api/src/main/java/com/cloud/resource/ResourceManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ public interface ResourceManager extends ResourceService, Configurable {
126126

127127
public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(HypervisorType type, long dcId);
128128

129+
public List<HostVO> listAllUpAndEnabledHostsAndRoutingTypeInOneZoneByHypervisor(HypervisorType type, long dcId);
130+
129131
public List<HostVO> listAllUpHostsInOneZoneByHypervisor(HypervisorType type, long dcId);
130132

131133
public List<HostVO> listAllUpAndEnabledHostsInOneZone(long dcId);

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@
9999
import com.cloud.exception.InvalidParameterValueException;
100100
import com.cloud.exception.PermissionDeniedException;
101101
import com.cloud.exception.ResourceAllocationException;
102-
import com.cloud.host.Host.Type;
103102
import com.cloud.host.HostVO;
104103
import com.cloud.host.dao.HostDao;
105104
import com.cloud.hypervisor.Hypervisor;
105+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
106106
import com.cloud.kubernetes.cluster.actionworkers.KubernetesClusterActionWorker;
107107
import com.cloud.kubernetes.cluster.actionworkers.KubernetesClusterDestroyWorker;
108108
import com.cloud.kubernetes.cluster.actionworkers.KubernetesClusterScaleWorker;
@@ -497,7 +497,7 @@ private void validateDockerRegistryParams(final String dockerRegistryUserName,
497497
private DeployDestination plan(final long nodesCount, final DataCenter zone, final ServiceOffering offering) throws InsufficientServerCapacityException {
498498
final int cpu_requested = offering.getCpu() * offering.getSpeed();
499499
final long ram_requested = offering.getRamSize() * 1024L * 1024L;
500-
List<HostVO> hosts = resourceManager.listAllHostsInOneZoneByType(Type.Routing, zone.getId());
500+
List<HostVO> hosts = resourceManager.listAllUpAndEnabledHostsAndRoutingTypeInOneZoneByHypervisor(HypervisorType.KVM, zone.getId());
501501
final Map<String, Pair<HostVO, Integer>> hosts_with_resevered_capacity = new ConcurrentHashMap<String, Pair<HostVO, Integer>>();
502502
for (HostVO h : hosts) {
503503
hosts_with_resevered_capacity.put(h.getUuid(), new Pair<HostVO, Integer>(h, 0));

server/src/main/java/com/cloud/api/ApiServlet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ void processRequestInContext(final HttpServletRequest req, final HttpServletResp
373373
LOGGER.error("unknown exception writing api response", ex);
374374
auditTrailSb.append(" unknown exception writing api response");
375375
} finally {
376-
LOGGER.info(auditTrailSb.toString());
376+
LOGGER.debug(auditTrailSb.toString());
377377
if (LOGGER.isDebugEnabled()) {
378378
LOGGER.debug("===END=== " + reqStr);
379379
}

server/src/main/java/com/cloud/resource/ResourceManagerImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,6 +3389,17 @@ public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(final Hypervis
33893389
return sc.list();
33903390
}
33913391

3392+
@Override
3393+
public List<HostVO> listAllUpAndEnabledHostsAndRoutingTypeInOneZoneByHypervisor(final HypervisorType type, final long dcId) {
3394+
final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);
3395+
sc.and(sc.entity().getType(), Op.EQ, Host.Type.Routing);
3396+
sc.and(sc.entity().getHypervisorType(), Op.EQ, type);
3397+
sc.and(sc.entity().getDataCenterId(), Op.EQ, dcId);
3398+
sc.and(sc.entity().getStatus(), Op.EQ, Status.Up);
3399+
sc.and(sc.entity().getResourceState(), Op.EQ, ResourceState.Enabled);
3400+
return sc.list();
3401+
}
3402+
33923403
@Override
33933404
public List<HostVO> listAllUpHostsInOneZoneByHypervisor(final HypervisorType type, final long dcId) {
33943405
final QueryBuilder<HostVO> sc = QueryBuilder.create(HostVO.class);

server/src/test/java/com/cloud/resource/MockResourceManagerImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,12 @@ public List<HostVO> listAllUpAndEnabledHostsInOneZoneByHypervisor(final Hypervis
601601
return null;
602602
}
603603

604+
@Override
605+
public List<HostVO> listAllUpAndEnabledHostsAndRoutingTypeInOneZoneByHypervisor(final HypervisorType type, final long dcId) {
606+
// TODO Auto-generated method stub
607+
return null;
608+
}
609+
604610
@Override
605611
public List<HostVO> listAllUpHostsInOneZoneByHypervisor(final HypervisorType type, final long dcId) {
606612
// TODO Auto-generated method stub

0 commit comments

Comments
 (0)