mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
宿主机存储利用率仅计算本地存储
This commit is contained in:
@@ -102,6 +102,8 @@ var (
|
||||
STORAGE_ZSTACK_LOCAL_STORAGE, STORAGE_ZSTACK_CEPH, STORAGE_GPFS,
|
||||
}
|
||||
|
||||
HOST_STORAGE_LOCAL_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL}
|
||||
|
||||
STORAGE_LIMITED_TYPES = []string{STORAGE_LOCAL, STORAGE_BAREMETAL, STORAGE_NAS, STORAGE_RBD, STORAGE_NFS, STORAGE_GPFS}
|
||||
|
||||
SHARED_FILE_STORAGE = []string{STORAGE_NFS, STORAGE_GPFS}
|
||||
|
||||
@@ -1069,10 +1069,13 @@ func (cap *SStorageCapacity) ToJson() *jsonutils.JSONDict {
|
||||
return ret
|
||||
}
|
||||
|
||||
func (self *SHost) GetAttachedStorageCapacity() SStorageCapacity {
|
||||
func (self *SHost) GetAttachedLocalStorageCapacity() SStorageCapacity {
|
||||
ret := SStorageCapacity{}
|
||||
storages := self.GetAttachedStorages("")
|
||||
for _, s := range storages {
|
||||
if !utils.IsInStringArray(s.StorageType, api.HOST_STORAGE_LOCAL_TYPES) {
|
||||
continue
|
||||
}
|
||||
ret.Add(s.getStorageCapacity())
|
||||
}
|
||||
return ret
|
||||
@@ -2350,7 +2353,7 @@ func (self *SHost) getMoreDetails(ctx context.Context, extra *jsonutils.JSONDict
|
||||
memCommitRate = float64(usage.GuestVmemSize) * 1.0 / float64(totalMem)
|
||||
}
|
||||
extra.Add(jsonutils.NewFloat(memCommitRate), "mem_commit_rate")
|
||||
capa := self.GetAttachedStorageCapacity()
|
||||
capa := self.GetAttachedLocalStorageCapacity()
|
||||
extra.Add(jsonutils.NewInt(int64(capa.Capacity)), "storage")
|
||||
extra.Add(jsonutils.NewInt(int64(capa.Used)), "storage_used")
|
||||
extra.Add(jsonutils.NewInt(int64(capa.Wasted)), "storage_waste")
|
||||
@@ -3067,7 +3070,7 @@ func (self *SHost) PerformInitialize(
|
||||
guest.SetAllMetadata(ctx, map[string]interface{}{
|
||||
"is_fake_baremetal_server": true, "host_ip": self.AccessIp}, userCred)
|
||||
|
||||
caps := self.GetAttachedStorageCapacity()
|
||||
caps := self.GetAttachedLocalStorageCapacity()
|
||||
diskConfig := &api.DiskConfig{SizeMb: int(caps.GetFree())}
|
||||
err = guest.CreateDisksOnHost(ctx, userCred, self, []*api.DiskConfig{diskConfig}, nil, true, true, nil, nil, true)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user