Skip to content

Commit 3ebd22d

Browse files
committed
CLOUDSTACK-10001: Fix incorrect total host memory in responses
This fixes incorrect total host memory in listHosts and related host responses, regression introduced in apache#2120. Signed-off-by: Rohit Yadav <[email protected]>
1 parent 53139aa commit 3ebd22d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail
159159
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
160160
Long cpu = host.getCpuReservedCapacity() + host.getCpuUsedCapacity();
161161

162-
hostResponse.setMemoryTotal(mem);
163-
Float totalMemorywithOverprovisioning=new Float((host.getTotalMemory()*ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId())));
162+
hostResponse.setMemoryTotal(host.getTotalMemory());
163+
Float totalMemorywithOverprovisioning = host.getTotalMemory() * ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
164164
hostResponse.setMemWithOverprovisioning(totalMemorywithOverprovisioning.toString());
165165
hostResponse.setMemoryAllocated(mem);
166166

@@ -180,7 +180,7 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail
180180

181181
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
182182

183-
Float cpuWithOverprovisioning = new Float(host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId()));
183+
Float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
184184
String cpuAlloc = decimalFormat.format(((float)cpu / cpuWithOverprovisioning * 100f)) + "%";
185185
hostResponse.setCpuAllocated(cpuAlloc);
186186
hostResponse.setCpuWithOverprovisioning(cpuWithOverprovisioning.toString());
@@ -308,10 +308,10 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu
308308
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
309309
Long cpu = host.getCpuReservedCapacity() + host.getCpuReservedCapacity();
310310

311-
hostResponse.setMemoryTotal(mem);
312-
Float memWithOverprovisioning =new Float((host.getTotalMemory()*ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId())));
311+
hostResponse.setMemoryTotal(host.getTotalMemory());
312+
Float memWithOverprovisioning = host.getTotalMemory() * ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
313313
hostResponse.setMemWithOverprovisioning(memWithOverprovisioning.toString());
314-
hostResponse.setMemoryAllocated(decimalFormat.format((float)mem/ memWithOverprovisioning*100f).toString()+"%");
314+
hostResponse.setMemoryAllocated(decimalFormat.format((float) mem / memWithOverprovisioning * 100.0f) +"%");
315315

316316
String hostTags = host.getTag();
317317
hostResponse.setHostTags(host.getTag());

0 commit comments

Comments
 (0)