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

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


The following commit(s) were added to refs/heads/main by this push:
     new 9083a677ae1 systeminstances field (#7871)
9083a677ae1 is described below

commit 9083a677ae132c5ce4da2f73b4f04ec2356b33b5
Author: sato03 <[email protected]>
AuthorDate: Sun Aug 20 10:41:07 2023 -0300

    systeminstances field (#7871)
    
    Co-authored-by: Henrique Sato <[email protected]>
---
 .../org/apache/cloudstack/metrics/MetricsServiceImpl.java  | 12 ++++++++++--
 .../apache/cloudstack/response/HostMetricsResponse.java    | 14 ++++++++++----
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git 
a/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java
 
b/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java
index 979e4aacbe7..a27896aa58d 100644
--- 
a/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java
+++ 
b/plugins/metrics/src/main/java/org/apache/cloudstack/metrics/MetricsServiceImpl.java
@@ -682,8 +682,10 @@ public class MetricsServiceImpl extends 
MutualExclusiveIdsManagerBase implements
             final Float cpuDisableThreshold = 
DeploymentClusterPlanner.ClusterCPUCapacityDisableThreshold.valueIn(clusterId);
             final Float memoryDisableThreshold = 
DeploymentClusterPlanner.ClusterMemoryCapacityDisableThreshold.valueIn(clusterId);
 
-            Long upInstances = 0L;
-            Long totalInstances = 0L;
+            long upInstances = 0L;
+            long totalInstances = 0L;
+            long upSystemInstances = 0L;
+            long totalSystemInstances = 0L;
             for (final VMInstanceVO instance: 
vmInstanceDao.listByHostId(hostId)) {
                 if (instance == null) {
                     continue;
@@ -693,10 +695,16 @@ public class MetricsServiceImpl extends 
MutualExclusiveIdsManagerBase implements
                     if (instance.getState() == VirtualMachine.State.Running) {
                         upInstances++;
                     }
+                } else if (instance.getType().isUsedBySystem()) {
+                    totalSystemInstances++;
+                    if (instance.getState() == VirtualMachine.State.Running) {
+                        upSystemInstances++;
+                    }
                 }
             }
             
metricsResponse.setPowerState(hostResponse.getOutOfBandManagementResponse().getPowerState());
             metricsResponse.setInstances(upInstances, totalInstances);
+            metricsResponse.setSystemInstances(upSystemInstances, 
totalSystemInstances);
             metricsResponse.setCpuTotal(hostResponse.getCpuNumber(), 
hostResponse.getCpuSpeed());
             metricsResponse.setCpuUsed(hostResponse.getCpuUsed(), 
hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
             metricsResponse.setCpuAllocated(hostResponse.getCpuAllocated(), 
hostResponse.getCpuNumber(), hostResponse.getCpuSpeed());
diff --git 
a/plugins/metrics/src/main/java/org/apache/cloudstack/response/HostMetricsResponse.java
 
b/plugins/metrics/src/main/java/org/apache/cloudstack/response/HostMetricsResponse.java
index 30f7e06ce58..8e12d2cbb6d 100644
--- 
a/plugins/metrics/src/main/java/org/apache/cloudstack/response/HostMetricsResponse.java
+++ 
b/plugins/metrics/src/main/java/org/apache/cloudstack/response/HostMetricsResponse.java
@@ -36,6 +36,10 @@ public class HostMetricsResponse extends HostResponse {
     @Param(description = "instances on the host")
     private String instances;
 
+    @SerializedName("systeminstances")
+    @Param(description = "system vm instances on the host")
+    private String systemInstances;
+
     @SerializedName("cputotalghz")
     @Param(description = "the total cpu capacity in Ghz")
     private String cpuTotal;
@@ -108,10 +112,12 @@ public class HostMetricsResponse extends HostResponse {
         this.powerState = powerState;
     }
 
-    public void setInstances(final Long running, final Long total) {
-        if (running != null && total != null) {
-            this.instances = String.format("%d / %d", running, total);
-        }
+    public void setSystemInstances(final long running, final long total) {
+        this.systemInstances = String.format("%d / %d", running, total);
+    }
+
+    public void setInstances(final long running, final long total) {
+        this.instances = String.format("%d / %d", running, total);
     }
 
     public void setCpuTotal(final Integer cpuNumber, final Long cpuSpeed) {

Reply via email to