mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
server: Fix host CPU number (#10218)
This commit is contained in:
parent
b186272f68
commit
09f154796a
@ -16,449 +16,20 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
package org.apache.cloudstack.api.response;
|
package org.apache.cloudstack.api.response;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
|
||||||
import org.apache.cloudstack.api.EntityReference;
|
import org.apache.cloudstack.api.EntityReference;
|
||||||
|
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.host.Status;
|
|
||||||
import com.cloud.serializer.Param;
|
import com.cloud.serializer.Param;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
@EntityReference(value = Host.class)
|
@EntityReference(value = Host.class)
|
||||||
public class HostForMigrationResponse extends BaseResponse {
|
public class HostForMigrationResponse extends HostResponse {
|
||||||
@SerializedName(ApiConstants.ID)
|
|
||||||
@Param(description = "the ID of the host")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.NAME)
|
|
||||||
@Param(description = "the name of the host")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.STATE)
|
|
||||||
@Param(description = "the state of the host")
|
|
||||||
private Status state;
|
|
||||||
|
|
||||||
@SerializedName("disconnected")
|
|
||||||
@Param(description = "true if the host is disconnected. False otherwise.")
|
|
||||||
private Date disconnectedOn;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.TYPE)
|
|
||||||
@Param(description = "the host type")
|
|
||||||
private Host.Type hostType;
|
|
||||||
|
|
||||||
@SerializedName("oscategoryid")
|
|
||||||
@Param(description = "the OS category ID of the host")
|
|
||||||
private String osCategoryId;
|
|
||||||
|
|
||||||
@SerializedName("oscategoryname")
|
|
||||||
@Param(description = "the OS category name of the host")
|
|
||||||
private String osCategoryName;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.IP_ADDRESS)
|
|
||||||
@Param(description = "the IP address of the host")
|
|
||||||
private String ipAddress;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.ZONE_ID)
|
|
||||||
@Param(description = "the Zone ID of the host")
|
|
||||||
private String zoneId;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.ZONE_NAME)
|
|
||||||
@Param(description = "the Zone name of the host")
|
|
||||||
private String zoneName;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.POD_ID)
|
|
||||||
@Param(description = "the Pod ID of the host")
|
|
||||||
private String podId;
|
|
||||||
|
|
||||||
@SerializedName("podname")
|
|
||||||
@Param(description = "the Pod name of the host")
|
|
||||||
private String podName;
|
|
||||||
|
|
||||||
@SerializedName("version")
|
|
||||||
@Param(description = "the host version")
|
|
||||||
private String version;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.HYPERVISOR)
|
|
||||||
@Param(description = "the host hypervisor")
|
|
||||||
private String hypervisor;
|
|
||||||
|
|
||||||
@SerializedName("cpunumber")
|
|
||||||
@Param(description = "the CPU number of the host")
|
|
||||||
private Integer cpuNumber;
|
|
||||||
|
|
||||||
@SerializedName("cpuspeed")
|
|
||||||
@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 ")
|
|
||||||
private String cpuWithOverprovisioning;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@SerializedName("memorytotal")
|
|
||||||
@Param(description = "the memory total of the host, this parameter is deprecated use memorywithoverprovisioning")
|
|
||||||
private Long memoryTotal;
|
|
||||||
|
|
||||||
@SerializedName("memorywithoverprovisioning")
|
|
||||||
@Param(description = "the amount of the host's memory after applying the mem.overprovisioning.factor ")
|
|
||||||
private String memWithOverprovisioning;
|
|
||||||
|
|
||||||
@SerializedName("averageload")
|
|
||||||
@Param(description = "the cpu average load on the host")
|
|
||||||
private Long averageLoad;
|
|
||||||
|
|
||||||
@SerializedName("networkkbsread")
|
|
||||||
@Param(description = "the incoming network traffic on the host")
|
|
||||||
private Long networkKbsRead;
|
|
||||||
|
|
||||||
@SerializedName("networkkbswrite")
|
|
||||||
@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;
|
|
||||||
|
|
||||||
@SerializedName("disksizetotal")
|
|
||||||
@Param(description = "the total disk size of the host")
|
|
||||||
private Long diskSizeTotal;
|
|
||||||
|
|
||||||
@SerializedName("disksizeallocated")
|
|
||||||
@Param(description = "the host's currently allocated disk size")
|
|
||||||
private Long diskSizeAllocated;
|
|
||||||
|
|
||||||
@SerializedName("capabilities")
|
|
||||||
@Param(description = "capabilities of the host")
|
|
||||||
private String capabilities;
|
|
||||||
|
|
||||||
@SerializedName("lastpinged")
|
|
||||||
@Param(description = "the date and time the host was last pinged")
|
|
||||||
private Date lastPinged;
|
|
||||||
|
|
||||||
@SerializedName("managementserverid")
|
|
||||||
@Param(description = "the management server ID of the host")
|
|
||||||
private Long managementServerId;
|
|
||||||
|
|
||||||
@SerializedName("clusterid")
|
|
||||||
@Param(description = "the cluster ID of the host")
|
|
||||||
private String clusterId;
|
|
||||||
|
|
||||||
@SerializedName("clustername")
|
|
||||||
@Param(description = "the cluster name of the host")
|
|
||||||
private String clusterName;
|
|
||||||
|
|
||||||
@SerializedName("clustertype")
|
|
||||||
@Param(description = "the cluster type of the cluster that host belongs to")
|
|
||||||
private String clusterType;
|
|
||||||
|
|
||||||
@SerializedName("islocalstorageactive")
|
|
||||||
@Param(description = "true if local storage is active, false otherwise")
|
|
||||||
private Boolean localStorageActive;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.CREATED)
|
|
||||||
@Param(description = "the date and time the host was created")
|
|
||||||
private Date created;
|
|
||||||
|
|
||||||
@SerializedName("removed")
|
|
||||||
@Param(description = "the date and time the host was removed")
|
|
||||||
private Date removed;
|
|
||||||
|
|
||||||
@SerializedName("events")
|
|
||||||
@Param(description = "events available for the host")
|
|
||||||
private String events;
|
|
||||||
|
|
||||||
@SerializedName("hosttags")
|
|
||||||
@Param(description = "comma-separated list of tags for the host")
|
|
||||||
private String hostTags;
|
|
||||||
|
|
||||||
@SerializedName("hasenoughcapacity")
|
|
||||||
@Param(description = "true if this host has enough CPU and RAM capacity to migrate a VM to it, false otherwise")
|
|
||||||
private Boolean hasEnoughCapacity;
|
|
||||||
|
|
||||||
@SerializedName("suitableformigration")
|
|
||||||
@Param(description = "true if this host is suitable(has enough capacity and satisfies all conditions like hosttags, " +
|
|
||||||
"max guests vm limit etc) to migrate a VM to it , false otherwise")
|
|
||||||
private Boolean suitableForMigration;
|
|
||||||
|
|
||||||
@SerializedName("requiresStorageMotion")
|
@SerializedName("requiresStorageMotion")
|
||||||
@Param(description = "true if migrating a vm to this host requires storage motion, false otherwise")
|
@Param(description = "true if migrating a vm to this host requires storage motion, false otherwise")
|
||||||
private Boolean requiresStorageMotion;
|
private Boolean requiresStorageMotion;
|
||||||
|
|
||||||
@SerializedName("resourcestate")
|
|
||||||
@Param(description = "the resource state of the host")
|
|
||||||
private String resourceState;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.HYPERVISOR_VERSION)
|
|
||||||
@Param(description = "the hypervisor version")
|
|
||||||
private String hypervisorVersion;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.HA_HOST)
|
|
||||||
@Param(description = "true if the host is Ha host (dedicated to vms started by HA process; false otherwise")
|
|
||||||
private Boolean haHost;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getObjectId() {
|
|
||||||
return getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(String id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(Status state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDisconnectedOn(Date disconnectedOn) {
|
|
||||||
this.disconnectedOn = disconnectedOn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHostType(Host.Type hostType) {
|
|
||||||
this.hostType = hostType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOsCategoryId(String osCategoryId) {
|
|
||||||
this.osCategoryId = osCategoryId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOsCategoryName(String osCategoryName) {
|
|
||||||
this.osCategoryName = osCategoryName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIpAddress(String ipAddress) {
|
|
||||||
this.ipAddress = ipAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZoneId(String zoneId) {
|
|
||||||
this.zoneId = zoneId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setZoneName(String zoneName) {
|
|
||||||
this.zoneName = zoneName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPodId(String podId) {
|
|
||||||
this.podId = podId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPodName(String podName) {
|
|
||||||
this.podName = podName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVersion(String version) {
|
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHypervisor(String hypervisor) {
|
|
||||||
this.hypervisor = hypervisor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCpuNumber(Integer cpuNumber) {
|
|
||||||
this.cpuNumber = cpuNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCpuSpeed(Long cpuSpeed) {
|
|
||||||
this.cpuSpeed = cpuSpeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCpuAllocated() {
|
|
||||||
return cpuAllocated;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAverageLoad(Long averageLoad) {
|
|
||||||
this.averageLoad = averageLoad;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNetworkKbsRead(Long networkKbsRead) {
|
|
||||||
this.networkKbsRead = networkKbsRead;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNetworkKbsWrite(Long networkKbsWrite) {
|
|
||||||
this.networkKbsWrite = networkKbsWrite;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMemoryAllocated(String memoryAllocated) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDiskSizeTotal(Long diskSizeTotal) {
|
|
||||||
this.diskSizeTotal = diskSizeTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDiskSizeAllocated(Long diskSizeAllocated) {
|
|
||||||
this.diskSizeAllocated = diskSizeAllocated;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCapabilities(String capabilities) {
|
|
||||||
this.capabilities = capabilities;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastPinged(Date lastPinged) {
|
|
||||||
this.lastPinged = lastPinged;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setManagementServerId(Long managementServerId) {
|
|
||||||
this.managementServerId = managementServerId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClusterId(String clusterId) {
|
|
||||||
this.clusterId = clusterId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClusterName(String clusterName) {
|
|
||||||
this.clusterName = clusterName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClusterType(String clusterType) {
|
|
||||||
this.clusterType = clusterType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLocalStorageActive(Boolean localStorageActive) {
|
|
||||||
this.localStorageActive = localStorageActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRemoved(Date removed) {
|
|
||||||
this.removed = removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEvents(String events) {
|
|
||||||
this.events = events;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHostTags() {
|
|
||||||
return hostTags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHostTags(String hostTags) {
|
|
||||||
this.hostTags = hostTags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHasEnoughCapacity(Boolean hasEnoughCapacity) {
|
|
||||||
this.hasEnoughCapacity = hasEnoughCapacity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSuitableForMigration(Boolean suitableForMigration) {
|
|
||||||
this.suitableForMigration = suitableForMigration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequiresStorageMotion(Boolean requiresStorageMotion) {
|
public void setRequiresStorageMotion(Boolean requiresStorageMotion) {
|
||||||
this.requiresStorageMotion = requiresStorageMotion;
|
this.requiresStorageMotion = requiresStorageMotion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResourceState() {
|
|
||||||
return resourceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResourceState(String resourceState) {
|
|
||||||
this.resourceState = resourceState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCpuWithOverprovisioning() {
|
|
||||||
return cpuWithOverprovisioning;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCpuWithOverprovisioning(String cpuWithOverprovisioning) {
|
|
||||||
this.cpuWithOverprovisioning = cpuWithOverprovisioning;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMemWithOverprovisioning(String memWithOverprovisioning){
|
|
||||||
this.memWithOverprovisioning=memWithOverprovisioning;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHypervisorVersion(String hypervisorVersion) {
|
|
||||||
this.hypervisorVersion = hypervisorVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getHaHost() {
|
|
||||||
return haHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHaHost(Boolean haHost) {
|
|
||||||
this.haHost = haHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMemoryTotal(Long memoryTotal) {
|
|
||||||
this.memoryTotal = memoryTotal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -115,9 +115,7 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setNewHostResponseBase(HostJoinVO host, EnumSet<HostDetails> details, HostResponse hostResponse) {
|
||||||
public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> details) {
|
|
||||||
HostResponse hostResponse = new HostResponse();
|
|
||||||
hostResponse.setId(host.getUuid());
|
hostResponse.setId(host.getUuid());
|
||||||
hostResponse.setCapabilities(host.getCapabilities());
|
hostResponse.setCapabilities(host.getCapabilities());
|
||||||
hostResponse.setClusterId(host.getClusterUuid());
|
hostResponse.setClusterId(host.getClusterUuid());
|
||||||
@ -189,7 +187,6 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
||||||
if (host.getType() == Host.Type.Routing) {
|
if (host.getType() == Host.Type.Routing) {
|
||||||
float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
|
float cpuOverprovisioningFactor = ApiDBUtils.getCpuOverprovisioningFactor(host.getClusterId());
|
||||||
hostResponse.setCpuNumber((int)(host.getCpus() * cpuOverprovisioningFactor));
|
|
||||||
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)) {
|
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)) {
|
||||||
// set allocated capacities
|
// set allocated capacities
|
||||||
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
|
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
|
||||||
@ -295,123 +292,19 @@ public class HostJoinDaoImpl extends GenericDaoBase<HostJoinVO, Long> implements
|
|||||||
hostResponse.setUsername(host.getUsername());
|
hostResponse.setUsername(host.getUsername());
|
||||||
|
|
||||||
hostResponse.setObjectName("host");
|
hostResponse.setObjectName("host");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> details) {
|
||||||
|
HostResponse hostResponse = new HostResponse();
|
||||||
|
setNewHostResponseBase(host, details, hostResponse);
|
||||||
return hostResponse;
|
return hostResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, EnumSet<HostDetails> details) {
|
public HostForMigrationResponse newHostForMigrationResponse(HostJoinVO host, EnumSet<HostDetails> details) {
|
||||||
HostForMigrationResponse hostResponse = new HostForMigrationResponse();
|
HostForMigrationResponse hostResponse = new HostForMigrationResponse();
|
||||||
hostResponse.setId(host.getUuid());
|
setNewHostResponseBase(host, details, hostResponse);
|
||||||
hostResponse.setCapabilities(host.getCapabilities());
|
|
||||||
hostResponse.setClusterId(host.getClusterUuid());
|
|
||||||
hostResponse.setCpuNumber(host.getCpus());
|
|
||||||
hostResponse.setZoneId(host.getZoneUuid());
|
|
||||||
hostResponse.setDisconnectedOn(host.getDisconnectedOn());
|
|
||||||
hostResponse.setHypervisor(host.getHypervisorType().getHypervisorDisplayName());
|
|
||||||
hostResponse.setHostType(host.getType());
|
|
||||||
hostResponse.setLastPinged(new Date(host.getLastPinged()));
|
|
||||||
hostResponse.setManagementServerId(host.getManagementServerId());
|
|
||||||
hostResponse.setName(host.getName());
|
|
||||||
hostResponse.setPodId(host.getPodUuid());
|
|
||||||
hostResponse.setRemoved(host.getRemoved());
|
|
||||||
hostResponse.setCpuSpeed(host.getSpeed());
|
|
||||||
hostResponse.setState(host.getStatus());
|
|
||||||
hostResponse.setIpAddress(host.getPrivateIpAddress());
|
|
||||||
hostResponse.setVersion(host.getVersion());
|
|
||||||
hostResponse.setCreated(host.getCreated());
|
|
||||||
|
|
||||||
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity) || details.contains(HostDetails.stats) || details.contains(HostDetails.events)) {
|
|
||||||
|
|
||||||
hostResponse.setOsCategoryId(host.getOsCategoryUuid());
|
|
||||||
hostResponse.setOsCategoryName(host.getOsCategoryName());
|
|
||||||
hostResponse.setZoneName(host.getZoneName());
|
|
||||||
hostResponse.setPodName(host.getPodName());
|
|
||||||
if (host.getClusterId() > 0) {
|
|
||||||
hostResponse.setClusterName(host.getClusterName());
|
|
||||||
hostResponse.setClusterType(host.getClusterType().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DecimalFormat decimalFormat = new DecimalFormat("#.##");
|
|
||||||
if (host.getType() == Host.Type.Routing) {
|
|
||||||
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity)) {
|
|
||||||
// set allocated capacities
|
|
||||||
Long mem = host.getMemReservedCapacity() + host.getMemUsedCapacity();
|
|
||||||
Long cpu = host.getCpuReservedCapacity() + host.getCpuUsedCapacity();
|
|
||||||
|
|
||||||
hostResponse.setMemoryTotal(host.getTotalMemory());
|
|
||||||
Float memWithOverprovisioning = host.getTotalMemory() * ApiDBUtils.getMemOverprovisioningFactor(host.getClusterId());
|
|
||||||
hostResponse.setMemWithOverprovisioning(decimalFormat.format(memWithOverprovisioning));
|
|
||||||
String memoryAllocatedPercentage = decimalFormat.format((float) mem / memWithOverprovisioning * 100.0f) +"%";
|
|
||||||
hostResponse.setMemoryAllocated(memoryAllocatedPercentage);
|
|
||||||
hostResponse.setMemoryAllocatedPercentage(memoryAllocatedPercentage);
|
|
||||||
hostResponse.setMemoryAllocatedBytes(mem);
|
|
||||||
|
|
||||||
String hostTags = host.getTag();
|
|
||||||
hostResponse.setHostTags(hostTags);
|
|
||||||
hostResponse.setHaHost(containsHostHATag(hostTags));
|
|
||||||
|
|
||||||
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.setCpuAllocatedWithOverprovisioning(calculateResourceAllocatedPercentage(cpu, cpuWithOverprovisioning));
|
|
||||||
hostResponse.setCpuWithOverprovisioning(decimalFormat.format(cpuWithOverprovisioning));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (details.contains(HostDetails.all) || details.contains(HostDetails.stats)) {
|
|
||||||
// set CPU/RAM/Network stats
|
|
||||||
String cpuUsed = null;
|
|
||||||
HostStats hostStats = ApiDBUtils.getHostStatistics(host.getId());
|
|
||||||
if (hostStats != null) {
|
|
||||||
float cpuUtil = (float)hostStats.getCpuUtilization();
|
|
||||||
cpuUsed = decimalFormat.format(cpuUtil) + "%";
|
|
||||||
hostResponse.setCpuUsed(cpuUsed);
|
|
||||||
hostResponse.setMemoryUsed((new Double(hostStats.getUsedMemory())).longValue());
|
|
||||||
hostResponse.setNetworkKbsRead((new Double(hostStats.getNetworkReadKBs())).longValue());
|
|
||||||
hostResponse.setNetworkKbsWrite((new Double(hostStats.getNetworkWriteKBs())).longValue());
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (host.getType() == Host.Type.SecondaryStorage) {
|
|
||||||
StorageStats secStorageStats = ApiDBUtils.getSecondaryStorageStatistics(host.getId());
|
|
||||||
if (secStorageStats != null) {
|
|
||||||
hostResponse.setDiskSizeTotal(secStorageStats.getCapacityBytes());
|
|
||||||
hostResponse.setDiskSizeAllocated(secStorageStats.getByteUsed());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hostResponse.setLocalStorageActive(ApiDBUtils.isLocalStorageActiveOnHost(host.getId()));
|
|
||||||
|
|
||||||
if (details.contains(HostDetails.all) || details.contains(HostDetails.events)) {
|
|
||||||
Set<com.cloud.host.Status.Event> possibleEvents = host.getStatus().getPossibleEvents();
|
|
||||||
if ((possibleEvents != null) && !possibleEvents.isEmpty()) {
|
|
||||||
String events = "";
|
|
||||||
Iterator<com.cloud.host.Status.Event> iter = possibleEvents.iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
com.cloud.host.Status.Event event = iter.next();
|
|
||||||
events += event.toString();
|
|
||||||
if (iter.hasNext()) {
|
|
||||||
events += "; ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hostResponse.setEvents(events);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hostResponse.setResourceState(host.getResourceState().toString());
|
|
||||||
|
|
||||||
// set async job
|
|
||||||
hostResponse.setJobId(host.getJobUuid());
|
|
||||||
hostResponse.setJobStatus(host.getJobStatus());
|
|
||||||
|
|
||||||
hostResponse.setObjectName("host");
|
|
||||||
|
|
||||||
return hostResponse;
|
return hostResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user