Skip to content

Commit c4483e3

Browse files
committed
Adding cpuallocatedwithoverprovisoning to hostresponse and hostsformigrationresponse
1 parent 81ac9f9 commit c4483e3

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

api/src/main/java/org/apache/cloudstack/api/response/HostForMigrationResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ public class HostForMigrationResponse extends BaseResponse {
9999
@Param(description = "the amount of the host's CPU currently allocated")
100100
private String cpuAllocated;
101101

102+
@SerializedName("cpuallocatedwithoverprovisioning")
103+
@Param(description = "the amount of the host's CPU currently allocated after applying the cpu.overprovisioning.factor")
104+
private String cpuAllocatedWithOverprovisioning;
105+
102106
@SerializedName("cpuused")
103107
@Param(description = "the amount of the host's CPU currently used")
104108
private String cpuUsed;
@@ -303,6 +307,10 @@ public void setCpuAllocated(String cpuAllocated) {
303307
this.cpuAllocated = cpuAllocated;
304308
}
305309

310+
public void setCpuAllocatedWithOverprovisioning(String cpuAllocatedWithOverprovisioning) {
311+
this.cpuAllocatedWithOverprovisioning = cpuAllocatedWithOverprovisioning;
312+
}
313+
306314
public void setCpuUsed(String cpuUsed) {
307315
this.cpuUsed = cpuUsed;
308316
}

api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,16 @@ public class HostResponse extends BaseResponse {
107107
@Param(description = "the amount of the host's CPU currently allocated")
108108
private String cpuAllocated;
109109

110+
@SerializedName("cpuallocatedwithoverprovisioning")
111+
@Param(description = "the amount of the host's CPU currently allocated after applying the cpu.overprovisioning.factor")
112+
private String cpuAllocatedWithOverprovisioning;
113+
110114
@SerializedName("cpuused")
111115
@Param(description = "the amount of the host's CPU currently used")
112116
private String cpuUsed;
113117

114118
@SerializedName("cpuwithoverprovisioning")
115-
@Param(description = "the amount of the host's CPU after applying the cpu.overprovisioning.factor ")
119+
@Param(description = "the amount of the host's CPU after applying the cpu.overprovisioning.factor")
116120
private String cpuWithOverprovisioning;
117121

118122
@SerializedName(ApiConstants.CPU_LOAD_AVERAGE)
@@ -342,6 +346,10 @@ public void setCpuAllocated(String cpuAllocated) {
342346
this.cpuAllocated = cpuAllocated;
343347
}
344348

349+
public void setCpuAllocatedWithOverprovisioning(String cpuAllocatedWithOverprovisioning) {
350+
this.cpuAllocatedWithOverprovisioning = cpuAllocatedWithOverprovisioning;
351+
}
352+
345353
public void setCpuUsed(String cpuUsed) {
346354
this.cpuUsed = cpuUsed;
347355
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,10 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail
193193

194194
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
195195

196+
String cpuAlloc = decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "%";
197+
hostResponse.setCpuAllocated(cpuAlloc);
196198
float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
197-
hostResponse.setCpuAllocated(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
199+
hostResponse.setCpuAllocatedWithOverprovisioning(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
198200
hostResponse.setCpuWithOverprovisioning(decimalFormat.format(cpuWithOverprovisioning));
199201
}
200202

@@ -345,8 +347,10 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu
345347

346348
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
347349

350+
String cpuAlloc = decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "%";
351+
hostResponse.setCpuAllocated(cpuAlloc);
348352
float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
349-
hostResponse.setCpuAllocated(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
353+
hostResponse.setCpuAllocatedWithOverprovisioning(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
350354
hostResponse.setCpuWithOverprovisioning(decimalFormat.format(cpuWithOverprovisioning));
351355
}
352356

0 commit comments

Comments
 (0)