mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-31 02:38:07 +08:00
Merge pull request #11377 from ioito/automated-cherry-pick-of-#11375-upstream-release-3.7
Automated cherry pick of #11375: fix(host): update rbd storage capacity
This commit is contained in:
@@ -347,7 +347,7 @@ func StartSyncStorageSizeTask(interval time.Duration) {
|
||||
manager := GetManager()
|
||||
for i := 0; i < len(manager.Storages); i++ {
|
||||
iS := manager.Storages[i]
|
||||
if iS.StorageType() == api.STORAGE_LOCAL {
|
||||
if iS.StorageType() == api.STORAGE_LOCAL || iS.StorageType() == api.STORAGE_RBD {
|
||||
err := iS.SyncStorageSize()
|
||||
if err != nil {
|
||||
log.Errorf("sync storage %s size failed: %s", iS.GetStorageName(), err)
|
||||
|
||||
@@ -606,6 +606,20 @@ func (s *SRbdStorage) getCapacity() (*sCephCapacity, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (s *SRbdStorage) SyncStorageSize() error {
|
||||
content := jsonutils.NewDict()
|
||||
capacity, err := s.getCapacity()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "getCapacity")
|
||||
}
|
||||
content.Set("capacity", jsonutils.NewInt(int64(capacity.CapacitySizeByte/1024/1024)))
|
||||
content.Set("actual_capacity_used", jsonutils.NewInt(int64(capacity.UsedCapacitySizeByte/1024/1024)))
|
||||
_, err = modules.Storages.Put(
|
||||
hostutils.GetComputeSession(context.Background()),
|
||||
s.StorageId, content)
|
||||
return errors.Wrapf(err, "storage update")
|
||||
}
|
||||
|
||||
func (s *SRbdStorage) SyncStorageInfo() (jsonutils.JSONObject, error) {
|
||||
content := map[string]interface{}{}
|
||||
if len(s.StorageId) > 0 {
|
||||
|
||||
Reference in New Issue
Block a user