-
Notifications
You must be signed in to change notification settings - Fork 6
/
get_pool.go
36 lines (32 loc) · 895 Bytes
/
get_pool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package daemonapi
import (
"net/http"
"github.com/labstack/echo/v4"
"github.com/opensvc/om3/core/pool"
"github.com/opensvc/om3/daemon/api"
)
func (a *DaemonAPI) GetPools(ctx echo.Context, params api.GetPoolsParams) error {
var items api.PoolItems
for _, e := range pool.StatusData.GetAll() {
if params.Name != nil && *params.Name != e.Name {
continue
}
stat := *e.Value
item := api.Pool{
Capabilities: append([]string{}, stat.Capabilities...),
Free: stat.Free,
Head: stat.Head,
Name: stat.Name,
Size: stat.Size,
Type: stat.Type,
Used: stat.Used,
VolumeCount: len(getPoolVolumes(&e.Name)),
}
if len(stat.Errors) > 0 {
l := append([]string{}, stat.Errors...)
item.Errors = &l
}
items = append(items, item)
}
return ctx.JSON(http.StatusOK, api.PoolList{Kind: "PoolList", Items: items})
}