From efd3d565758de352c4e2965ab06b8bb9b0d762e9 Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Sat, 15 Dec 2018 17:21:00 +0800 Subject: [PATCH] =?UTF-8?q?region:=20=E5=A6=82=E6=9E=9C=20memsize=20<=2010?= =?UTF-8?q?24=20=E6=8C=89MB=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/hosts.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index 2b75e0f103..4d4ce2bf1e 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -820,9 +820,15 @@ func (self *SHost) GetSpec(statusCheck bool) *jsonutils.JSONDict { func (manager *SHostManager) GetSpecIdent(spec *jsonutils.JSONDict) []string { nCpu, _ := spec.Int("cpu") memSize, _ := spec.Int("mem") - memGB, err := utils.GetSizeGB(fmt.Sprintf("%d", memSize), "M") - if err != nil { - log.Errorf("Get mem size %d GB error: %v", memSize, err) + var memSizeStr string + if memSize < 1024 { + memSizeStr = fmt.Sprintf("mem:%dM", memSize) + } else { + memGB, err := utils.GetSizeGB(fmt.Sprintf("%d", memSize), "M") + if err != nil { + log.Errorf("Get mem size %d GB error: %v", memSize, err) + } + memSizeStr = fmt.Sprintf("mem:%dG", memGB) } nicCount, _ := spec.Int("nic_count") manufacture, _ := spec.GetString("manufacture") @@ -830,7 +836,7 @@ func (manager *SHostManager) GetSpecIdent(spec *jsonutils.JSONDict) []string { specKeys := []string{ fmt.Sprintf("cpu:%d", nCpu), - fmt.Sprintf("mem:%dG", memGB), + memSizeStr, fmt.Sprintf("nic:%d", nicCount), fmt.Sprintf("manufacture:%s", manufacture), fmt.Sprintf("model:%s", model),