mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Adding cpuallocated percentage and value to host and hostsformigrationresponse (#4499)
* Adding cpuallocatedwithoverprovisoning to hostresponse and hostsformigrationresponse * Adding cpuallocatedpercentage and cpuallocatedvalue
This commit is contained in:
parent
e82813b509
commit
afebfd5bbf
@ -95,10 +95,23 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||||||
@Param(description = "the CPU speed of the host")
|
@Param(description = "the CPU speed of the host")
|
||||||
private Long cpuSpeed;
|
private Long cpuSpeed;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@SerializedName("cpuallocated")
|
@SerializedName("cpuallocated")
|
||||||
@Param(description = "the amount of the host's CPU currently allocated")
|
@Param(description = "the amount of the host's CPU currently allocated")
|
||||||
private String cpuAllocated;
|
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")
|
@SerializedName("cpuused")
|
||||||
@Param(description = "the amount of the host's CPU currently used")
|
@Param(description = "the amount of the host's CPU currently used")
|
||||||
private String cpuUsed;
|
private String cpuUsed;
|
||||||
@ -303,6 +316,18 @@ public class HostForMigrationResponse extends BaseResponse {
|
|||||||
this.cpuAllocated = 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) {
|
public void setCpuUsed(String cpuUsed) {
|
||||||
this.cpuUsed = cpuUsed;
|
this.cpuUsed = cpuUsed;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,10 +103,23 @@ public class HostResponse extends BaseResponse {
|
|||||||
@Param(description = "the CPU speed of the host")
|
@Param(description = "the CPU speed of the host")
|
||||||
private Long cpuSpeed;
|
private Long cpuSpeed;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
@SerializedName("cpuallocated")
|
@SerializedName("cpuallocated")
|
||||||
@Param(description = "the amount of the host's CPU currently allocated")
|
@Param(description = "the amount of the host's CPU currently allocated")
|
||||||
private String cpuAllocated;
|
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")
|
@SerializedName("cpuused")
|
||||||
@Param(description = "the amount of the host's CPU currently used")
|
@Param(description = "the amount of the host's CPU currently used")
|
||||||
private String cpuUsed;
|
private String cpuUsed;
|
||||||
@ -342,6 +355,18 @@ public class HostResponse extends BaseResponse {
|
|||||||
this.cpuAllocated = 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) {
|
public void setCpuUsed(String cpuUsed) {
|
||||||
this.cpuUsed = cpuUsed;
|
this.cpuUsed = cpuUsed;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -193,8 +193,12 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
|
|
||||||
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
|
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());
|
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));
|
hostResponse.setCpuWithOverprovisioning(decimalFormat.format(cpuWithOverprovisioning));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,8 +349,12 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
|
|
||||||
hostResponse.setHypervisorVersion(host.getHypervisorVersion());
|
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());
|
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));
|
hostResponse.setCpuWithOverprovisioning(decimalFormat.format(cpuWithOverprovisioning));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user