|
17 | 17 | package org.apache.cloudstack.api.command.admin.gpu; |
18 | 18 |
|
19 | 19 | import com.cloud.user.Account; |
| 20 | +import org.apache.cloudstack.acl.RoleType; |
20 | 21 | import org.apache.cloudstack.api.APICommand; |
21 | 22 | import org.apache.cloudstack.api.ApiConstants; |
22 | 23 | import org.apache.cloudstack.api.ApiErrorCode; |
|
28 | 29 | import org.apache.cloudstack.api.response.HostResponse; |
29 | 30 | import org.apache.cloudstack.api.response.VgpuProfileResponse; |
30 | 31 | import org.apache.cloudstack.gpu.GpuDevice; |
31 | | -import org.apache.cloudstack.gpu.GpuService; |
32 | 32 | import org.apache.commons.lang3.EnumUtils; |
33 | 33 | import org.apache.commons.lang3.StringUtils; |
34 | 34 |
|
35 | | -import javax.inject.Inject; |
36 | 35 |
|
37 | | -@APICommand(name = "createGpuDevice", |
38 | | - description = "Creates a GPU device manually on a host", |
39 | | - responseObject = GpuDeviceResponse.class, |
40 | | - since = "4.21.0", |
41 | | - requestHasSensitiveInfo = false, |
42 | | - responseHasSensitiveInfo = false) |
| 36 | +@APICommand(name = "createGpuDevice", description = "Creates a GPU device manually on a host", |
| 37 | + responseObject = GpuDeviceResponse.class, since = "4.21.0", requestHasSensitiveInfo = false, |
| 38 | + responseHasSensitiveInfo = false, authorized = {RoleType.Admin}) |
43 | 39 | public class CreateGpuDeviceCmd extends BaseCmd { |
44 | 40 |
|
45 | | - @Inject |
46 | | - private GpuService gpuService; |
47 | | - |
48 | | - @Parameter(name = ApiConstants.HOST_ID, |
49 | | - type = CommandType.UUID, |
50 | | - entityType = HostResponse.class, |
51 | | - required = true, |
52 | | - description = "ID of the host where the GPU device is located") |
| 41 | + @Parameter(name = ApiConstants.HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, required = true, |
| 42 | + description = "ID of the host where the GPU device is located") |
53 | 43 | private Long hostId; |
54 | 44 |
|
55 | | - @Parameter(name = ApiConstants.BUS_ADDRESS, |
56 | | - type = CommandType.STRING, |
57 | | - required = true, |
58 | | - description = "PCI bus address of the GPU device (e.g., 0000:01:00.0) or UUID for MDEV devices.") |
| 45 | + @Parameter(name = ApiConstants.BUS_ADDRESS, type = CommandType.STRING, required = true, |
| 46 | + description = "PCI bus address of the GPU device (e.g., 0000:01:00.0) or UUID for MDEV devices.") |
59 | 47 | private String busAddress; |
60 | 48 |
|
61 | | - @Parameter(name = ApiConstants.GPU_CARD_ID, |
62 | | - type = CommandType.UUID, |
63 | | - entityType = GpuCardResponse.class, |
64 | | - required = true, |
65 | | - description = "ID of the GPU card type") |
| 49 | + @Parameter(name = ApiConstants.GPU_CARD_ID, type = CommandType.UUID, entityType = GpuCardResponse.class, |
| 50 | + required = true, description = "ID of the GPU card type") |
66 | 51 | private Long gpuCardId; |
67 | 52 |
|
68 | | - @Parameter(name = ApiConstants.VGPU_PROFILE_ID, |
69 | | - type = CommandType.UUID, |
70 | | - entityType = VgpuProfileResponse.class, |
71 | | - required = true, |
72 | | - description = "ID of the vGPU profile") |
| 53 | + @Parameter(name = ApiConstants.VGPU_PROFILE_ID, type = CommandType.UUID, entityType = VgpuProfileResponse.class, |
| 54 | + required = true, description = "ID of the vGPU profile") |
73 | 55 | private Long vgpuProfileId; |
74 | 56 |
|
75 | | - @Parameter(name = ApiConstants.TYPE, |
76 | | - type = CommandType.STRING, |
77 | | - description = "Type of GPU device (PCI, MDEV, VGPUOnly). Defaults to PCI.") |
| 57 | + @Parameter(name = ApiConstants.TYPE, type = CommandType.STRING, |
| 58 | + description = "Type of GPU device (PCI, MDEV, VGPUOnly). Defaults to PCI.") |
78 | 59 | private String type; |
79 | 60 |
|
80 | | - @Parameter(name = ApiConstants.PARENT_GPU_DEVICE_ID, |
81 | | - type = CommandType.UUID, |
82 | | - entityType = GpuDeviceResponse.class, |
83 | | - description = "ID of the parent GPU device (for virtual GPU devices)") |
| 61 | + @Parameter(name = ApiConstants.PARENT_GPU_DEVICE_ID, type = CommandType.UUID, entityType = GpuDeviceResponse.class, |
| 62 | + description = "ID of the parent GPU device (for virtual GPU devices)") |
84 | 63 | private Long parentGpuDeviceId; |
85 | 64 |
|
86 | | - @Parameter(name = ApiConstants.NUMA_NODE, |
87 | | - type = CommandType.STRING, |
88 | | - entityType = GpuDeviceResponse.class, |
89 | | - description = "NUMA node of the GPU device (e.g., 0, 1, etc.). This is optional and can be used to specify the NUMA node for the GPU device which is used during allocation. Defaults to -1") |
| 65 | + @Parameter(name = ApiConstants.NUMA_NODE, type = CommandType.STRING, |
| 66 | + description = "NUMA node of the GPU device (e.g., 0, 1, etc.). This is optional and can be used to " |
| 67 | + + "specify the NUMA node for the GPU device which is used during allocation. Defaults to -1") |
90 | 68 | private String numaNode; |
91 | 69 |
|
92 | | - @Parameter(name = ApiConstants.PCI_ROOT, |
93 | | - type = CommandType.STRING, |
94 | | - entityType = GpuDeviceResponse.class, |
95 | | - description = "PCI root of the GPU device.") |
96 | | - private String pciRoot; |
97 | | - |
98 | 70 | public Long getHostId() { |
99 | 71 | return hostId; |
100 | 72 | } |
@@ -133,10 +105,6 @@ public String getNumaNode() { |
133 | 105 | return numaNode; |
134 | 106 | } |
135 | 107 |
|
136 | | - public String getPciRoot() { |
137 | | - return pciRoot; |
138 | | - } |
139 | | - |
140 | 108 | @Override |
141 | 109 | public void execute() { |
142 | 110 | try { |
|
0 commit comments