Skip to content

Commit e2ab417

Browse files
[#70360] documentation: Described the support for execution of predefined actions
Signed-off-by: Mikolaj Klikowicz <mklikowicz@antmicro.com>
1 parent 2f45867 commit e2ab417

File tree

2 files changed

+74
-2
lines changed

2 files changed

+74
-2
lines changed

documentation/source/rdfm_linux_device_client.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Consider the following example:
132132
]
133133
```
134134

135-
:::{note} Since the file gives the capacity to run arbitrary binaries, its permissions should be set to `-rw-r--r--`.
135+
:::{note} Since the file gives the capacity to run arbitrary binaries, its permissions must be set to `-rw-r--r--`.
136136
:::
137137

138138
#### name `string`
@@ -151,6 +151,64 @@ A list of arguments for the given executable.
151151

152152
Number of milliseconds between each time a logger is ran. In the case of a logger taking more than `tick` to execute, it is killed and the client reports a timeout error.
153153

154+
### RDFM actions config
155+
156+
The JSON structured `/var/lib/rdfm/actions.conf` file contains a list of actions that can be executed on the device.
157+
Each action contains a command to execute and a timeout.
158+
Identifiers are used in `action_exec` messages sent from the server to select the action to execute.
159+
Name and description can be used for user-friendly display.
160+
Actions defined in the configuration can be queried using `action_list_query`.
161+
162+
Example configuration:
163+
```json
164+
[
165+
{
166+
"Id": "echo",
167+
"Name": "Echo",
168+
"Command": ["echo", "Executing echo action"],
169+
"Description": "Description of echo action",
170+
"Timeout": 1.0
171+
},
172+
{
173+
"Id": "sleepTwoSeconds",
174+
"Name": "Sleep 2",
175+
"Command": ["sleep", "2"],
176+
"Description": "Description of sleep 2 seconds action",
177+
"Timeout": 3.0
178+
},
179+
{
180+
"Id": "sleepFiveSeconds",
181+
"Name": "Sleep 5",
182+
"Command": ["sleep", "5"],
183+
"Description": "This action will timeout",
184+
"Timeout": 3.0
185+
}
186+
]
187+
```
188+
189+
:::{note} Since the file gives the capacity to run arbitrary binaries, its permissions must be set to `-rw-r--r--`.
190+
:::
191+
192+
#### Id `string`
193+
194+
Identifier used in execution requests, must be unique.
195+
196+
#### Name `string`
197+
198+
Human readable name, should be unique.
199+
200+
#### Command `[]string`
201+
202+
Command to execute, the first elements is an executable, others are arguments.
203+
204+
#### Description `string`
205+
206+
Human readable action description.
207+
208+
#### Timeout `float`
209+
210+
Maximum duration of command execution in seconds, command is killed if it doesn't finish in the time provided.
211+
154212
## Testing server-device integration with a demo Linux device client
155213

156214
For development purposes, it's often necessary to test server integration with an existing device client.

documentation/source/server_operation.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,24 @@ By default it is assumed that the device does not provide any capabilities.
102102

103103
This capability indicates that a device supports spawning a reverse shell.
104104
The following methods must be supported by the device:
105-
- `shell_attach`
105+
106+
##### Method - `shell_attach`
106107

107108
A device with the `shell` capability should react to `shell_attach` messages by connecting to a shell WebSocket at `/api/v1/devices/<shell_attach.mac_addr>/shell/attach/<shell_attach.uuid>`.
108109
This establishes a connection between the requesting manager and the device.
109110
This WebSocket can then be used to stream the contents of the shell session and receive user input.
110111
The format of messages sent over this endpoint is implementation defined.
111112
However, generally the shell output/input are simply sent as binary WebSocket messages containing the standard output/input as raw bytes.
113+
114+
#### Capability - `action`
115+
116+
This capability indicates that a device supports execution of predefined actions.
117+
The following methods must be supported by the device:
118+
119+
##### Method - `action_list_query`
120+
121+
Return a list of actions supported by the device.
122+
123+
##### Method - `action_exec`
124+
125+
Attempt to queue action execution and immediately respond with the `action_exec_control` message indicating success or failure. Action execution result is sent later via `action_exec_result` message.

0 commit comments

Comments
 (0)