From 9734c5187ca43d5347ee23b3be5fa691e9acf88f Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:54:40 +0800 Subject: [PATCH] fix(region): host list add hide cpu topo info option (#21946) --- pkg/compute/models/hosts.go | 11 +++++++++++ pkg/mcclient/options/compute/host.go | 2 ++ 2 files changed, 13 insertions(+) diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index d4f369865a..b6a89d66b6 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -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 } diff --git a/pkg/mcclient/options/compute/host.go b/pkg/mcclient/options/compute/host.go index 2efc96ca4a..a11e6c6844 100644 --- a/pkg/mcclient/options/compute/host.go +++ b/pkg/mcclient/options/compute/host.go @@ -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 }