FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Adding cpuallocated percentage and value to host and hostsformigrationresponse by davidjumani · Pull Request #4499 · apache/cloudstack · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL