fix: host 内存规格信息直接为 MB (#281)

This commit is contained in:
Zexi Li
2019-04-08 22:27:34 +08:00
committed by yunion-ci-robot
parent 2393df6bda
commit a7a672bf6c
2 changed files with 4 additions and 12 deletions
+3 -3
View File
@@ -71,7 +71,7 @@ func init() {
options.BaseListOptions
HostType string `help:"Host type filter" choices:"baremetal|hypervisor|esxi|kubelet|hyperv"`
Ncpu int64 `help:"#CPU count of host" metavar:"<CPU_COUNT>"`
MemSize string `help:"Memory GB size"`
MemSize int64 `help:"Memory MB size"`
DiskSpec []string `help:"Disk spec string, like 'Linux_adapter0_HDD_111Gx4'"`
Nic int64 `help:"#Nics count of host" metavar:"<NIC_COUNT>"`
GpuModel []string `help:"GPU model, like 'GeForce GTX 1050 Ti'"`
@@ -83,8 +83,8 @@ func init() {
if args.Ncpu > 0 {
keys = append(keys, fmt.Sprintf("cpu:%d", args.Ncpu))
}
if len(args.MemSize) != 0 {
keys = append(keys, fmt.Sprintf("mem:%s", args.MemSize))
if args.MemSize > 0 {
keys = append(keys, fmt.Sprintf("mem:%dM", args.MemSize))
}
if args.Nic > 0 {
keys = append(keys, fmt.Sprintf("nic:%d", args.Nic))
+1 -9
View File
@@ -921,15 +921,7 @@ func (manager *SHostManager) GetSpecIdent(spec *jsonutils.JSONDict) []string {
nCpu, _ := spec.Int("cpu")
memSize, _ := spec.Int("mem")
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)
}
memSizeStr = fmt.Sprintf("mem:%dM", memSize)
nicCount, _ := spec.Int("nic_count")
manufacture, _ := spec.GetString("manufacture")
model, _ := spec.GetString("model")