Power
Reboot or shut down the host. osapi dsl behavior get --name power and
osapi dsl behavior method get show the same.
Behavior
| Name | power |
| Description | Reboot or shut down the host |
| Placement | node |
| Area | node |
| Internal | no |
| API | yes |
| CLI | yes |
| Next | no |
| Platforms | debian |
| Sudo | none |
| Runs | none |
| Writes | none |
| Keeps state | no |
| Uses | none |
| Used by | none |
Methods (2)
| NAME | VERB | HTTP | ROUTE | PERMISSION | DESCRIPTION |
|---|---|---|---|---|---|
| reboot | write | POST | /api/node/{hostname}/power/reboot | power:write | Reboot the host |
| shutdown | write | POST | /api/node/{hostname}/power/shutdown | power:write | Shut the host down |
Types (2)
| NAME | INPUT | OUTPUT |
|---|---|---|
| reboot | Input { delay, message } | Result { action, delay, changed } |
| shutdown | Input { delay, message } | Result { action, delay, changed } |
Settings (0)
None. Declare them with behavior.Config.
Telemetry
| Span | behavior.power.<method> |
| Child spans | exec shutdown |
| Metrics | osapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total |
| Attributes | osapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed |
| Recorded inputs | delay (reboot, shutdown) |
Method reboot
| Name | reboot |
| Verb | write |
| Description | Reboot the host |
| Detail | Runs shutdown -r -- +N, with N the delay in whole minutes and at least one, so the agent can answer before the host goes down. A message goes to the logged-in users. Each run changes the host. |
| HTTP | POST |
| Route | /api/node/{hostname}/power/reboot |
| Permission | power:execute |
| Command | osapi client node power reboot |
| Input type | Input |
| Output type | Result |
Input (2)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| delay | integer | no | min 0 | Seconds before the host goes down. It rounds to whole minutes, at least one. |
| message | string | no | A message to the logged-in users first. |
Output (3)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| action | string | reboot or shutdown |
| delay | integer | Seconds before the host goes down. |
| changed | boolean | Always true: each run changes the host. |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| In one minute | (none) | action=reboot, delay=60, changed=true |
| In five minutes, with a message | delay=300, message=maintenance | action=reboot, delay=300, changed=true |
Method shutdown
| Name | shutdown |
| Verb | write |
| Description | Shut the host down |
| Detail | Runs shutdown -h -- +N, with N the delay in whole minutes and at least one, so the agent can answer before the host goes down. A message goes to the logged-in users. Each run changes the host. |
| HTTP | POST |
| Route | /api/node/{hostname}/power/shutdown |
| Permission | power:execute |
| Command | osapi client node power shutdown |
| Input type | Input |
| Output type | Result |
Input (2)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| delay | integer | no | min 0 | Seconds before the host goes down. It rounds to whole minutes, at least one. |
| message | string | no | A message to the logged-in users first. |
Output (3)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| action | string | reboot or shutdown |
| delay | integer | Seconds before the host goes down. |
| changed | boolean | Always true: each run changes the host. |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| In one minute | (none) | action=shutdown, delay=60, changed=true |
| In five minutes, with a message | delay=300, message=maintenance | action=shutdown, delay=300, changed=true |