Skip to content

Commit cfb6140

Browse files
committed
add reboot to admin access
1 parent 41fe8f7 commit cfb6140

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

docs/manual/api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ it means it can act like an access node to user private networks
153153

154154
The next set of commands are ONLY possible to be called by the `farmer` only.
155155

156+
### Reboot
157+
158+
| command |body| return|
159+
|---|---|---|
160+
| `zos.admin.reboot` | - | - |
161+
162+
Stops all services then reboot the node
163+
156164
### List Physical Interfaces
157165

158166
| command |body| return|

pkg/zos_api/admin.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
8+
"github.com/threefoldtech/zos/pkg/zinit"
79
)
810

11+
func (g *ZosAPI) adminRebootHandler(ctx context.Context, payload []byte) (interface{}, error) {
12+
zinit := zinit.Default()
13+
14+
return nil, zinit.Reboot()
15+
}
16+
917
func (g *ZosAPI) adminInterfacesHandler(ctx context.Context, payload []byte) (interface{}, error) {
1018
// list all interfaces on node
1119
type Interface struct {

pkg/zos_api/routes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func (g *ZosAPI) SetupRoutes(router *peer.Router) {
4545

4646
admin := root.SubRoute("admin")
4747
admin.Use(g.authorized)
48+
admin.WithHandler("reboot", g.adminRebootHandler)
4849
admin.WithHandler("interfaces", g.adminInterfacesHandler)
4950
admin.WithHandler("set_public_nic", g.adminSetPublicNICHandler)
5051
admin.WithHandler("get_public_nic", g.adminGetPublicNICHandler)

0 commit comments

Comments
 (0)