Skip to content

Commit 127196e

Browse files
CLOUDSTACK-6366: add vgpuTypes details in vgpu_types table.
1 parent 68c80e2 commit 127196e

16 files changed

Lines changed: 234 additions & 52 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.package com.cloud.agent.api;
17+
public class VgpuTypesInfo {
18+
19+
private String modelName;
20+
private Long maxHeads;
21+
private Long videoRam;
22+
private Long maxResolutionX;
23+
private Long maxResolutionY;
24+
private Long maxVgpuPerGpu;
25+
private Long remainingCapacity;
26+
private Long maxCapacity;
27+
28+
public String getModelName() {
29+
return modelName;
30+
}
31+
32+
public Long getVideoRam() {
33+
return videoRam;
34+
}
35+
36+
public Long getMaxHeads() {
37+
return maxHeads;
38+
}
39+
40+
public Long getMaxResolutionX() {
41+
return maxResolutionX;
42+
}
43+
44+
public Long getMaxResolutionY() {
45+
return maxResolutionY;
46+
}
47+
48+
public Long getMaxVpuPerGpu() {
49+
return maxVgpuPerGpu;
50+
}
51+
52+
public Long getRemainingCapacity() {
53+
return remainingCapacity;
54+
}
55+
56+
public void setRemainingCapacity(Long remainingCapacity) {
57+
this.remainingCapacity = remainingCapacity;
58+
}
59+
60+
public Long getMaxCapacity() {
61+
return maxCapacity;
62+
}
63+
64+
public void setMaxVmCapacity(Long maxCapacity) {
65+
this.maxCapacity = maxCapacity;
66+
}
67+
68+
public VgpuTypesInfo(String modelName, Long videoRam, Long maxHeads, Long maxResolutionX, Long maxResolutionY, Long maxVgpuPerGpu,
69+
Long remainingCapacity, Long maxCapacity) {
70+
this.modelName = modelName;
71+
this.videoRam = videoRam;
72+
this.maxHeads = maxHeads;
73+
this.maxResolutionX = maxResolutionX;
74+
this.maxResolutionY = maxResolutionY;
75+
this.maxVgpuPerGpu = maxVgpuPerGpu;
76+
this.remainingCapacity = remainingCapacity;
77+
this.maxCapacity = maxCapacity;
78+
}
79+
}

api/src/com/cloud/agent/api/to/GPUDeviceTO.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
import java.util.HashMap;
2020

