Skip to content

Commit 2df1ac5

Browse files
committed
2 parents 576b97b + 0785ba0 commit 2df1ac5

File tree

135 files changed

+4015
-1726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+4015
-1726
lines changed

api/src/main/java/com/cloud/cpu/CPU.java

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,55 @@
1616
// under the License.
1717
package com.cloud.cpu;
1818

19-
import com.cloud.utils.exception.CloudRuntimeException;
2019
import org.apache.commons.lang3.StringUtils;
2120

22-
import java.util.LinkedHashMap;
23-
import java.util.Map;
24-
2521
public class CPU {
22+
public enum CPUArch {
23+
x86("i686", 32),
24+
amd64("x86_64", 64),
25+
arm64("aarch64", 64);
2626

27-
public static final String archX86Identifier = "i686";
28-
public static final String archX86_64Identifier = "x86_64";
29-
public static final String archARM64Identifier = "aarch64";
30-
31-
public static class CPUArch {
32-
private static final Map<String, CPUArch> cpuArchMap = new LinkedHashMap<>();
33-
34-
public static final CPUArch archX86 = new CPUArch(archX86Identifier, 32);
35-
public static final CPUArch amd64 = new CPUArch(archX86_64Identifier, 64);
36-
public static final CPUArch arm64 = new CPUArch(archARM64Identifier, 64);
27+
private final String type;
28+
private final int bits;
3729

38-
private String type;
39-
private int bits;
40-
41-
public CPUArch(String type, int bits) {
30+
CPUArch(String type, int bits) {
4231
this.type = type;
4332
this.bits = bits;
44-
cpuArchMap.put(type, this);
33+
}
34+
35+
public static CPUArch getDefault() {
36+
return amd64;
4537
}
4638

4739
public String getType() {
48-
return this.type;
40+
return type;
4941
}
5042

5143
public int getBits() {
52-
return this.bits;
44+
return bits;
5345
}
5446

5547
public static CPUArch fromType(String type) {
5648
if (StringUtils.isBlank(type)) {
57-
return amd64;
49+
return getDefault();
50+
}
51+
for (CPUArch arch : values()) {
52+
if (arch.type.equals(type)) {
53+
return arch;
54+
}
55+
}
56+
throw new IllegalArgumentException("Unsupported arch type: " + type);
57+
}
58+
59+
public static String getTypesAsCSV() {
60+
StringBuilder sb = new StringBuilder();
61+
for (CPUArch arch : values()) {
62+
sb.append(arch.getType()).append(",");
5863
}
59-
switch (type) {
60-
case archX86Identifier: return archX86;
61-
case archX86_64Identifier: return amd64;
62-
case archARM64Identifier: return arm64;
63-
default: throw new CloudRuntimeException(String.format("Unsupported arch type: %s", type));
64+
if (sb.length() > 0) {
65+
sb.setLength(sb.length() - 1);
6466
}
67+
return sb.toString();
6568
}
6669
}
6770
}

api/src/main/java/com/cloud/vm/VmDetailConstants.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,13 @@ public interface VmDetailConstants {
101101
String VMWARE_HOST_NAME = String.format("%s-host", VMWARE_TO_KVM_PREFIX);
102102
String VMWARE_DISK = String.format("%s-disk", VMWARE_TO_KVM_PREFIX);
103103
String VMWARE_MAC_ADDRESSES = String.format("%s-mac-addresses", VMWARE_TO_KVM_PREFIX);
104+
105+
// TPM
106+
String VIRTUAL_TPM_ENABLED = "virtual.tpm.enabled";
107+
String VIRTUAL_TPM_MODEL = "virtual.tpm.model";
108+
String VIRTUAL_TPM_VERSION = "virtual.tpm.version";
109+
110+
// CPU mode and model, ADMIN only
111+
String GUEST_CPU_MODE = "guest.cpu.mode";
112+
String GUEST_CPU_MODEL = "guest.cpu.model";
104113
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,12 +485,11 @@ public class ApiConstants {
485485
public static final String STATE = "state";
486486
public static final String STATS = "stats";
487487
public static final String STATUS = "status";
488+
public static final String STORAGE_TYPE = "storagetype";
489+
public static final String STORAGE_POLICY = "storagepolicy";
490+
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
488491
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
489492
public static final String STORAGE_CUSTOM_STATS = "storagecustomstats";
490-
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
491-
public static final String STORAGE_POLICY = "storagepolicy";
492-
public static final String STORAGE_POOL = "storagepool";
493-
public static final String STORAGE_TYPE = "storagetype";
494493
public static final String SUBNET = "subnet";
495494
public static final String OWNER = "owner";
496495
public static final String SWAP_OWNER = "swapowner";

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java

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

22-
2322
import org.apache.cloudstack.api.APICommand;
2423
import org.apache.cloudstack.api.ApiConstants;
2524
import org.apache.cloudstack.api.BaseListCmd;
@@ -28,7 +27,9 @@
2827
import org.apache.cloudstack.api.response.ListResponse;
2928
import org.apache.cloudstack.api.response.PodResponse;
3029
import org.apache.cloudstack.api.response.ZoneResponse;
30+
import org.apache.commons.lang3.StringUtils;
3131

32+
import com.cloud.cpu.CPU;
3233
import com.cloud.org.Cluster;
3334
import com.cloud.utils.Pair;
3435

@@ -68,6 +69,11 @@ public class ListClustersCmd extends BaseListCmd {
6869
@Parameter(name = ApiConstants.SHOW_CAPACITIES, type = CommandType.BOOLEAN, description = "flag to display the capacity of the clusters")
6970
private Boolean showCapacities;
7071

72+
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
73+
description = "CPU arch of the clusters",
74+
since = "4.20.1")
75+
private String arch;
76+
7177
/////////////////////////////////////////////////////
7278
/////////////////// Accessors ///////////////////////
7379
/////////////////////////////////////////////////////
@@ -112,6 +118,10 @@ public Boolean getShowCapacities() {
112118
return showCapacities;
113119
}
114120

121+
public CPU.CPUArch getArch() {
122+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
123+
}
124+
115125
/////////////////////////////////////////////////////
116126
/////////////// API Implementation///////////////////
117127
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24-
2524
import org.apache.cloudstack.api.APICommand;
2625
import org.apache.cloudstack.api.ApiCommandResourceType;
2726
import org.apache.cloudstack.api.ApiConstants;
@@ -35,7 +34,9 @@
3534
import org.apache.cloudstack.api.response.PodResponse;
3635
import org.apache.cloudstack.api.response.UserVmResponse;
3736
import org.apache.cloudstack.api.response.ZoneResponse;
37+
import org.apache.commons.lang3.StringUtils;
3838

39+
import com.cloud.cpu.CPU;
3940
import com.cloud.exception.InvalidParameterValueException;
4041
import com.cloud.host.Host;
4142
import com.cloud.hypervisor.Hypervisor.HypervisorType;
@@ -109,6 +110,9 @@ public class ListHostsCmd extends BaseListCmd {
109110
@Parameter(name = ApiConstants.MANAGEMENT_SERVER_ID, type = CommandType.UUID, entityType = ManagementServerResponse.class, description = "the id of the management server", since="4.21.0")
110111
private Long managementServerId;
111112

113+
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING, description = "CPU Arch of the host", since = "4.20.1")
114+
private String arch;
115+
112116
/////////////////////////////////////////////////////
113117
/////////////////// Accessors ///////////////////////
114118
/////////////////////////////////////////////////////
@@ -197,6 +201,10 @@ public Long getManagementServerId() {
197201
return managementServerId;
198202
}
199203

204+
public CPU.CPUArch getArch() {
205+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
206+
}
207+
200208
/////////////////////////////////////////////////////
201209
/////////////// API Implementation///////////////////
202210
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/router/ListRoutersCmd.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.command.admin.router;
1818

19-
import org.apache.commons.lang.BooleanUtils;
20-
2119
import org.apache.cloudstack.api.APICommand;
2220
import org.apache.cloudstack.api.ApiCommandResourceType;
2321
import org.apache.cloudstack.api.ApiConstants;
@@ -32,7 +30,10 @@
3230
import org.apache.cloudstack.api.response.UserVmResponse;
3331
import org.apache.cloudstack.api.response.VpcResponse;
3432
import org.apache.cloudstack.api.response.ZoneResponse;
33+
import org.apache.commons.lang.BooleanUtils;
34+
import org.apache.commons.lang3.StringUtils;
3535

36+
import com.cloud.cpu.CPU;
3637
import com.cloud.network.router.VirtualRouter.Role;
3738
import com.cloud.vm.VirtualMachine;
3839

@@ -86,6 +87,11 @@ public class ListRoutersCmd extends BaseListProjectAndAccountResourcesCmd {
8687
description = "if true is passed for this parameter, also fetch last executed health check results for the router. Default is false")
8788
private Boolean fetchHealthCheckResults;
8889

90+
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
91+
description = "CPU arch of the router",
92+
since = "4.20.1")
93+
private String arch;
94+
8995
/////////////////////////////////////////////////////
9096
/////////////////// Accessors ///////////////////////
9197
/////////////////////////////////////////////////////
@@ -146,6 +152,10 @@ public boolean shouldFetchHealthCheckResults() {
146152
return BooleanUtils.isTrue(fetchHealthCheckResults);
147153
}
148154

155+
public CPU.CPUArch getArch() {
156+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
157+
}
158+
149159

150160
/////////////////////////////////////////////////////
151161
/////////////// API Implementation///////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java

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

22-
2322
import org.apache.cloudstack.api.APICommand;
2423
import org.apache.cloudstack.api.ApiCommandResourceType;
2524
import org.apache.cloudstack.api.ApiConstants;
@@ -31,7 +30,9 @@
3130
import org.apache.cloudstack.api.response.StoragePoolResponse;
3231
import org.apache.cloudstack.api.response.SystemVmResponse;
3332
import org.apache.cloudstack.api.response.ZoneResponse;
33+
import org.apache.commons.lang3.StringUtils;
3434

35+
import com.cloud.cpu.CPU;
3536
import com.cloud.utils.Pair;
3637
import com.cloud.vm.VirtualMachine;
3738

@@ -74,6 +75,11 @@ public class ListSystemVMsCmd extends BaseListCmd {
7475
since = "3.0.1")
7576
private Long storageId;
7677

78+
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
79+
description = "CPU arch of the system VM",
80+
since = "4.20.1")
81+
private String arch;
82+
7783
/////////////////////////////////////////////////////
7884
/////////////////// Accessors ///////////////////////
7985
/////////////////////////////////////////////////////
@@ -110,6 +116,10 @@ public Long getStorageId() {
110116
return storageId;
111117
}
112118

119+
public CPU.CPUArch getArch() {
120+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
121+
}
122+
113123
/////////////////////////////////////////////////////
114124
/////////////// API Implementation///////////////////
115125
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/vm/ListVMsCmd.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646
import org.apache.cloudstack.api.response.UserVmResponse;
4747
import org.apache.cloudstack.api.response.VpcResponse;
4848
import org.apache.cloudstack.api.response.ZoneResponse;
49-
import org.apache.commons.lang3.BooleanUtils;
5049
import org.apache.commons.collections.CollectionUtils;
50+
import org.apache.commons.lang3.BooleanUtils;
51+
import org.apache.commons.lang3.StringUtils;
5152

53+
import com.cloud.cpu.CPU;
5254
import com.cloud.exception.InvalidParameterValueException;
5355
import com.cloud.server.ResourceIcon;
5456
import com.cloud.server.ResourceTag;
@@ -153,6 +155,11 @@ public class ListVMsCmd extends BaseListRetrieveOnlyResourceCountCmd implements
153155
@Parameter(name = ApiConstants.USER_DATA_ID, type = CommandType.UUID, entityType = UserDataResponse.class, required = false, description = "the instances by userdata", since = "4.20.1")
154156
private Long userdataId;
155157

158+
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING,
159+
description = "CPU arch of the VM",
160+
since = "4.20.1")
161+
private String arch;
162+
156163
/////////////////////////////////////////////////////
157164
/////////////////// Accessors ///////////////////////
158165
/////////////////////////////////////////////////////
@@ -292,6 +299,10 @@ public Boolean getVnf() {
292299
return isVnf;
293300
}
294301

302+
public CPU.CPUArch getArch() {
303+
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
304+
}
305+
295306
/////////////////////////////////////////////////////
296307
/////////////// API Implementation///////////////////
297308
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/response/DomainRouterResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ public class DomainRouterResponse extends BaseResponseWithAnnotations implements
245245
@Param(description = "the version of the code / software in the router")
246246
private String softwareVersion;
247247

248+
@SerializedName(ApiConstants.ARCH)
249+
@Param(description = "CPU arch of the router", since = "4.20.1")
250+
private String arch;
251+
248252
public DomainRouterResponse() {
249253
nics = new LinkedHashSet<NicResponse>();
250254
}
@@ -518,4 +522,8 @@ public String getSoftwareVersion() {
518522
public void setSoftwareVersion(String softwareVersion) {
519523
this.softwareVersion = softwareVersion;
520524
}
525+
526+
public void setArch(String arch) {
527+
this.arch = arch;
528+
}
521529
}

api/src/main/java/org/apache/cloudstack/api/response/HostResponse.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public class HostResponse extends BaseResponseWithAnnotations {
152152
@Deprecated
153153
@SerializedName("memoryallocated")
154154
@Param(description = "the amount of the host's memory currently allocated")
155-
private Long memoryAllocated;
155+
private long memoryAllocated;
156156

157157
@SerializedName("memoryallocatedpercentage")
158158
@Param(description = "the amount of the host's memory currently allocated in percentage")
@@ -415,7 +415,7 @@ public void setMemWithOverprovisioning(String memWithOverprovisioning){
415415
this.memWithOverprovisioning=memWithOverprovisioning;
416416
}
417417

418-
public void setMemoryAllocated(Long memoryAllocated) {
418+
public void setMemoryAllocated(long memoryAllocated) {
419419
this.memoryAllocated = memoryAllocated;
420420
}
421421

@@ -703,8 +703,8 @@ public Long getMemoryTotal() {
703703
return memoryTotal;
704704
}
705705

706-
public Long getMemoryAllocated() {
707-
return memoryAllocated == null ? 0 : memoryAllocated;
706+
public long getMemoryAllocated() {
707+
return memoryAllocated;
708708
}
709709

710710
public void setMemoryAllocatedPercentage(String memoryAllocatedPercentage) {

0 commit comments

Comments
 (0)