mirror of https://github.com/apache/cloudstack.git
listhost api needs to return host_details table
This commit is contained in:
parent
3f9e826d28
commit
ce82ab605d
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue