Skip to content

Commit 896c3b6

Browse files
authored
Merge branch 'main' into feature-ui-logs
2 parents 4a9e4ae + fd74895 commit 896c3b6

File tree

208 files changed

+7797
-1777
lines changed

Some content is hidden

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

208 files changed

+7797
-1777
lines changed

INSTALL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ Install tools and dependencies used for development:
2020

2121
Set up Maven (3.6.0):
2222

23-
# wget http://www.us.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
24-
# tar -zxvf apache-maven-3.6.3-bin.tar.gz -C /usr/local
23+
# wget https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
24+
# tar -zxvf apache-maven-3.9.9-bin.tar.gz -C /usr/local
2525
# cd /usr/local
26-
# ln -s apache-maven-3.6.3 maven
26+
# ln -s apache-maven-3.9.9 maven
2727
# echo export M2_HOME=/usr/local/maven >> ~/.bashrc # or .zshrc or .profile
2828
# echo export PATH=/usr/local/maven/bin:${PATH} >> ~/.bashrc # or .zshrc or .profile
2929
# source ~/.bashrc

agent/src/main/java/com/cloud/agent/Agent.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,9 @@ protected void processRequest(final Request request, final Link link) {
800800
}
801801
commandsInProgress.incrementAndGet();
802802
try {
803+
if (cmd.isReconcile()) {
804+
cmd.setRequestSequence(request.getSequence());
805+
}
803806
answer = serverResource.executeRequest(cmd);
804807
} finally {
805808
commandsInProgress.decrementAndGet();
@@ -1021,6 +1024,8 @@ private void processPingAnswer(final PingAnswer answer) {
10211024
if ((answer.isSendStartup()) && reconnectAllowed) {
10221025
logger.info("Management server requested startup command to reinitialize the agent");
10231026
sendStartup(link);
1027+
} else {
1028+
serverResource.processPingAnswer((PingAnswer) answer);
10241029
}
10251030
shell.setAvoidHosts(answer.getAvoidMsList());
10261031
}
@@ -1087,6 +1092,9 @@ public void processOtherTask(final Task task) {
10871092
Answer answer = null;
10881093
commandsInProgress.incrementAndGet();
10891094
try {
1095+
if (command.isReconcile()) {
1096+
command.setRequestSequence(req.getSequence());
1097+
}
10901098
answer = serverResource.executeRequest(command);
10911099
} finally {
10921100
commandsInProgress.decrementAndGet();

api/src/main/java/com/cloud/agent/api/Command.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,31 @@ public static enum OnError {
3535
Continue, Stop
3636
}
3737

38+
public enum State {
39+
CREATED, // Command is created by management server
40+
STARTED, // Command is started by agent
41+
PROCESSING, // Processing by agent
42+
PROCESSING_IN_BACKEND, // Processing in backend by agent
43+
COMPLETED, // Operation succeeds by agent or management server
44+
FAILED, // Operation fails by agent
45+
RECONCILE_RETRY, // Ready for retry of reconciliation
46+
RECONCILING, // Being reconciled by management server
47+
RECONCILED, // Reconciled by management server
48+
RECONCILE_SKIPPED, // Skip the reconciliation as the resource state is inconsistent with the command
49+
RECONCILE_FAILED, // Fail to reconcile by management server
50+
TIMED_OUT, // Timed out on management server or agent
51+
INTERRUPTED, // Interrupted by management server or agent (for example agent is restarted),
52+
DANGLED_IN_BACKEND // Backend process which cannot be processed normally (for example agent is restarted)
53+
}
54+
3855
public static final String HYPERVISOR_TYPE = "hypervisorType";
3956

4057
// allow command to carry over hypervisor or other environment related context info
4158
@LogLevel(Log4jLevel.Trace)
4259
protected Map<String, String> contextMap = new HashMap<String, String>();
4360
private int wait; //in second
4461
private boolean bypassHostMaintenance = false;
62+
private transient long requestSequence = 0L;
4563

4664
protected Command() {
4765
this.wait = 0;
@@ -82,6 +100,10 @@ public String getContextParam(String name) {
82100
return contextMap.get(name);
83101
}
84102

103+
public Map<String, String> getContextMap() {
104+
return contextMap;
105+
}
106+
85107
public boolean allowCaching() {
86108
return true;
87109
}
@@ -94,6 +116,18 @@ public void setBypassHostMaintenance(boolean bypassHostMaintenance) {
94116
this.bypassHostMaintenance = bypassHostMaintenance;
95117
}
96118

119+
public boolean isReconcile() {
120+
return false;
121+
}
122+
123+
public long getRequestSequence() {
124+
return requestSequence;
125+
}
126+
127+
public void setRequestSequence(long requestSequence) {
128+
this.requestSequence = requestSequence;
129+
}
130+
97131
@Override
98132
public boolean equals(Object o) {
99133
if (this == o) return true;

api/src/main/java/com/cloud/agent/api/to/DiskTO.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class DiskTO {
4646
private Long diskSeq;
4747
private String path;
4848
private Volume.Type type;
49-
private Map<String, String> _details;
49+
private Map<String, String> details;
5050

5151
public DiskTO() {
5252

@@ -92,10 +92,10 @@ public void setType(Volume.Type type) {
9292
}
9393

9494
public void setDetails(Map<String, String> details) {
95-
_details = details;
95+
this.details = details;
9696
}
9797

9898
public Map<String, String> getDetails() {
99-
return _details;
99+
return details;
100100
}
101101
}

api/src/main/java/com/cloud/agent/api/to/NetworkTO.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class NetworkTO {
3636
protected TrafficType type;
3737
protected URI broadcastUri;
3838
protected URI isolationUri;
39-
protected boolean isSecurityGroupEnabled;
39+
protected boolean securityGroupEnabled;
4040
protected String name;
4141
protected String ip6address;
4242
protected String ip6gateway;
@@ -112,7 +112,7 @@ public String getName() {
112112
}
113113

114114
public void setSecurityGroupEnabled(boolean enabled) {
115-
this.isSecurityGroupEnabled = enabled;
115+
this.securityGroupEnabled = enabled;
116116
}
117117

118118
/**
@@ -221,7 +221,7 @@ public void setIsolationuri(URI isolationUri) {
221221
}
222222

223223
public boolean isSecurityGroupEnabled() {
224-
return this.isSecurityGroupEnabled;
224+
return this.securityGroupEnabled;
225225
}
226226

227227
public void setIp6Dns1(String ip6Dns1) {

api/src/main/java/com/cloud/agent/api/to/NicTO.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ public void setUuid(String uuid) {
8686
this.nicUuid = uuid;
8787
}
8888

89+
public String getNicUuid() {
90+
return nicUuid;
91+
}
92+
93+
public void setNicUuid(String nicUuid) {
94+
this.nicUuid = nicUuid;
95+
}
96+
8997
@Override
9098
public String toString() {
9199
return new StringBuilder("[Nic:").append(type).append("-").append(ip).append("-").append(broadcastUri).append("]").toString();

api/src/main/java/com/cloud/agent/api/to/VirtualMachineTO.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class VirtualMachineTO {
6161
@LogLevel(LogLevel.Log4jLevel.Off)
6262
String vncPassword;
6363
String vncAddr;
64-
Map<String, String> params;
64+
Map<String, String> details;
6565
String uuid;
6666
String bootType;
6767
String bootMode;
@@ -191,7 +191,11 @@ public Integer getMaxSpeed() {
191191
return maxSpeed;
192192
}
193193

194-
public boolean getLimitCpuUse() {
194+
public boolean isEnableHA() {
195+
return enableHA;
196+
}
197+
198+
public boolean isLimitCpuUse() {
195199
return limitCpuUse;
196200
}
197201

@@ -289,11 +293,11 @@ public void setVncAddr(String vncAddr) {
289293
}
290294

291295
public Map<String, String> getDetails() {
292-
return params;
296+
return details;
293297
}
294298

295299
public void setDetails(Map<String, String> params) {
296-
this.params = params;
300+
this.details = params;
297301
}
298302

299303
public String getUuid() {

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
@@ -490,12 +490,11 @@ public class ApiConstants {
490490
public static final String STATE = "state";
491491
public static final String STATS = "stats";
492492
public static final String STATUS = "status";
493+
public static final String STORAGE_TYPE = "storagetype";
494+
public static final String STORAGE_POLICY = "storagepolicy";
495+
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
493496
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
494497
public static final String STORAGE_CUSTOM_STATS = "storagecustomstats";
495-
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
496-
public static final String STORAGE_POLICY = "storagepolicy";
497-
public static final String STORAGE_POOL = "storagepool";
498-
public static final String STORAGE_TYPE = "storagetype";
499498
public static final String SUBNET = "subnet";
500499
public static final String OWNER = "owner";
501500
public static final String SWAP_OWNER = "swapowner";

0 commit comments

Comments
 (0)