diff --git a/pkg/hostman/storageman/core.go b/pkg/hostman/storageman/core.go index 13ba2bb027..8282ce34c9 100644 --- a/pkg/hostman/storageman/core.go +++ b/pkg/hostman/storageman/core.go @@ -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) diff --git a/pkg/hostman/storageman/storage_rbd.go b/pkg/hostman/storageman/storage_rbd.go index b41aacafa2..48bcc07948 100644 --- a/pkg/hostman/storageman/storage_rbd.go +++ b/pkg/hostman/storageman/storage_rbd.go @@ -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 {