manta_shared/types/api/boot_parameters.rs
1//! HTTP request/response bodies and CLI-built parameter structs for
2//! the boot-parameter endpoints (`/api/v1/boot-config` and
3//! `/api/v1/boot-parameters`).
4
5use serde::{Deserialize, Serialize};
6use utoipa::ToSchema;
7
8/// Request body for `POST /api/v1/boot-config`.
9///
10/// Applies a combined boot configuration (image + runtime config +
11/// kernel parameters) to the nodes named by `hosts_expression`. The
12/// field is a hosts expression — xnames, NIDs, or hostlist notation;
13/// HSM group names are not accepted here (resolve them client-side
14/// first if needed).
15///
16/// At least one of `boot_image_id`, `boot_image_configuration`,
17/// `kernel_parameters`, or `runtime_configuration` should be set;
18/// `null` fields are left unchanged on the targeted nodes.
19///
20/// # Wire shape
21///
22/// ```json
23/// {
24/// "hosts_expression": "x3000c0s1b0n[0-3]",
25/// "boot_image_id": "0a1b2c3d-...",
26/// "boot_image_configuration": null,
27/// "kernel_parameters": "console=ttyS0 nosmt",
28/// "runtime_configuration": "cos-2.5",
29/// "dry_run": false
30/// }
31/// ```
32#[derive(Debug, Serialize, Deserialize, ToSchema)]
33pub struct ApplyBootConfigRequest {
34 /// Hosts expression (xnames, NIDs, or hostlist notation) naming
35 /// the target nodes.
36 pub hosts_expression: String,
37 /// IMS image ID to set as the boot image. Mutually exclusive with
38 /// `boot_image_configuration`: set one or the other, not both.
39 pub boot_image_id: Option<String>,
40 /// CFS configuration name associated with the boot image; the
41 /// server resolves the most recent image built against this
42 /// configuration when `boot_image_id` is absent.
43 pub boot_image_configuration: Option<String>,
44 /// Kernel command-line parameters to apply.
45 pub kernel_parameters: Option<String>,
46 /// CFS configuration to assign as the runtime desired-config.
47 pub runtime_configuration: Option<String>,
48 /// When true, return the computed changeset without persisting it.
49 #[serde(default)]
50 pub dry_run: bool,
51}
52
53/// Typed parameters for fetching boot parameters.
54///
55/// Precedence: `host_expression` > `group_name` >
56/// `settings_group_name`. The first one set is used; the others are
57/// ignored. If all three are unset the request fails.
58pub struct GetBootParametersParams {
59 /// Group whose members' boot parameters should be returned.
60 pub group_name: Option<String>,
61 /// Hosts expression (xnames, NIDs, or hostlist notation); mutually
62 /// exclusive with `group_name`.
63 pub host_expression: Option<String>,
64 /// Operator default from `cli.toml`'s `hsm_group`, used
65 /// when neither `group_name` nor `host_expression` is supplied.
66 pub settings_group_name: Option<String>,
67}
68
69impl GetBootParametersParams {
70 /// Returns the effective group name, preferring the explicit
71 /// `--group` flag and falling back to the operator default from
72 /// `cli.toml`.
73 pub fn effective_group(&self) -> Option<&str> {
74 self
75 .group_name
76 .as_deref()
77 .or(self.settings_group_name.as_deref())
78 }
79}
80
81/// Typed parameters for updating boot parameters.
82#[derive(serde::Deserialize, serde::Serialize, utoipa::ToSchema)]
83pub struct UpdateBootParametersParams {
84 /// Target node xnames.
85 pub hosts: Vec<String>,
86 /// Node IDs corresponding to `hosts` (optional alternate identifier).
87 pub nids: Option<Vec<u32>>,
88 /// MAC addresses corresponding to `hosts` (optional alternate identifier).
89 pub macs: Option<Vec<String>>,
90 /// Kernel command-line parameters string.
91 pub params: String,
92 /// S3 path to the kernel image.
93 pub kernel: String,
94 /// S3 path to the initrd image.
95 pub initrd: String,
96}