From 58a7a7a6f97ad146f5a870e764590b1fa9101fe0 Mon Sep 17 00:00:00 2001 From: ioito Date: Wed, 15 May 2019 17:04:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8C=E6=AD=A5=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=87=86=E7=A1=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/util/openstack/host.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/util/openstack/host.go b/pkg/util/openstack/host.go index 339c54121d..7d4231c8af 100644 --- a/pkg/util/openstack/host.go +++ b/pkg/util/openstack/host.go @@ -302,6 +302,18 @@ func (host *SHost) GetCpuCount() int8 { } func (host *SHost) GetNodeCount() int8 { + if len(host.CpuInfo) > 0 { + info, err := jsonutils.Parse([]byte(host.CpuInfo)) + if err == nil { + cpuInfo := &CpuInfo{} + err = info.Unmarshal(cpuInfo) + if err == nil { + if cell, ok := cpuInfo.Topology["cells"]; ok { + return int8(cell) + } + } + } + } return host.GetCpuCount() }