backend update
This commit is contained in:
2
assets
2
assets
Submodule assets updated: 64e7385a24...f1c5f86553
@@ -90,6 +90,15 @@ type GetStoragePolicyResponse struct {
|
|||||||
EntitiesSize int `json:"entities_size,omitempty"`
|
EntitiesSize int `json:"entities_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StoragePolicySpace 存储策略空间使用情况
|
||||||
|
type StoragePolicySpace struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Used int64 `json:"used"`
|
||||||
|
Total int64 `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
type ListNodeResponse struct {
|
type ListNodeResponse struct {
|
||||||
Pagination *inventory.PaginationResults `json:"pagination"`
|
Pagination *inventory.PaginationResults `json:"pagination"`
|
||||||
Nodes []*ent.Node `json:"nodes"`
|
Nodes []*ent.Node `json:"nodes"`
|
||||||
@@ -115,9 +124,10 @@ type ListGroupResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HomepageSummary struct {
|
type HomepageSummary struct {
|
||||||
MetricsSummary *MetricsSummary `json:"metrics_summary"`
|
MetricsSummary *MetricsSummary `json:"metrics_summary"`
|
||||||
SiteURls []string `json:"site_urls"`
|
SiteURls []string `json:"site_urls"`
|
||||||
Version *Version `json:"version"`
|
Version *Version `json:"version"`
|
||||||
|
StoragePolicies []*StoragePolicySpace `json:"storage_policies"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MetricsSummary struct {
|
type MetricsSummary struct {
|
||||||
|
|||||||
@@ -161,6 +161,33 @@ func (s *SummaryService) Summary(c *gin.Context) (*HomepageSummary, error) {
|
|||||||
_ = kv.Set(MetricCacheKey, *summary, 86400)
|
_ = kv.Set(MetricCacheKey, *summary, 86400)
|
||||||
res.MetricsSummary = summary
|
res.MetricsSummary = summary
|
||||||
|
|
||||||
|
// 获取存储策略空间使用数据
|
||||||
|
policyClient := dep.StoragePolicyClient()
|
||||||
|
policyResult, err := policyClient.ListPolicies(c, &inventory.ListPolicyParameters{
|
||||||
|
PaginationArgs: &inventory.PaginationArgs{PageSize: 1000, Page: 0}, // 获取所有策略
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
// 收集存储策略空间使用情况
|
||||||
|
res.StoragePolicies = make([]*StoragePolicySpace, 0, len(policyResult.Policies))
|
||||||
|
entityClient := dep.FileClient()
|
||||||
|
|
||||||
|
for _, policy := range policyResult.Policies {
|
||||||
|
// 获取该存储策略的已使用空间
|
||||||
|
_, usedSpace, err := entityClient.CountEntityByStoragePolicyID(c, policy.ID)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
res.StoragePolicies = append(res.StoragePolicies, &StoragePolicySpace{
|
||||||
|
ID: int64(policy.ID),
|
||||||
|
Name: policy.Name,
|
||||||
|
Type: policy.Type,
|
||||||
|
Used: int64(usedSpace),
|
||||||
|
Total: policy.MaxSize, // 使用策略的最大空间限制
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user