You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2014/09/05 02:58:23 UTC

git commit: updated refs/heads/master to ce82ab6

Repository: cloudstack
Updated Branches:
  refs/heads/master 3f9e826d2 -> ce82ab605


listhost api needs to return host_details table


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ce82ab60
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ce82ab60
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ce82ab60

Branch: refs/heads/master
Commit: ce82ab605da12314eaa3f19f4e20b7545c24e394
Parents: 3f9e826
Author: Edison Su <su...@gmail.com>
Authored: Thu Sep 4 17:42:43 2014 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Thu Sep 4 17:57:24 2014 -0700

----------------------------------------------------------------------
 .../cloudstack/api/response/HostResponse.java    | 10 ++++++++++
 .../com/cloud/api/query/dao/HostJoinDaoImpl.java | 19 +++++++++++++++++++
 2 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce82ab60/api/src/org/apache/cloudstack/api/response/HostResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/HostResponse.java b/api/src/org/apache/cloudstack/api/response/HostResponse.java
index d7638de..9cb0fcb 100644
--- a/api/src/org/apache/cloudstack/api/response/HostResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/HostResponse.java
@@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response;
 
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
 import com.google.gson.annotations.SerializedName;
 
@@ -212,6 +213,10 @@ public class HostResponse extends BaseResponse {
     @Param(description = "true if the host is Ha host (dedicated to vms started by HA process; false otherwise")
     private Boolean haHost;
 
+    @SerializedName(ApiConstants.DETAILS)
+    @Param(description = "Host details in key/value pairs.", since = "4.5")
+    private Map details;
+
     @Override
     public String getObjectId() {
         return this.getId();
@@ -416,4 +421,9 @@ public class HostResponse extends BaseResponse {
     public void setHaHost(Boolean haHost) {
         this.haHost = haHost;
     }
+
+    public void setDetails(Map details) {
+        this.details = details;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ce82ab60/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
index 9a4b38e..dca4de1 100644
--- a/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/HostJoinDaoImpl.java
@@ -22,6 +22,7 @@ import java.util.Date;
 import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.ejb.Local;
@@ -43,6 +44,9 @@ import com.cloud.gpu.HostGpuGroupsVO;
 import com.cloud.gpu.VGPUTypesVO;
 import com.cloud.host.Host;
 import com.cloud.host.HostStats;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.hypervisor.Hypervisor;
 import com.cloud.storage.StorageStats;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
@@ -55,6 +59,8 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
 
     @Inject
     private ConfigurationDao _configDao;
+    @Inject
+    private HostDao hostDao;
 
     private final SearchBuilder<HostJoinVO> hostSearch;
 
@@ -182,6 +188,19 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
                 }
             }
 
+            if (details.contains(HostDetails.all) && host.getHypervisorType() == Hypervisor.HypervisorType.KVM) {
+                //only kvm has the requirement to return host details
+                try {
+                    HostVO h = hostDao.findById(host.getId());
+                    hostDao.loadDetails(h);
+                    Map<String, String> hostVoDetails;
+                    hostVoDetails = h.getDetails();
+                    hostResponse.setDetails(hostVoDetails);
+                } catch (Exception e) {
+                    s_logger.debug("failed to get host details", e);
+                }
+            }
+
         } else if (host.getType() == Host.Type.SecondaryStorage) {
             StorageStats secStorageStats = ApiDBUtils.getSecondaryStorageStatistics(host.getId());
             if (secStorageStats != null) {