Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ public String toString() {
}

public enum HostDetails {
all, capacity, events, stats, min;
all, capacity, core, events, stats, min;
}

public enum VMDetails {
Expand Down
74 changes: 42 additions & 32 deletions server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,15 @@ private void setNewHostResponseBase(HostJoinVO host, EnumSet<HostDetails> detail
hostResponse.setLastPinged(new Date(host.getLastPinged()));
Long mshostId = host.getManagementServerId();
if (mshostId != null) {
ManagementServerHostVO managementServer = managementServerHostDao.findByMsid(host.getManagementServerId());
if (managementServer != null) {
hostResponse.setManagementServerId(managementServer.getUuid());
hostResponse.setManagementServerName(managementServer.getName());
if (details.contains(HostDetails.core)) {
// msid is returned as-is; callers resolve it to avoid a per-host lookup
hostResponse.setManagementServerId(mshostId.toString());
} else {
ManagementServerHostVO managementServer = managementServerHostDao.findByMsid(host.getManagementServerId());
if (managementServer != null) {
hostResponse.setManagementServerId(managementServer.getUuid());
hostResponse.setManagementServerName(managementServer.getName());
}
}
}
hostResponse.setName(host.getName());
Expand Down Expand Up @@ -189,9 +194,12 @@ private void setNewHostResponseBase(HostJoinVO host, EnumSet<HostDetails> detail
hostResponse.setGpuGroup(gpus);
}
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity) || details.contains(HostDetails.stats) || details.contains(HostDetails.events)) {

hostResponse.setOsCategoryId(host.getOsCategoryUuid());
hostResponse.setOsCategoryName(host.getOsCategoryName());
}

if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity) || details.contains(HostDetails.core) ||
details.contains(HostDetails.stats) || details.contains(HostDetails.events)) {
hostResponse.setZoneName(host.getZoneName());
hostResponse.setPodName(host.getPodName());
if (host.getClusterId() > 0) {
Expand All @@ -203,42 +211,44 @@ private void setNewHostResponseBase(HostJoinVO host, EnumSet<HostDetails> detail
DecimalFormat decimalFormat = new DecimalFormat("#.##");
if (host.getType() == Host.Type.Routing) {
float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)) {
// set allocated capacities
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
Long cpu = host.getCpuReservedCapacity() + host.getCpuUsedCapacity();

Float memWithOverprovisioning = host.getTotalMemory() * ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
hostResponse.setMemoryTotal(memWithOverprovisioning.longValue());
hostResponse.setMemWithOverprovisioning(decimalFormat.format(memWithOverprovisioning));
hostResponse.setMemoryAllocated(mem);
hostResponse.setMemoryAllocatedBytes(mem);
hostResponse.setMemoryAllocatedPercentage(calculateResourceAllocatedPercentage(mem, memWithOverprovisioning));

if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity) || details.contains(HostDetails.core)) {
String hostTags = host.getTag();
hostResponse.setHostTags(hostTags);
hostResponse.setIsTagARule(host.getIsTagARule());
hostResponse.setHaHost(containsHostHATag(hostTags));
hostResponse.setExplicitHostTags(host.getExplicitTag());
hostResponse.setImplicitHostTags(host.getImplicitTag());

hostResponse.setHypervisorVersion(host.getHypervisorVersion());
if (host.getArch() != null) {
hostResponse.setArch(host.getArch().getType());
}

hostResponse.setStorageAccessGroups(host.getStorageAccessGroups());
hostResponse.setClusterStorageAccessGroups(host.getClusterStorageAccessGroups());
hostResponse.setPodStorageAccessGroups(host.getPodStorageAccessGroups());
hostResponse.setZoneStorageAccessGroups(host.getZoneStorageAccessGroups());

float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * cpuOverprovisioningFactor;
hostResponse.setCpuAllocatedValue(cpu);
String cpuAllocated = calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning);
hostResponse.setCpuAllocated(cpuAllocated);
hostResponse.setCpuAllocatedPercentage(cpuAllocated);
hostResponse.setCpuAllocatedWithOverprovisioning(cpuAllocated);
hostResponse.setCpuWithOverprovisioning(decimalFormat.format(cpuWithOverprovisioning));
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)) {
// set allocated capacities
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
Long cpu = host.getCpuReservedCapacity() + host.getCpuUsedCapacity();

Float memWithOverprovisioning = host.getTotalMemory() * ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
hostResponse.setMemoryTotal(memWithOverprovisioning.longValue());
hostResponse.setMemWithOverprovisioning(decimalFormat.format(memWithOverprovisioning));
hostResponse.setMemoryAllocated(mem);
hostResponse.setMemoryAllocatedBytes(mem);
hostResponse.setMemoryAllocatedPercentage(calculateResourceAllocatedPercentage(mem, memWithOverprovisioning));

hostResponse.setIsTagARule(host.getIsTagARule());
hostResponse.setHaHost(containsHostHATag(hostTags));

hostResponse.setHypervisorVersion(host.getHypervisorVersion());
if (host.getArch() != null) {
hostResponse.setArch(host.getArch().getType());
}

float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * cpuOverprovisioningFactor;
hostResponse.setCpuAllocatedValue(cpu);
String cpuAllocated = calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning);
hostResponse.setCpuAllocated(cpuAllocated);
hostResponse.setCpuAllocatedPercentage(cpuAllocated);
hostResponse.setCpuAllocatedWithOverprovisioning(cpuAllocated);
hostResponse.setCpuWithOverprovisioning(decimalFormat.format(cpuWithOverprovisioning));
}
}

if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
Expand Down
Loading