-
Notifications
You must be signed in to change notification settings - Fork 6
/
post_node_action_unfreeze.go
39 lines (34 loc) · 1.22 KB
/
post_node_action_unfreeze.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
37
38
39
package daemonapi
import (
"net/http"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"github.com/opensvc/om3/core/client"
"github.com/opensvc/om3/core/naming"
"github.com/opensvc/om3/daemon/api"
"github.com/opensvc/om3/daemon/rbac"
)
func (a *DaemonAPI) PostPeerActionUnfreeze(ctx echo.Context, nodename string, params api.PostPeerActionUnfreezeParams) error {
if nodename == a.localhost {
return a.localNodeActionUnfreeze(ctx, params)
}
return a.proxy(ctx, nodename, func(c *client.T) (*http.Response, error) {
return c.PostPeerActionUnfreeze(ctx.Request().Context(), nodename, ¶ms)
})
}
func (a *DaemonAPI) localNodeActionUnfreeze(ctx echo.Context, params api.PostPeerActionUnfreezeParams) error {
if v, err := assertGrant(ctx, rbac.GrantRoot); !v {
return err
}
log := LogHandler(ctx, "PostPeerActionUnfreeze")
var requesterSid uuid.UUID
args := []string{"node", "unfreeze", "--local"}
if params.RequesterSid != nil {
requesterSid = *params.RequesterSid
}
if sid, err := a.apiExec(ctx, naming.Path{}, requesterSid, args, log); err != nil {
return JSONProblemf(ctx, http.StatusInternalServerError, "", "%s", err)
} else {
return ctx.JSON(http.StatusOK, api.NodeActionAccepted{SessionID: sid})
}
}