fix(region): host list add hide cpu topo info option (#21946)

This commit is contained in:
wanyaoqi
2025-01-13 13:54:40 +08:00
committed by GitHub
parent 3d1befff66
commit 9734c5187c
2 changed files with 13 additions and 0 deletions
+11
View File
@@ -3598,6 +3598,7 @@ func (manager *SHostManager) FetchCustomizeColumns(
if query.Contains("show_fail_reason") {
showReason = true
}
var hideCpuTypoInfo = jsonutils.QueryBoolean(query, "hide_cpu_topo_info", false)
hostIds := make([]string, len(objs))
hosts := make([]*SHost, len(objs))
for i := range rows {
@@ -3762,6 +3763,16 @@ func (manager *SHostManager) FetchCustomizeColumns(
rows[i].Schedtags, _ = schedtags[hostIds[i]]
rows[i].NicInfo, _ = nics[hostIds[i]]
rows[i].NicCount = len(rows[i].NicInfo)
if hideCpuTypoInfo {
sysInfo, ok := hosts[i].SysInfo.(*jsonutils.JSONDict)
if ok {
sysInfo.Remove("cpu_info")
sysInfo.Remove("topology")
}
delete(rows[i].Metadata, "cpu_info")
delete(rows[i].Metadata, "topology")
}
}
return rows
}
+2
View File
@@ -64,6 +64,8 @@ type HostListOptions struct {
OrderByCpuCommit string `help:"Order by cpu commit" choices:"desc|asc"`
OrderByMemCommit string `help:"Order by mem commit" choices:"desc|asc"`
HideCpuTopoInfo *bool `help:"Host list will remove cpu_info and topology info from sysinfo and metadata"`
options.BaseListOptions
}