Skip to content
Merged
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 @@ -95,10 +95,23 @@ public class HostForMigrationResponse extends BaseResponse {
@Param(description = "the CPU speed of the host")
private Long cpuSpeed;

@Deprecated
@SerializedName("cpuallocated")
@Param(description = "the amount of the host's CPU currently allocated")
private String cpuAllocated;

@SerializedName("cpuallocatedvalue")
@Param(description = "the amount of the host's CPU currently allocated in MHz")
private Long cpuAllocatedValue;

@SerializedName("cpuallocatedpercentage")
@Param(description = "the amount of the host's CPU currently allocated in percentage")
private String cpuAllocatedPercentage;

@SerializedName("cpuallocatedwithoverprovisioning")
@Param(description = "the amount of the host's CPU currently allocated after applying the cpu.overprovisioning.factor")
private String cpuAllocatedWithOverprovisioning;

@SerializedName("cpuused")
@Param(description = "the amount of the host's CPU currently used")
private String cpuUsed;
Expand Down Expand Up @@ -303,6 +316,18 @@ public void setCpuAllocated(String cpuAllocated) {
this.cpuAllocated = cpuAllocated;
}

public void setCpuAllocatedValue(Long cpuAllocatedValue) {
this.cpuAllocatedValue = cpuAllocatedValue;
}

public void setCpuAllocatedPercentage(String cpuAllocatedPercentage) {
this.cpuAllocatedPercentage = cpuAllocatedPercentage;
}

public void setCpuAllocatedWithOverprovisioning(String cpuAllocatedWithOverprovisioning) {
this.cpuAllocatedWithOverprovisioning = cpuAllocatedWithOverprovisioning;
}

public void setCpuUsed(String cpuUsed) {
this.cpuUsed = cpuUsed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,29 @@ public class HostResponse extends BaseResponse {
@Param(description = "the CPU speed of the host")
private Long cpuSpeed;

@Deprecated
@SerializedName("cpuallocated")
@Param(description = "the amount of the host's CPU currently allocated")
private String cpuAllocated;

@SerializedName("cpuallocatedvalue")
@Param(description = "the amount of the host's CPU currently allocated in MHz")
private Long cpuAllocatedValue;

@SerializedName("cpuallocatedpercentage")
@Param(description = "the amount of the host's CPU currently allocated in percentage")
private String cpuAllocatedPercentage;

@SerializedName("cpuallocatedwithoverprovisioning")
@Param(description = "the amount of the host's CPU currently allocated after applying the cpu.overprovisioning.factor")
private String cpuAllocatedWithOverprovisioning;

@SerializedName("cpuused")
@Param(description = "the amount of the host's CPU currently used")
private String cpuUsed;

@SerializedName("cpuwithoverprovisioning")
@Param(description = "the amount of the host's CPU after applying the cpu.overprovisioning.factor ")
@Param(description = "the amount of the host's CPU after applying the cpu.overprovisioning.factor")
private String cpuWithOverprovisioning;

@SerializedName(ApiConstants.CPU_LOAD_AVERAGE)
Expand Down Expand Up @@ -342,6 +355,18 @@ public void setCpuAllocated(String cpuAllocated) {
this.cpuAllocated = cpuAllocated;
}

public void setCpuAllocatedValue(Long cpuAllocatedValue) {
this.cpuAllocatedValue = cpuAllocatedValue;
}

public void setCpuAllocatedPercentage(String cpuAllocatedPercentage) {
this.cpuAllocatedPercentage = cpuAllocatedPercentage;
}

public void setCpuAllocatedWithOverprovisioning(String cpuAllocatedWithOverprovisioning) {
this.cpuAllocatedWithOverprovisioning = cpuAllocatedWithOverprovisioning;
}

public void setCpuUsed(String cpuUsed) {
this.cpuUsed = cpuUsed;
}
Expand Down
12 changes: 10 additions & 2 deletions server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,12 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail

hostResponse.setHypervisorVersion(host.getHypervisorVersion());

hostResponse.setCpuAllocatedValue(cpu);
String cpuAlloc = decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "%";
hostResponse.setCpuAllocated(cpuAlloc);
hostResponse.setCpuAllocatedPercentage(cpuAlloc);
float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
hostResponse.setCpuAllocated(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
hostResponse.setCpuAllocatedWithOverprovisioning(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
hostResponse.setCpuWithOverprovisioning(decimalFormat.format(cpuWithOverprovisioning));
}

Expand Down Expand Up @@ -345,8 +349,12 @@ public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, Enu

hostResponse.setHypervisorVersion(host.getHypervisorVersion());

hostResponse.setCpuAllocatedValue(cpu);
String cpuAlloc = decimalFormat.format(((float)cpu / (float)(host.getCpus() * host.getSpeed())) * 100f) + "%";
hostResponse.setCpuAllocated(cpuAlloc);
hostResponse.setCpuAllocatedPercentage(cpuAlloc);
float cpuWithOverprovisioning = host.getCpus() * host.getSpeed() * ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
hostResponse.setCpuAllocated(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
hostResponse.setCpuAllocatedWithOverprovisioning(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
hostResponse.setCpuWithOverprovisioning(decimalFormat.format(cpuWithOverprovisioning));
}

Expand Down