This is an automated email from the ASF dual-hosted git repository.

dahn pushed a commit to branch 4.14
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.14 by this push:
     new d79d242  Adding memoryallocatedpercentage & memoryallocatedbytes to 
HostsResponse & HostsForMigrationResponse (#4478)
d79d242 is described below

commit d79d24261a69769a481b71e6a74e197b76fcdf58
Author: davidjumani <[email protected]>
AuthorDate: Fri Nov 20 16:57:47 2020 +0530

    Adding memoryallocatedpercentage & memoryallocatedbytes to HostsResponse & 
HostsForMigrationResponse (#4478)
---
 .../api/response/HostForMigrationResponse.java          | 17 +++++++++++++++++
 .../apache/cloudstack/api/response/HostResponse.java    | 17 +++++++++++++++++
 .../java/com/cloud/api/query/dao/HostJoinDaoImpl.java   | 12 +++++++++---
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git 
a/api/src/main/java/org/apache/cloudstack/api/response/HostForMigrationResponse.java
 
b/api/src/main/java/org/apache/cloudstack/api/response/HostForMigrationResponse.java
index 8cc3109..e4a84a3 100644
--- 
a/api/src/main/java/org/apache/cloudstack/api/response/HostForMigrationResponse.java
+++ 
b/api/src/main/java/org/apache/cloudstack/api/response/HostForMigrationResponse.java
@@ -128,10 +128,19 @@ public class HostForMigrationResponse extends 
BaseResponse {
     @Param(description = "the outgoing network traffic on the host")
     private Long networkKbsWrite;
 
+    @Deprecated
     @SerializedName("memoryallocated")
     @Param(description = "the amount of the host's memory currently allocated")
     private String memoryAllocated;
 
+    @SerializedName("memoryallocatedpercentage")
+    @Param(description = "the amount of the host's memory currently allocated 
in percentage")
+    private String memoryAllocatedPercentage;
+
+    @SerializedName("memoryallocatedbytes")
+    @Param(description = "the amount of the host's memory currently allocated 
in bytes")
+    private Long memoryAllocatedBytes;
+
     @SerializedName("memoryused")
     @Param(description = "the amount of the host's memory currently used")
     private Long memoryUsed;
@@ -314,6 +323,14 @@ public class HostForMigrationResponse extends BaseResponse 
{
         this.memoryAllocated = memoryAllocated;
     }
 
+    public void setMemoryAllocatedPercentage(String memoryAllocatedPercentage) 
{
+        this.memoryAllocatedPercentage = memoryAllocatedPercentage;
+    }
+
+    public void setMemoryAllocatedBytes(Long memoryAllocatedBytes) {
+        this.memoryAllocatedBytes = memoryAllocatedBytes;
+    }
+
     public void setMemoryUsed(Long memoryUsed) {
         this.memoryUsed = memoryUsed;
     }
diff --git 
a/api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java 
b/api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java
index 61a662f..7b80f22 100644
--- a/api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java
+++ b/api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java
@@ -136,10 +136,19 @@ public class HostResponse extends BaseResponse {
     @Param(description = "the amount of the host's memory after applying the 
mem.overprovisioning.factor")
     private String memWithOverprovisioning;
 
+    @Deprecated
     @SerializedName("memoryallocated")
     @Param(description = "the amount of the host's memory currently allocated")
     private long memoryAllocated;
 
+    @SerializedName("memoryallocatedpercentage")
+    @Param(description = "the amount of the host's memory currently allocated 
in percentage")
+    private String memoryAllocatedPercentage;
+
+    @SerializedName("memoryallocatedbytes")
+    @Param(description = "the amount of the host's memory currently allocated 
in bytes")
+    private Long memoryAllocatedBytes;
+
     @SerializedName("memoryused")
     @Param(description = "the amount of the host's memory currently used")
     private Long memoryUsed;
@@ -609,6 +618,14 @@ public class HostResponse extends BaseResponse {
         return memoryAllocated;
     }
 
+    public void setMemoryAllocatedPercentage(String memoryAllocatedPercentage) 
{
+        this.memoryAllocatedPercentage = memoryAllocatedPercentage;
+    }
+
+    public void setMemoryAllocatedBytes(Long memoryAllocatedBytes) {
+        this.memoryAllocatedBytes = memoryAllocatedBytes;
+    }
+
     public Long getMemoryUsed() {
         return memoryUsed;
     }
diff --git a/server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java 
b/server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java
index 8b4220c..9f5bfee 100644
--- a/server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java
+++ b/server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java
@@ -170,9 +170,12 @@ public class HostJoinDaoImpl extends 
GenericDaoBase<HostJoinVO, Long> implements
                 Long cpu = host.getCpuReservedCapacity() + 
host.getCpuUsedCapacity();
 
                 hostResponse.setMemoryTotal(host.getTotalMemory());
-                Float totalMemorywithOverprovisioning = host.getTotalMemory() 
* ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
-                
hostResponse.setMemWithOverprovisioning(decimalFormat.format(totalMemorywithOverprovisioning));
+                Float memWithOverprovisioning = host.getTotalMemory() * 
ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
+                
hostResponse.setMemWithOverprovisioning(decimalFormat.format(memWithOverprovisioning));
                 hostResponse.setMemoryAllocated(mem);
+                hostResponse.setMemoryAllocatedBytes(mem);
+                String memoryAllocatedPercentage = 
decimalFormat.format((float) mem / memWithOverprovisioning * 100.0f) +"%";
+                
hostResponse.setMemoryAllocatedPercentage(memoryAllocatedPercentage);
 
                 String hostTags = host.getTag();
                 hostResponse.setHostTags(host.getTag());
@@ -321,7 +324,10 @@ public class HostJoinDaoImpl extends 
GenericDaoBase<HostJoinVO, Long> implements
                 hostResponse.setMemoryTotal(host.getTotalMemory());
                 Float memWithOverprovisioning = host.getTotalMemory() * 
ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
                 
hostResponse.setMemWithOverprovisioning(decimalFormat.format(memWithOverprovisioning));
-                hostResponse.setMemoryAllocated(decimalFormat.format((float) 
mem / memWithOverprovisioning * 100.0f) +"%");
+                String memoryAllocatedPercentage = 
decimalFormat.format((float) mem / memWithOverprovisioning * 100.0f) +"%";
+                hostResponse.setMemoryAllocated(memoryAllocatedPercentage);
+                
hostResponse.setMemoryAllocatedPercentage(memoryAllocatedPercentage);
+                hostResponse.setMemoryAllocatedBytes(mem);
 
                 String hostTags = host.getTag();
                 hostResponse.setHostTags(host.getTag());

Reply via email to