mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-6366: add vgpuTypes details in vgpu_types table.
This commit is contained in:
parent
ecc71518a9
commit
a195205d11
79
api/src/com/cloud/agent/api/VgpuTypesInfo.java
Normal file
79
api/src/com/cloud/agent/api/VgpuTypesInfo.java
Normal file
@ -0,0 +1,79 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.package com.cloud.agent.api;
|
||||
public class VgpuTypesInfo {
|
||||
|
||||
private String modelName;
|
||||
private Long maxHeads;
|
||||
private Long videoRam;
|
||||
private Long maxResolutionX;
|
||||
private Long maxResolutionY;
|
||||
private Long maxVgpuPerGpu;
|
||||
private Long remainingCapacity;
|
||||
private Long maxCapacity;
|
||||
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public Long getVideoRam() {
|
||||
return videoRam;
|
||||
}
|
||||
|
||||
public Long getMaxHeads() {
|
||||
return maxHeads;
|
||||
}
|
||||
|
||||
public Long getMaxResolutionX() {
|
||||
return maxResolutionX;
|
||||
}
|
||||
|
||||
public Long getMaxResolutionY() {
|
||||
return maxResolutionY;
|
||||
}
|
||||
|
||||
public Long getMaxVpuPerGpu() {
|
||||
return maxVgpuPerGpu;
|
||||
}
|
||||
|
||||
public Long getRemainingCapacity() {
|
||||
return remainingCapacity;
|
||||
}
|
||||
|
||||
public void setRemainingCapacity(Long remainingCapacity) {
|
||||
this.remainingCapacity = remainingCapacity;
|
||||
}
|
||||
|
||||
public Long getMaxCapacity() {
|
||||
return maxCapacity;
|
||||
}
|
||||
|
||||
public void setMaxVmCapacity(Long maxCapacity) {
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
||||
public VgpuTypesInfo(String modelName, Long videoRam, Long maxHeads, Long maxResolutionX, Long maxResolutionY, Long maxVgpuPerGpu,
|
||||
Long remainingCapacity, Long maxCapacity) {
|
||||
this.modelName = modelName;
|
||||
this.videoRam = videoRam;
|
||||
this.maxHeads = maxHeads;
|
||||
this.maxResolutionX = maxResolutionX;
|
||||
this.maxResolutionY = maxResolutionY;
|
||||
this.maxVgpuPerGpu = maxVgpuPerGpu;
|
||||
this.remainingCapacity = remainingCapacity;
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
}
|
||||
@ -18,13 +18,15 @@ package com.cloud.agent.api.to;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
|
||||
public class GPUDeviceTO {
|
||||
|
||||
private String gpuGroup;
|
||||
private String vgpuType;
|
||||
private HashMap<String, HashMap<String, Long>> groupDetails = new HashMap<String, HashMap<String, Long>>();
|
||||
private HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
|
||||
|
||||
public GPUDeviceTO( String gpuGroup, String vgpuType, HashMap<String, HashMap<String, Long>> groupDetails) {
|
||||
public GPUDeviceTO( String gpuGroup, String vgpuType, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
|
||||
this.gpuGroup = gpuGroup;
|
||||
this.vgpuType = vgpuType;
|
||||
this.groupDetails = groupDetails;
|
||||
@ -46,11 +48,12 @@ public class GPUDeviceTO {
|
||||
this.vgpuType = vgpuType;
|
||||
}
|
||||
|
||||
public HashMap<String, HashMap<String, Long>> getGroupDetails() {
|
||||
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGroupDetails() {
|
||||
return groupDetails;
|
||||
}
|
||||
|
||||
public void setGroupDetails(HashMap<String, HashMap<String, Long>> groupDetails) {
|
||||
public void setGroupDetails(HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
|
||||
this.groupDetails = groupDetails;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -23,14 +23,14 @@ import com.cloud.agent.api.LogLevel.Log4jLevel;
|
||||
@LogLevel(Log4jLevel.Trace)
|
||||
public class GetGPUStatsAnswer extends Answer {
|
||||
|
||||
private HashMap<String, HashMap<String, Long>> groupDetails;
|
||||
private HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails;
|
||||
|
||||
public GetGPUStatsAnswer(GetGPUStatsCommand cmd, HashMap<String, HashMap<String, Long>> groupDetails) {
|
||||
public GetGPUStatsAnswer(GetGPUStatsCommand cmd, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
|
||||
super(cmd);
|
||||
this.groupDetails = groupDetails;
|
||||
}
|
||||
|
||||
public HashMap<String, HashMap<String, Long>> getGroupDetails() {
|
||||
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGroupDetails() {
|
||||
return this.groupDetails;
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class StartupRoutingCommand extends StartupCommand {
|
||||
HypervisorType hypervisorType;
|
||||
Map<String, String> hostDetails; //stuff like host os, cpu capabilities
|
||||
String hypervisorVersion;
|
||||
HashMap<String, HashMap<String, Long>> groupDetails = new HashMap<String, HashMap<String, Long>>();
|
||||
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
|
||||
|
||||
public StartupRoutingCommand() {
|
||||
super(Host.Type.Routing);
|
||||
@ -246,11 +246,11 @@ public class StartupRoutingCommand extends StartupCommand {
|
||||
this._hostVmStateReport = hostVmStateReport;
|
||||
}
|
||||
|
||||
public HashMap<String, HashMap<String, Long>> getGpuGroupDetails() {
|
||||
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGpuGroupDetails() {
|
||||
return groupDetails;
|
||||
}
|
||||
|
||||
public void setGpuGroupDetails(HashMap<String, HashMap<String, Long>> groupDetails) {
|
||||
public void setGpuGroupDetails(HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
|
||||
this.groupDetails = groupDetails;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import java.util.Map;
|
||||
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.agent.api.to.GPUDeviceTO;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
@ -180,12 +181,12 @@ public interface ResourceManager extends ResourceService {
|
||||
* @param hostId, the dest host Id
|
||||
* @param groupDetails, capacity of GPU group.
|
||||
*/
|
||||
void updateGPUDetails(long hostId, HashMap<String, HashMap<String, Long>> groupDetails);
|
||||
void updateGPUDetails(long hostId, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails);
|
||||
|
||||
/**
|
||||
* Get GPU details for a host
|
||||
* @param host, the Host object
|
||||
* @return Details of groupNames and enabled VGPU type with remaining capacity.
|
||||
*/
|
||||
HashMap<String, HashMap<String, Long>> getGPUStatistics(HostVO host);
|
||||
HashMap<String, HashMap<String, VgpuTypesInfo>> getGPUStatistics(HostVO host);
|
||||
}
|
||||
|
||||
@ -33,30 +33,47 @@ public class VGPUTypesVO implements InternalIdentity {
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
@Column(name="vgpu_type")
|
||||
private String vgpuType;
|
||||
|
||||
@Column(name="gpu_group_id")
|
||||
private long gpuGroupId;
|
||||
|
||||
@Column(name="remaining_vm_capacity")
|
||||
@Column(name="vgpu_type")
|
||||
private String vgpuType;
|
||||
|
||||
@Column(name="video_ram")
|
||||
private long videoRam;
|
||||
|
||||
@Column(name="max_heads")
|
||||
private long maxHeads;
|
||||
|
||||
@Column(name="max_resolution_x")
|
||||
private long maxResolutionX;
|
||||
|
||||
@Column(name="max_resolution_y")
|
||||
private long maxResolutionY;
|
||||
|
||||
@Column(name="max_vgpu_per_pgpu")
|
||||
private long maxVgpuPerPgpu;
|
||||
|
||||
@Column(name="remaining_capacity")
|
||||
private long remainingCapacity;
|
||||
|
||||
@Column(name="max_capacity")
|
||||
private long maxCapacity;
|
||||
|
||||
protected VGPUTypesVO() {
|
||||
}
|
||||
|
||||
public VGPUTypesVO(String vgpuType, long gpuGroupId, long remainingCapacity) {
|
||||
this.vgpuType = vgpuType;
|
||||
public VGPUTypesVO(long gpuGroupId, String vgpuType, long videoRam, long maxHeads, long maxResolutionX, long maxResolutionY, long maxVgpuPerPgpu,
|
||||
long remainingCapacity, long maxCapacity) {
|
||||
this.gpuGroupId = gpuGroupId;
|
||||
this.remainingCapacity = remainingCapacity;
|
||||
}
|
||||
|
||||
public String getVgpuType() {
|
||||
return vgpuType;
|
||||
}
|
||||
|
||||
public void setVgpuType(String vgpuType) {
|
||||
this.vgpuType = vgpuType;
|
||||
this.videoRam = videoRam;
|
||||
this.maxHeads = maxHeads;
|
||||
this.maxResolutionX = maxResolutionX;
|
||||
this.maxResolutionY = maxResolutionY;
|
||||
this.maxVgpuPerPgpu = maxVgpuPerPgpu;
|
||||
this.remainingCapacity = remainingCapacity;
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
||||
public long getGpuGroupId() {
|
||||
@ -67,6 +84,54 @@ public class VGPUTypesVO implements InternalIdentity {
|
||||
this.gpuGroupId = gpuGroupId;
|
||||
}
|
||||
|
||||
public String getVgpuType() {
|
||||
return vgpuType;
|
||||
}
|
||||
|
||||
public void setVgpuType(String vgpuType) {
|
||||
this.vgpuType = vgpuType;
|
||||
}
|
||||
|
||||
public long getVideoRam() {
|
||||
return videoRam;
|
||||
}
|
||||
|
||||
public void setVideoRam(long videoRam) {
|
||||
this.videoRam = videoRam;
|
||||
}
|
||||
|
||||
public long getMaxHeads() {
|
||||
return maxHeads;
|
||||
}
|
||||
|
||||
public void setMaxHeads(long maxHeads) {
|
||||
this.maxHeads = maxHeads;
|
||||
}
|
||||
|
||||
public long getMaxResolutionX() {
|
||||
return maxResolutionX;
|
||||
}
|
||||
|
||||
public void setMaxResolutionX(long maxResolutionX) {
|
||||
this.maxResolutionX = maxResolutionX;
|
||||
}
|
||||
|
||||
public long getMaxResolutionY() {
|
||||
return maxResolutionY;
|
||||
}
|
||||
|
||||
public void setMaxResolutionY(long maxResolutionY) {
|
||||
this.maxResolutionY = maxResolutionY;
|
||||
}
|
||||
|
||||
public long getMaxVgpuPerPgpu() {
|
||||
return maxVgpuPerPgpu;
|
||||
}
|
||||
|
||||
public void setMaxVgpuPerPgpu(long maxVgpuPerPgpu) {
|
||||
this.maxVgpuPerPgpu = maxVgpuPerPgpu;
|
||||
}
|
||||
|
||||
public long getRemainingCapacity() {
|
||||
return remainingCapacity;
|
||||
}
|
||||
@ -75,6 +140,14 @@ public class VGPUTypesVO implements InternalIdentity {
|
||||
this.remainingCapacity = remainingCapacity;
|
||||
}
|
||||
|
||||
public long getMaxCapacity() {
|
||||
return maxCapacity;
|
||||
}
|
||||
|
||||
public void setMaxCapacity(long maxCapacity) {
|
||||
this.maxCapacity = maxCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getId() {
|
||||
return id;
|
||||
|
||||
@ -19,6 +19,7 @@ package com.cloud.gpu.dao;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.gpu.VGPUTypesVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@ -44,5 +45,5 @@ public interface VGPUTypesDao extends GenericDao<VGPUTypesVO, Long> {
|
||||
* @param hostId the host
|
||||
* @param groupDetails with enabled VGPU types
|
||||
*/
|
||||
void persist(long hostId, HashMap<String, HashMap<String, Long>> groupDetails);
|
||||
void persist(long hostId, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails);
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ import javax.inject.Inject;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.gpu.HostGpuGroupsVO;
|
||||
import com.cloud.gpu.VGPUTypesVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
@ -73,20 +74,23 @@ public class VGPUTypesDaoImpl extends GenericDaoBase<VGPUTypesVO, Long> implemen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void persist(long hostId, HashMap<String, HashMap<String, Long>> groupDetails) {
|
||||
Iterator<Entry<String, HashMap<String, Long>>> it1 = groupDetails.entrySet().iterator();
|
||||
public void persist(long hostId, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
|
||||
Iterator<Entry<String, HashMap<String, VgpuTypesInfo>>> it1 = groupDetails.entrySet().iterator();
|
||||
while (it1.hasNext()) {
|
||||
Entry<String, HashMap<String, Long>> entry = it1.next();
|
||||
Entry<String, HashMap<String, VgpuTypesInfo>> entry = it1.next();
|
||||
HostGpuGroupsVO gpuGroup = _hostGpuGroupsDao.findByHostIdGroupName(hostId, entry.getKey());
|
||||
HashMap<String, Long> values = entry.getValue();
|
||||
Iterator<Entry<String, Long>> it2 = values.entrySet().iterator();
|
||||
HashMap<String, VgpuTypesInfo> values = entry.getValue();
|
||||
Iterator<Entry<String, VgpuTypesInfo>> it2 = values.entrySet().iterator();
|
||||
while (it2.hasNext()) {
|
||||
Entry<String, Long> record = it2.next();
|
||||
Entry<String, VgpuTypesInfo> record = it2.next();
|
||||
VgpuTypesInfo details = record.getValue();
|
||||
VGPUTypesVO vgpuType = null;
|
||||
if ((vgpuType = findByGroupIdVGPUType(gpuGroup.getId(), record.getKey())) == null) {
|
||||
persist(new VGPUTypesVO(record.getKey(), gpuGroup.getId(), record.getValue()));
|
||||
persist(new VGPUTypesVO(gpuGroup.getId(), record.getKey(), details.getVideoRam(), details.getMaxHeads(), details.getMaxResolutionX(),
|
||||
details.getMaxResolutionY(), details.getMaxVpuPerGpu(), details.getRemainingCapacity(), details.getMaxCapacity()));
|
||||
} else {
|
||||
vgpuType.setRemainingCapacity(record.getValue());
|
||||
vgpuType.setRemainingCapacity(details.getRemainingCapacity());
|
||||
vgpuType.setMaxCapacity(details.getMaxCapacity());
|
||||
update(vgpuType.getId(), vgpuType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceState;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
@ -156,7 +157,7 @@ public class HostVO implements Host {
|
||||
|
||||
// This value is only for saving and current cannot be loaded.
|
||||
@Transient
|
||||
HashMap<String, HashMap<String, Long>> groupDetails = new HashMap<String, HashMap<String, Long>>();
|
||||
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
|
||||
|
||||
@Override
|
||||
public String getStorageIpAddressDeux() {
|
||||
@ -318,11 +319,11 @@ public class HostVO implements Host {
|
||||
this.hostTags = hostTags;
|
||||
}
|
||||
|
||||
public HashMap<String, HashMap<String, Long>> getGpuGroupDetails() {
|
||||
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGpuGroupDetails() {
|
||||
return groupDetails;
|
||||
}
|
||||
|
||||
public void setGpuGroups(HashMap<String, HashMap<String, Long>> groupDetails) {
|
||||
public void setGpuGroups(HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
|
||||
this.groupDetails = groupDetails;
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ import javax.persistence.TableGenerator;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.cluster.agentlb.HostTransferMapVO;
|
||||
import com.cloud.cluster.agentlb.dao.HostTransferMapDao;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
@ -782,7 +783,7 @@ public class HostDaoImpl extends GenericDaoBase<HostVO, Long> implements HostDao
|
||||
}
|
||||
|
||||
protected void saveGpuRecords(HostVO host) {
|
||||
HashMap<String, HashMap<String, Long>> groupDetails = host.getGpuGroupDetails();
|
||||
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = host.getGpuGroupDetails();
|
||||
if (groupDetails != null) {
|
||||
// Create/Update GPU group entries
|
||||
_hostGpuGroupsDao.persist(host.getId(), new ArrayList<String>(groupDetails.keySet()));
|
||||
|
||||
@ -114,6 +114,7 @@ import com.cloud.agent.api.UnPlugNicAnswer;
|
||||
import com.cloud.agent.api.UnPlugNicCommand;
|
||||
import com.cloud.agent.api.UpdateHostPasswordCommand;
|
||||
import com.cloud.agent.api.UpgradeSnapshotCommand;
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
import com.cloud.agent.api.check.CheckSshAnswer;
|
||||
import com.cloud.agent.api.check.CheckSshCommand;
|
||||
@ -1340,7 +1341,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
return dynamicMinRam;
|
||||
}
|
||||
|
||||
protected HashMap<String, HashMap<String, Long>> getGPUGroupDetails(Connection conn) throws XenAPIException, XmlRpcException {
|
||||
protected HashMap<String, HashMap<String, VgpuTypesInfo>> getGPUGroupDetails(Connection conn) throws XenAPIException, XmlRpcException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -3665,7 +3666,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
s_logger.debug("VM " + vmName + " does not have GPU support.");
|
||||
}
|
||||
if (vGPUs != null && !vGPUs.isEmpty()) {
|
||||
HashMap<String, HashMap<String, Long>> groupDetails = getGPUGroupDetails(conn);
|
||||
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = getGPUGroupDetails(conn);
|
||||
cmd.setGpuDevice(new GPUDeviceTO(null, null, groupDetails));
|
||||
}
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ import com.cloud.agent.api.GetGPUStatsAnswer;
|
||||
import com.cloud.agent.api.GetGPUStatsCommand;
|
||||
import com.cloud.agent.api.StartCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.agent.api.to.GPUDeviceTO;
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.xensource.xenapi.Connection;
|
||||
@ -43,6 +44,7 @@ import com.xensource.xenapi.PGPU;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
import com.xensource.xenapi.VGPU;
|
||||
import com.xensource.xenapi.VGPUType;
|
||||
import com.xensource.xenapi.VGPUType.Record;
|
||||
import com.xensource.xenapi.VM;
|
||||
|
||||
@Local(value=ServerResource.class)
|
||||
@ -65,7 +67,7 @@ public class XenServer620SP1Resource extends XenServer620Resource {
|
||||
|
||||
protected GetGPUStatsAnswer execute(GetGPUStatsCommand cmd) {
|
||||
Connection conn = getConnection();
|
||||
HashMap<String, HashMap<String, Long>> groupDetails = new HashMap<String, HashMap<String, Long>>();
|
||||
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
|
||||
try {
|
||||
groupDetails = getGPUGroupDetails(conn);
|
||||
} catch (Exception e) {
|
||||
@ -79,7 +81,7 @@ public class XenServer620SP1Resource extends XenServer620Resource {
|
||||
protected void fillHostInfo(Connection conn, StartupRoutingCommand cmd) {
|
||||
super.fillHostInfo(conn, cmd);
|
||||
try {
|
||||
HashMap<String, HashMap<String, Long>> groupDetails = getGPUGroupDetails(conn);
|
||||
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = getGPUGroupDetails(conn);
|
||||
cmd.setGpuGroupDetails(groupDetails);
|
||||
} catch (Exception e) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
@ -89,8 +91,8 @@ public class XenServer620SP1Resource extends XenServer620Resource {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HashMap<String, HashMap<String, Long>> getGPUGroupDetails(Connection conn) throws XenAPIException, XmlRpcException {
|
||||
HashMap<String, HashMap<String, Long>> groupDetails = new HashMap<String, HashMap<String, Long>>();
|
||||
protected HashMap<String, HashMap<String, VgpuTypesInfo>> getGPUGroupDetails(Connection conn) throws XenAPIException, XmlRpcException {
|
||||
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
|
||||
Host host = Host.getByUuid(conn, _host.uuid);
|
||||
Set<PGPU> pgpus = host.getPGPUs(conn);
|
||||
Iterator<PGPU> iter = pgpus.iterator();
|
||||
@ -99,7 +101,7 @@ public class XenServer620SP1Resource extends XenServer620Resource {
|
||||
GPUGroup gpuGroup = pgpu.getGPUGroup(conn);
|
||||
Set<VGPUType> enabledVGPUTypes = gpuGroup.getEnabledVGPUTypes(conn);
|
||||
String groupName = gpuGroup.getNameLabel(conn);
|
||||
HashMap<String, Long> gpuCapacity = new HashMap<String, Long>();
|
||||
HashMap<String, VgpuTypesInfo> gpuCapacity = new HashMap<String, VgpuTypesInfo>();
|
||||
if (groupDetails.get(groupName) != null) {
|
||||
gpuCapacity = groupDetails.get(groupName);
|
||||
}
|
||||
@ -108,13 +110,20 @@ public class XenServer620SP1Resource extends XenServer620Resource {
|
||||
Iterator<VGPUType> it = enabledVGPUTypes.iterator();
|
||||
while (it.hasNext()) {
|
||||
VGPUType type = it.next();
|
||||
String modelName = type.getModelName(conn);
|
||||
Record record = type.getRecord(conn);
|
||||
Long remainingCapacity = pgpu.getRemainingCapacity(conn, type);
|
||||
if (gpuCapacity.get(modelName) != null) {
|
||||
long newRemainingCapacity = gpuCapacity.get(modelName) + remainingCapacity;
|
||||
gpuCapacity.put(modelName, newRemainingCapacity);
|
||||
Long maxCapacity = pgpu.getSupportedVGPUMaxCapacities(conn).get(type);
|
||||
VgpuTypesInfo entry;
|
||||
if ((entry = gpuCapacity.get(record.modelName)) != null) {
|
||||
remainingCapacity += entry.getRemainingCapacity();
|
||||
maxCapacity += entry.getMaxCapacity();
|
||||
entry.setRemainingCapacity(remainingCapacity);
|
||||
entry.setMaxVmCapacity(maxCapacity);
|
||||
gpuCapacity.put(record.modelName, entry);
|
||||
} else {
|
||||
gpuCapacity.put(modelName, remainingCapacity);
|
||||
VgpuTypesInfo vgpuTypeRecord = new VgpuTypesInfo(record.modelName, record.framebufferSize, record.maxHeads,
|
||||
record.maxResolutionX, record.maxResolutionY, maxCapacity, remainingCapacity, maxCapacity);
|
||||
gpuCapacity.put(record.modelName, vgpuTypeRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,6 +63,7 @@ import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.UnsupportedAnswer;
|
||||
import com.cloud.agent.api.UpdateHostPasswordCommand;
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.agent.api.to.GPUDeviceTO;
|
||||
import com.cloud.agent.transport.Request;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
@ -2537,7 +2538,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGPUDetails(long hostId, HashMap<String, HashMap<String, Long>> groupDetails) {
|
||||
public void updateGPUDetails(long hostId, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
|
||||
// Update GPU group capacity
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
txn.start();
|
||||
@ -2547,7 +2548,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, HashMap<String, Long>> getGPUStatistics(HostVO host) {
|
||||
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGPUStatistics(HostVO host) {
|
||||
Answer answer = _agentMgr.easySend(host.getId(), new GetGPUStatsCommand(host.getGuid(), host.getName()));
|
||||
if (answer != null && (answer instanceof UnsupportedAnswer)) {
|
||||
return null;
|
||||
|
||||
@ -49,6 +49,7 @@ import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.GetStorageStatsCommand;
|
||||
import com.cloud.agent.api.HostStatsEntry;
|
||||
import com.cloud.agent.api.PerformanceMonitorCommand;
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.agent.api.VmDiskStatsEntry;
|
||||
import com.cloud.agent.api.VmStatsEntry;
|
||||
import com.cloud.cluster.ManagementServerHostVO;
|
||||
@ -342,7 +343,7 @@ public class StatsCollector extends ManagerBase implements ComponentMethodInterc
|
||||
gpuEnabledHosts = hosts;
|
||||
}
|
||||
for (HostVO host : gpuEnabledHosts) {
|
||||
HashMap<String, HashMap<String, Long>> groupDetails = _resourceMgr.getGPUStatistics(host);
|
||||
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = _resourceMgr.getGPUStatistics(host);
|
||||
if (groupDetails != null) {
|
||||
_resourceMgr.updateGPUDetails(host.getId(), groupDetails);
|
||||
}
|
||||
|
||||
@ -36,6 +36,7 @@ import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
|
||||
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.api.VgpuTypesInfo;
|
||||
import com.cloud.agent.api.to.GPUDeviceTO;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
@ -576,12 +577,12 @@ public class MockResourceManagerImpl extends ManagerBase implements ResourceMana
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGPUDetails(long hostId, HashMap<String, HashMap<String, Long>> deviceDetails) {
|
||||
public void updateGPUDetails(long hostId, HashMap<String, HashMap<String, VgpuTypesInfo>> deviceDetails) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, HashMap<String, Long>> getGPUStatistics(HostVO host) {
|
||||
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGPUStatistics(HostVO host) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -738,7 +738,13 @@ CREATE TABLE `cloud`.`vgpu_types` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`gpu_group_id` bigint(20) unsigned NOT NULL,
|
||||
`vgpu_type` varchar(40) NOT NULL COMMENT 'vgpu type supported by this gpu group',
|
||||
`remaining_vm_capacity` bigint(20) unsigned DEFAULT NULL COMMENT 'remaining vgpu can be created with this vgpu_type on the given gpu group',
|
||||
`video_ram` bigint(20) unsigned DEFAULT NULL COMMENT 'video RAM for this vgpu type',
|
||||
`max_heads` bigint(20) unsigned DEFAULT NULL COMMENT 'maximum displays per user',
|
||||
`max_resolution_x` bigint(20) unsigned DEFAULT NULL COMMENT 'maximum X resolution per display',
|
||||
`max_resolution_y` bigint(20) unsigned DEFAULT NULL COMMENT 'maximum Y resolution per display',
|
||||
`max_vgpu_per_pgpu` bigint(20) unsigned DEFAULT NULL COMMENT 'max number of vgpus per physical gpu (pgpu)',
|
||||
`remaining_capacity` bigint(20) unsigned DEFAULT NULL COMMENT 'remaining vgpu can be created with this vgpu_type on the given gpu group',
|
||||
`max_capacity` bigint(20) unsigned DEFAULT NULL COMMENT 'maximum vgpu can be created with this vgpu_type on the given gpu group',
|
||||
PRIMARY KEY (`id`),
|
||||
CONSTRAINT `fk_vgpu_types__gpu_group_id` FOREIGN KEY (`gpu_group_id`) REFERENCES `host_gpu_groups` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB CHARSET=utf8;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user