Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions plugin/kvm/src/main/java/org/zstack/kvm/KVMAgentCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,8 @@ public static class HostFactResponse extends AgentResponse {
private List<String> libvirtCapabilities;
@GrayVersion(value = "5.0.0")
private VirtualizerInfoTO virtualizerInfo;
@GrayVersion("5.5.6")
private String cpuFeatureMd5;
private String iscsiInitiatorName;

public String getOsDistribution() {
Expand Down Expand Up @@ -799,6 +801,14 @@ public String getDeployMode() {
public void setDeployMode(String deployMode) {
this.deployMode = deployMode;
}

public String getCpuFeatureMd5() {
return cpuFeatureMd5;
}

public void setCpuFeatureMd5(String cpuFeatureMd5) {
this.cpuFeatureMd5 = cpuFeatureMd5;
}
}

public static class HostCapacityCmd extends AgentCommand {
Expand Down
19 changes: 19 additions & 0 deletions plugin/kvm/src/main/java/org/zstack/kvm/KVMHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -6246,10 +6246,29 @@ private void saveKvmHostRelatedFacts(HostFactResponse ret) {
}

deleteCpuHistoryVOIfCpuModeNameChange(ret.getCpuModelName());
deleteCpuHistoryVOIfCpuFeatureMd5Change(ret.getCpuFeatureMd5());
}
};
}

private void deleteCpuHistoryVOIfCpuFeatureMd5Change(String newMd5) {
if (newMd5 == null) {
return;
}

String oldMd5 = KVMSystemTags.CPU_FEATURE_MD5.getTokenByResourceUuid(self.getUuid(), KVMSystemTags.CPU_FEATURE_MD5_TOKEN);

if (oldMd5 == null || !oldMd5.equals(newMd5)) {
SQL.New(CpuFeaturesHistoryVO.class).eq(CpuFeaturesHistoryVO_.srcHostUuid, self.getUuid()).delete();
SQL.New(CpuFeaturesHistoryVO.class).eq(CpuFeaturesHistoryVO_.dstHostUuid, self.getUuid()).delete();

logger.debug(String.format("host[uuid:%s] CPU feature %s, old MD5: %s, new MD5: %s, deleted related CpuFeaturesHistoryVO records",
self.getUuid(), oldMd5 == null ? "first recorded" : "changed", oldMd5, newMd5));
}

createTagWithoutNonValue(KVMSystemTags.CPU_FEATURE_MD5, KVMSystemTags.CPU_FEATURE_MD5_TOKEN, newMd5, true);
}

private void deleteCpuHistoryVOIfCpuModeNameChange(String cpuModelName){
// delete all records that do not match the cpuModelName of the source physical machine
SQL.New(CpuFeaturesHistoryVO.class)
Expand Down
3 changes: 3 additions & 0 deletions plugin/kvm/src/main/java/org/zstack/kvm/KVMSystemTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class KVMSystemTags {
public static final String CPU_MODEL_NAME_TOKEN = "name";
public static PatternedSystemTag CPU_MODEL_NAME = new PatternedSystemTag(String.format("cpuModelName::{%s}", CPU_MODEL_NAME_TOKEN), HostVO.class);

public static final String CPU_FEATURE_MD5_TOKEN = "cpuFeatureMd5";
public static PatternedSystemTag CPU_FEATURE_MD5 = new PatternedSystemTag(String.format("cpuFeatureMd5::{%s}", CPU_FEATURE_MD5_TOKEN), HostVO.class);

public static final String CHECK_CLUSTER_CPU_MODEL_TOKEN = "enable";
public static PatternedSystemTag CHECK_CLUSTER_CPU_MODEL = new PatternedSystemTag(String.format("check::cluster::cpu::model::{%s}", CHECK_CLUSTER_CPU_MODEL_TOKEN), ClusterVO.class);

Expand Down