21+
import com.cloud.agent.api.VgpuTypesInfo;
22+
2123
public class GPUDeviceTO {
2224

2325
private String gpuGroup;
2426
private String vgpuType;
25-
private HashMap<String, HashMap<String, Long>> groupDetails = new HashMap<String, HashMap<String, Long>>();
27+
private HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
2628

27-
public GPUDeviceTO( String gpuGroup, String vgpuType, HashMap<String, HashMap<String, Long>> groupDetails) {
29+
public GPUDeviceTO( String gpuGroup, String vgpuType, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
2830
this.gpuGroup = gpuGroup;
2931
this.vgpuType = vgpuType;
3032
this.groupDetails = groupDetails;
@@ -46,11 +48,12 @@ public void setVgpuType(String vgpuType) {
4648
this.vgpuType = vgpuType;
4749
}
4850

49-
public HashMap<String, HashMap<String, Long>> getGroupDetails() {
51+
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGroupDetails() {
5052
return groupDetails;
5153
}
5254

53-
public void setGroupDetails(HashMap<String, HashMap<String, Long>> groupDetails) {
55+
public void setGroupDetails(HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
5456
this.groupDetails = groupDetails;
5557
}
58+
5659
}

core/src/com/cloud/agent/api/GetGPUStatsAnswer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
@LogLevel(Log4jLevel.Trace)
2424
public class GetGPUStatsAnswer extends Answer {
2525

26-
private HashMap<String, HashMap<String, Long>> groupDetails;
26+
private HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails;
2727

28-
public GetGPUStatsAnswer(GetGPUStatsCommand cmd, HashMap<String, HashMap<String, Long>> groupDetails) {
28+
public GetGPUStatsAnswer(GetGPUStatsCommand cmd, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
2929
super(cmd);
3030
this.groupDetails = groupDetails;
3131
}
3232

33-
public HashMap<String, HashMap<String, Long>> getGroupDetails() {
33+
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGroupDetails() {
3434
return this.groupDetails;
3535
}
3636
}

core/src/com/cloud/agent/api/StartupRoutingCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public String getHost() {
7070
HypervisorType hypervisorType;
7171
Map<String, String> hostDetails; //stuff like host os, cpu capabilities
7272
String hypervisorVersion;
73-
HashMap<String, HashMap<String, Long>> groupDetails = new HashMap<String, HashMap<String, Long>>();
73+
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
7474

7575
public StartupRoutingCommand() {
7676
super(Host.Type.Routing);
@@ -246,11 +246,11 @@ public void setHostVmStateReport(Map<String, HostVmStateReportEntry> hostVmState
246246
this._hostVmStateReport = hostVmStateReport;
247247
}
248248

249-
public HashMap<String, HashMap<String, Long>> getGpuGroupDetails() {
249+
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGpuGroupDetails() {
250250
return groupDetails;
251251
}
252252

253-
public void setGpuGroupDetails(HashMap<String, HashMap<String, Long>> groupDetails) {
253+
public void setGpuGroupDetails(HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
254254
this.groupDetails = groupDetails;
255255
}
256256
}

engine/components-api/src/com/cloud/resource/ResourceManager.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import com.cloud.agent.api.StartupCommand;
2525
import com.cloud.agent.api.StartupRoutingCommand;
26+
import com.cloud.agent.api.VgpuTypesInfo;
2627
import com.cloud.agent.api.to.GPUDeviceTO;
2728
import com.cloud.dc.DataCenterVO;
2829
import com.cloud.dc.HostPodVO;
@@ -180,12 +181,12 @@ public interface ResourceManager extends ResourceService {
180181
* @param hostId, the dest host Id
181182
* @param groupDetails, capacity of GPU group.
182183
*/
183-
void updateGPUDetails(long hostId, HashMap<String, HashMap<String, Long>> groupDetails);
184+
void updateGPUDetails(long hostId, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails);
184185

185186
/**
186187
* Get GPU details for a host
187188
* @param host, the Host object
188189
* @return Details of groupNames and enabled VGPU type with remaining capacity.
189190
*/
190-
HashMap<String, HashMap<String, Long>> getGPUStatistics(HostVO host);
191+
HashMap<String, HashMap<String, VgpuTypesInfo>> getGPUStatistics(HostVO host);
191192
}

engine/schema/src/com/cloud/gpu/VGPUTypesVO.java

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,55 @@ public class VGPUTypesVO implements InternalIdentity {
3333
@Column(name="id")
3434
private long id;
3535

36+
@Column(name="gpu_group_id")
37+
private long gpuGroupId;
38+
3639
@Column(name="vgpu_type")
3740
private String vgpuType;
3841

39-
@Column(name="gpu_group_id")
40-
private long gpuGroupId;
42+
@Column(name="video_ram")
43+
private long videoRam;
44+
45+
@Column(name="max_heads")
46+
private long maxHeads;
4147

42-
@Column(name="remaining_vm_capacity")
48+
@Column(name="max_resolution_x")
49+
private long maxResolutionX;
50+
51+
@Column(name="max_resolution_y")
52+
private long maxResolutionY;
53+
54+
@Column(name="max_vgpu_per_pgpu")
55+
private long maxVgpuPerPgpu;
56+
57+
@Column(name="remaining_capacity")
4358
private long remainingCapacity;
4459

60+
@Column(name="max_capacity")
61+
private long maxCapacity;
62+
4563
protected VGPUTypesVO() {
4664
}
4765

48-
public VGPUTypesVO(String vgpuType, long gpuGroupId, long remainingCapacity) {
49-
this.vgpuType = vgpuType;
66+
public VGPUTypesVO(long gpuGroupId, String vgpuType, long videoRam, long maxHeads, long maxResolutionX, long maxResolutionY, long maxVgpuPerPgpu,
67+
long remainingCapacity, long maxCapacity) {
5068
this.gpuGroupId = gpuGroupId;
69+
this.vgpuType = vgpuType;
70+
this.videoRam = videoRam;
71+
this.maxHeads = maxHeads;
72+
this.maxResolutionX = maxResolutionX;
73+
this.maxResolutionY = maxResolutionY;
74+
this.maxVgpuPerPgpu = maxVgpuPerPgpu;
5175
this.remainingCapacity = remainingCapacity;
76+
this.maxCapacity = maxCapacity;
77+
}
78+
79+
public long getGpuGroupId() {
80+
return gpuGroupId;
81+
}
82+
83+
public void setGpuGroupId(long gpuGroupId) {
84+
this.gpuGroupId = gpuGroupId;
5285
}
5386

5487
public String getVgpuType() {
@@ -59,12 +92,44 @@ public void setVgpuType(String vgpuType) {
5992
this.vgpuType = vgpuType;
6093
}
6194

62-
public long getGpuGroupId() {
63-
return gpuGroupId;
95+
public long getVideoRam() {
96+
return videoRam;
6497
}
6598

66-
public void setGpuGroupId(long gpuGroupId) {
67-
this.gpuGroupId = gpuGroupId;
99+
public void setVideoRam(long videoRam) {
100+
this.videoRam = videoRam;
101+
}
102+
103+
public long getMaxHeads() {
104+
return maxHeads;
105+
}
106+
107+
public void setMaxHeads(long maxHeads) {
108+
this.maxHeads = maxHeads;
109+
}
110+
111+
public long getMaxResolutionX() {
112+
return maxResolutionX;
113+
}
114+
115+
public void setMaxResolutionX(long maxResolutionX) {
116+
this.maxResolutionX = maxResolutionX;
117+
}
118+
119+
public long getMaxResolutionY() {
120+
return maxResolutionY;
121+
}
122+
123+
public void setMaxResolutionY(long maxResolutionY) {
124+
this.maxResolutionY = maxResolutionY;
125+
}
126+
127+
public long getMaxVgpuPerPgpu() {
128+
return maxVgpuPerPgpu;
129+
}
130+
131+
public void setMaxVgpuPerPgpu(long maxVgpuPerPgpu) {
132+
this.maxVgpuPerPgpu = maxVgpuPerPgpu;
68133
}
69134

70135
public long getRemainingCapacity() {
@@ -75,6 +140,14 @@ public void setRemainingCapacity(long remainingCapacity) {
75140
this.remainingCapacity = remainingCapacity;
76141
}
77142

143+
public long getMaxCapacity() {
144+
return maxCapacity;
145+
}
146+
147+
public void setMaxCapacity(long maxCapacity) {
148+
this.maxCapacity = maxCapacity;
149+
}
150+
78151
@Override
79152
public long getId() {
80153
return id;

engine/schema/src/com/cloud/gpu/dao/VGPUTypesDao.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.HashMap;
2020
import java.util.List;
2121

22+
import com.cloud.agent.api.VgpuTypesInfo;
2223
import com.cloud.gpu.VGPUTypesVO;
2324
import com.cloud.utils.db.GenericDao;
2425

@@ -44,5 +45,5 @@ public interface VGPUTypesDao extends GenericDao<VGPUTypesVO, Long> {
4445
* @param hostId the host
4546
* @param groupDetails with enabled VGPU types
4647
*/
47-
void persist(long hostId, HashMap<String, HashMap<String, Long>> groupDetails);
48+
void persist(long hostId, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails);
4849
}

engine/schema/src/com/cloud/gpu/dao/VGPUTypesDaoImpl.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.apache.log4j.Logger;
2828
import org.springframework.stereotype.Component;
2929

30+
import com.cloud.agent.api.VgpuTypesInfo;
3031
import com.cloud.gpu.HostGpuGroupsVO;
3132
import com.cloud.gpu.VGPUTypesVO;
3233
import com.cloud.utils.db.GenericDaoBase;
@@ -73,20 +74,23 @@ public VGPUTypesVO findByGroupIdVGPUType(long groupId, String vgpuType) {
7374
}
7475

7576
@Override
76-
public void persist(long hostId, HashMap<String, HashMap<String, Long>> groupDetails) {
77-
Iterator<Entry<String, HashMap<String, Long>>> it1 = groupDetails.entrySet().iterator();
77+
public void persist(long hostId, HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
78+
Iterator<Entry<String, HashMap<String, VgpuTypesInfo>>> it1 = groupDetails.entrySet().iterator();
7879
while (it1.hasNext()) {
79-
Entry<String, HashMap<String, Long>> entry = it1.next();
80+
Entry<String, HashMap<String, VgpuTypesInfo>> entry = it1.next();
8081
HostGpuGroupsVO gpuGroup = _hostGpuGroupsDao.findByHostIdGroupName(hostId, entry.getKey());
81-
HashMap<String, Long> values = entry.getValue();
82-
Iterator<Entry<String, Long>> it2 = values.entrySet().iterator();
82+
HashMap<String, VgpuTypesInfo> values = entry.getValue();
83+
Iterator<Entry<String, VgpuTypesInfo>> it2 = values.entrySet().iterator();
8384
while (it2.hasNext()) {
84-
Entry<String, Long> record = it2.next();
85+
Entry<String, VgpuTypesInfo> record = it2.next();
86+
VgpuTypesInfo details = record.getValue();
8587
VGPUTypesVO vgpuType = null;
8688
if ((vgpuType = findByGroupIdVGPUType(gpuGroup.getId(), record.getKey())) == null) {
87-
persist(new VGPUTypesVO(record.getKey(), gpuGroup.getId(), record.getValue()));
89+
persist(new VGPUTypesVO(gpuGroup.getId(), record.getKey(), details.getVideoRam(), details.getMaxHeads(), details.getMaxResolutionX(),
90+
details.getMaxResolutionY(), details.getMaxVpuPerGpu(), details.getRemainingCapacity(), details.getMaxCapacity()));
8891
} else {
89-
vgpuType.setRemainingCapacity(record.getValue());
92+
vgpuType.setRemainingCapacity(details.getRemainingCapacity());
93+
vgpuType.setMaxCapacity(details.getMaxCapacity());
9094
update(vgpuType.getId(), vgpuType);
9195
}
9296
}

engine/schema/src/com/cloud/host/HostVO.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import javax.persistence.TemporalType;
3939
import javax.persistence.Transient;
4040

41+
import com.cloud.agent.api.VgpuTypesInfo;
4142
import com.cloud.hypervisor.Hypervisor.HypervisorType;
4243
import com.cloud.resource.ResourceState;
4344
import com.cloud.storage.Storage.StoragePoolType;
@@ -156,7 +157,7 @@ public class HostVO implements Host {
156157

157158
// This value is only for saving and current cannot be loaded.
158159
@Transient
159-
HashMap<String, HashMap<String, Long>> groupDetails = new HashMap<String, HashMap<String, Long>>();
160+
HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails = new HashMap<String, HashMap<String, VgpuTypesInfo>>();
160161

161162
@Override
162163
public String getStorageIpAddressDeux() {
@@ -318,11 +319,11 @@ public void setHostTags(List<String> hostTags) {
318319
this.hostTags = hostTags;
319320
}
320321

321-
public HashMap<String, HashMap<String, Long>> getGpuGroupDetails() {
322+
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGpuGroupDetails() {
322323
return groupDetails;
323324
}
324325

325-
public void setGpuGroups(HashMap<String, HashMap<String, Long>> groupDetails) {
326+
public void setGpuGroups(HashMap<String, HashMap<String, VgpuTypesInfo>> groupDetails) {
326327
this.groupDetails = groupDetails;
327328
}
328329

0 commit comments

Comments
 (0)