diff --git a/client/node.go b/client/node.go index 5b42e1467..949aa3692 100644 --- a/client/node.go +++ b/client/node.go @@ -280,7 +280,7 @@ func (n *NodeClient) AdminRestartAll(ctx context.Context) error { return n.bus.Call(ctx, n.nodeTwin, cmd, nil, nil) } -// AdminShowLogs returns a l lines of zinit logs +// AdminShowLogs returns l lines of zinit logs func (n *NodeClient) AdminShowLogs(ctx context.Context, l int) (logs []byte, err error) { const cmd = "zos.admin.show_logs" diff --git a/docs/manual/api.md b/docs/manual/api.md index 9a9c5ef15..6baf7cc22 100644 --- a/docs/manual/api.md +++ b/docs/manual/api.md @@ -84,7 +84,8 @@ so `used = user_used + system`, while `system` is only the amount of resourced r | `zos.storage.pools` | - |`[]Pool`| List all node pools with their types, size and used space -where + +Where ```json Pool { @@ -151,7 +152,7 @@ it means it can act like an access node to user private networks ## Admin -The next set of commands are ONLY possible to be called by the `farmer` only. +The next set of commands are ONLY possible to be called by the `farmer` owning the node. ### Reboot Node @@ -159,21 +160,87 @@ The next set of commands are ONLY possible to be called by the `farmer` only. |---|---|---| | `zos.admin.reboot` | - | - | -Stops all services then reboot the node +Stops all services then reboots the node ### Restart Service | command |body| return| |---|---|---| -| `zos.admin.reboot` | string | - | +| `zos.admin.restart` | string | - | Restarts a service running on the node +### Restart All Services + +| command |body| return| +|---|---|---| +| `zos.admin.restart_all` | - | - | + +Restarts all zinit services running on the node + +### Show Logs + +| command |body| return| +|---|---|---| +| `zos.admin.show_logs` | int | []byte | + +Shows a number of lines of zinit logs + +### Show Resolve + +| command |body| return| +|---|---|---| +| `zos.admin.show_resolve` | - | []byte | + +Shows the content of /etc/resolv.conf + +### Show Open Connections + +| command |body| return| +|---|---|---| +| `zos.admin.show_open_connections` | - | []byte | + +Shows information about all open connections in the node + +### Stop Workload + +| command |body| return| +|---|---|---| +| `zos.admin.Stop` | `Args` | - | + +Where + +```json +Args { + "twin_id": "uint32", + "workload_id": "uint64", +} +``` + +Stops a workload + +### Resume Workload + +| command |body| return| +|---|---|---| +| `zos.admin.resume` | `Args` | - | + +Where + +```json +Args { + "twin_id": "uint32", + "workload_id": "uint64", +} +``` + +Resumes a stopped workload + ### List Physical Interfaces | command |body| return| |---|---|---| -| `zos.network.admin.interfaces` | - |`map[string]Interface` | +| `zos.admin.interfaces` | - |`map[string]Interface` | Where @@ -191,7 +258,7 @@ Those interfaces then can be used as an input to `set_public_nic` | command |body| return| |---|---|---| -| `zos.network.admin.get_public_nic` | - |`ExitDevice` | +| `zos.admin.get_public_nic` | - |`ExitDevice` | Where @@ -209,7 +276,7 @@ returns the interface used by public traffic (for user workloads) | command |body| return| |---|---|---| -| `zos.network.admin.set_public_nic` | `name` |- | +| `zos.admin.set_public_nic` | `name` |- | name must be one of (free) names returned by `zos.network.admin.interfaces` @@ -239,7 +306,6 @@ name must be one of (free) names returned by `zos.network.admin.interfaces` |---|---|---| | `zos.system.node_features_get` | - |`[]NodeFeature` | - Where ```json diff --git a/pkg/primitives/statistics.go b/pkg/primitives/statistics.go index dfd089ca5..441d9c2cd 100644 --- a/pkg/primitives/statistics.go +++ b/pkg/primitives/statistics.go @@ -236,9 +236,7 @@ func (s *statsStream) Total() gridtypes.Capacity { } func (s *statsStream) OpenConnections() ([]byte, error) { - args := []string{"-ptn", "state", "established"} - cmd := exec.Command("ss", args...) - return cmd.Output() + return exec.Command("ss", "-ptn", "state", "established").Output() } func (s *statsStream) openConnectionsCount() (int, error) { diff --git a/pkg/provision.go b/pkg/provision.go index 55838f900..6fae7d98d 100644 --- a/pkg/provision.go +++ b/pkg/provision.go @@ -32,7 +32,6 @@ type Statistics interface { GetCounters() (Counters, error) ListGPUs() ([]GPUInfo, error) OpenConnections() ([]byte, error) - // Pause(id gridtypes.WorkloadID) error } type Counters struct { diff --git a/pkg/zinit/commands.go b/pkg/zinit/commands.go index c62e29748..e857b2bc1 100644 --- a/pkg/zinit/commands.go +++ b/pkg/zinit/commands.go @@ -207,7 +207,7 @@ func (c *Client) List() (out map[string]ServiceState, err error) { } // List returns all the service monitored and their status -func (c *Client) Log(n int) (out string, err error) { +func (c *Client) Log(n int) (out []byte, err error) { cmd1 := exec.Command("zinit", "log", "-s") cmd2 := exec.Command("tail", "-n", fmt.Sprint(n)) @@ -231,7 +231,7 @@ func (c *Client) Log(n int) (out string, err error) { return } - return string(output), err + return output, err } // Status returns the status of a service