Skip to content

Commit

Permalink
add reboot to admin access
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdaGastan authored and Eslam-Nawara committed Dec 22, 2024
1 parent 0f5fe58 commit 2ee7e4a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/manual/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ it means it can act like an access node to user private networks

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

### Reboot

| command |body| return|
|---|---|---|
| `zos.admin.reboot` | - | - |

Stops all services then reboot the node

### List Physical Interfaces

| command |body| return|
Expand Down
8 changes: 8 additions & 0 deletions pkg/zos_api/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ import (
"context"
"encoding/json"
"fmt"

"github.com/threefoldtech/zos/pkg/zinit"
)

func (g *ZosAPI) adminRebootHandler(ctx context.Context, payload []byte) (interface{}, error) {
zinit := zinit.Default()

return nil, zinit.Reboot()
}

func (g *ZosAPI) adminInterfacesHandler(ctx context.Context, payload []byte) (interface{}, error) {
// list all interfaces on node
type Interface struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/zos_api/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (g *ZosAPI) SetupRoutes(router *peer.Router) {

admin := root.SubRoute("admin")
admin.Use(g.authorized)
admin.WithHandler("reboot", g.adminRebootHandler)
admin.WithHandler("interfaces", g.adminInterfacesHandler)
admin.WithHandler("set_public_nic", g.adminSetPublicNICHandler)
admin.WithHandler("get_public_nic", g.adminGetPublicNICHandler)
Expand Down

0 comments on commit 2ee7e4a

Please sign in to comment.